From a330ec5b43e20479c6b2366854adb65e7d8969ee Mon Sep 17 00:00:00 2001 From: mtelvers Date: Thu, 7 Nov 2024 15:53:07 +0000 Subject: [PATCH] Busybox --- lib/qemu_snapshot.ml | 7 +++---- qemu/Makefile | 33 ++++++++++++++++++++++++++------- qemu/user-data.yaml.m4 | 1 + 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/qemu_snapshot.ml b/lib/qemu_snapshot.ml index 6c38b906..91e1fb2a 100644 --- a/lib/qemu_snapshot.ml +++ b/lib/qemu_snapshot.ml @@ -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 [] diff --git a/qemu/Makefile b/qemu/Makefile index 692218e1..11350745 100644 --- a/qemu/Makefile +++ b/qemu/Makefile @@ -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 \ @@ -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 @@ -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 @@ -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 diff --git a/qemu/user-data.yaml.m4 b/qemu/user-data.yaml.m4 index f7e04e64..c242f9f3 100644 --- a/qemu/user-data.yaml.m4 +++ b/qemu/user-data.yaml.m4 @@ -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"