Skip to content

Commit

Permalink
Busybox
Browse files Browse the repository at this point in the history
  • Loading branch information
mtelvers committed Nov 7, 2024
1 parent c5f2c48 commit a330ec5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
7 changes: 3 additions & 4 deletions lib/qemu_snapshot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ open Lwt.Infix
let ( / ) = Filename.concat

let fetch ~log:_ ~root ~rootfs base =
let base_image = match base with
| "busybox" -> root / "base-image" / "ubuntu-noble-amd64-ocaml-4.14.qcow2"
| x -> root / "base-image" / (x ^ ".qcow2") in
Os.sudo [ "qemu-img"; "create"; "-f"; "qcow2"; "-b"; base_image; "-F"; "qcow2"; rootfs / "image.qcow2" ] >>= fun () ->
Os.sudo [ "qemu-img"; "create";
"-f"; "qcow2"; "-b"; root / "base-image" / (base ^ ".qcow2");
"-F"; "qcow2"; rootfs / "image.qcow2" ] >>= fun () ->
Lwt.return []

33 changes: 26 additions & 7 deletions qemu/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@

clean:
rm -f *.qcow2
rm -f *.qcow2 *.iso

# Windows

windows: windows-server-2022-amd64-ocaml-4.14.2.qcow2 windows-server-2022-amd64-ocaml-5.2.0.qcow2
windows: windows-server-2022-amd64-ocaml-4.14.qcow2 windows-server-2022-amd64-ocaml-5.2.qcow2 busybox.qcow2

windows-server-2022-amd64-ocaml-%.qcow2: unattend-%.iso virtio-win.iso
windows-server-2022-amd64-ocaml-5.2.qcow2: windows-server-2022-amd64-ocaml-5.2.0.qcow2
ln -s $< $@

windows-server-2022-amd64-ocaml-4.14.qcow2: windows-server-2022-amd64-ocaml-4.14.2.qcow2
ln -s $< $@

windows-server-2022-amd64-ocaml-%.qcow2: unattend-%.iso virtio-win.ISO
qemu-img create -f qcow2 $@ 40G
qemu-img create -f qcow2 cache-ntfs.qcow2 20G
qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=pc -cpu host -display none -vnc :0 \
Expand All @@ -15,7 +21,7 @@ windows-server-2022-amd64-ocaml-%.qcow2: unattend-%.iso virtio-win.iso
-drive file=cache-ntfs.qcow2,if=virtio \
-drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom \
-drive file=$<,media=cdrom \
-drive file=virtio-win.iso,media=cdrom
-drive file=virtio-win.ISO,media=cdrom

unattend-%.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe
m4 -D VERSION=$* $< > autounattend.xml
Expand All @@ -33,12 +39,12 @@ openssh-win64.msi:
setup-x86_64.exe:
curl -L https://www.cygwin.com/setup-x86_64.exe -o setup-x86_64.exe

virtio-win.iso:
curl -L https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.262-2/virtio-win.iso -o virtio-win.iso
virtio-win.ISO:
curl -L https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.262-2/virtio-win.iso -o virtio-win.ISO

# Ubuntu

ubuntu: ubuntu-noble-amd64-ocaml-4.14.2.qcow2 ubuntu-noble-amd64-ocaml-5.2.0.qcow2 ubuntu-noble-riscv64-ocaml-4.14.2.qcow2 ubuntu-noble-riscv64-ocaml-5.2.0.qcow2
ubuntu: ubuntu-noble-amd64-ocaml-4.14.2.qcow2 ubuntu-noble-amd64-ocaml-5.2.0.qcow2 ubuntu-noble-riscv64-ocaml-4.14.2.qcow2 ubuntu-noble-riscv64-ocaml-5.2.0.qcow2 busybox.qcow2

seed-%.iso: user-data.yaml.m4
m4 -D VERSION=$* $< > user-data.yaml
Expand Down Expand Up @@ -67,6 +73,19 @@ noble-server-cloudimg-%.qcow2: noble-server-cloudimg-%.img

noble-server-cloudimg-%.img: ;

# busybox

seed.iso: busybox.yaml
cp $< user-data.yaml
cloud-localds $@ user-data.yaml

busybox.qcow2: noble-server-cloudimg-amd64.qcow2 seed.iso
qemu-img create -f qcow2 -b $< -F qcow2 $@ 20G
qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=pc -cpu host -display none -vnc :0 \
-drive file=$@ \
-drive file=seed.iso,format=raw \
-nic user,hostfwd=tcp::60022-:22

# OpenBSD

openbsd: openbsd-76-amd64-ocaml-4.14.2.qcow2 openbsd-76-amd64-ocaml-5.2.0.qcow2
Expand Down
1 change: 1 addition & 0 deletions qemu/user-data.yaml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ runcmd:
- chmod +x /usr/bin/opam-dev
- ln -s /usr/bin/opam-dev /usr/bin/opam
- apt update
- apt upgrade
- apt install build-essential unzip bubblewrap -y
- su - opam -c "git clone https://github.com/ocaml/opam-repository"
- su - opam -c "opam init -k local -a /home/opam/opam-repository --bare --disable-sandboxing"
Expand Down

0 comments on commit a330ec5

Please sign in to comment.