From c5f2c487976c3547c0e3abdc0d4a55f34f2af9c1 Mon Sep 17 00:00:00 2001 From: mtelvers Date: Thu, 7 Nov 2024 13:03:53 +0000 Subject: [PATCH] * Speed improvements on Windows platform * Added RISCV64 support * Added OpenBSD support --- doc/qemu.md | 67 ++- lib/build.ml | 9 +- lib/docker_sandbox.ml | 4 +- lib/qemu_sandbox.ml | 119 +++- lib/qemu_snapshot.ml | 5 +- lib/s.ml | 6 +- lib/sandbox.jail.ml | 4 +- lib/sandbox.macos.ml | 4 +- lib/sandbox.runc.ml | 4 +- main.ml | 2 +- qemu/Makefile | 117 ++-- qemu/autounattend.xml.m4 | 632 ++++++++++----------- qemu/disklabel | 10 + qemu/install.conf | 16 + qemu/install.site.m4 | 28 + qemu/{user-data.yaml => user-data.yaml.m4} | 20 +- test/mock_sandbox.ml | 4 +- 17 files changed, 608 insertions(+), 443 deletions(-) create mode 100644 qemu/disklabel create mode 100644 qemu/install.conf create mode 100644 qemu/install.site.m4 rename qemu/{user-data.yaml => user-data.yaml.m4} (53%) diff --git a/doc/qemu.md b/doc/qemu.md index 99d20b87..6e58dc70 100644 --- a/doc/qemu.md +++ b/doc/qemu.md @@ -6,16 +6,23 @@ which can provide an SSH interface. # Base Images These need to be provided as boot disks. There is a `Makefile` in the -`qemu` directory which builds two base images: +`qemu` directory which builds several base images: -- ubuntu-noble-x86_64-ocaml-4.14.img -- windows-server-2022-x86_64-ocaml-4.14.img +- 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 +- openbsd-67-amd64-ocaml-4.14.2.qcow2 +- openbsd-67-amd64-ocaml-5.2.0.qcow2 +- windows-server-2022-amd64-ocaml-4.14.2.qcow2 +- windows-server-2022-amd64-ocaml-5.2.0.qcow2 -The base images build automatically using Cloud Init on Ubuntu and -`autounattend.xml` on Windows. +The base images build automatically using Cloud Init on Ubuntu, +`autounattend.xml` on Windows and `autoinstall` on OpenBSD. -# Operation +Use `make ubuntu`, `make windows` or `make openbsd`. +# Operation A spec which reference the required base image in using the `from` directive, then run the whatever commands are required. An trivial @@ -23,19 +30,19 @@ example is given below. ``` ( - (from windows-server-2022-x86_64-ocaml-4.14) + (from windows-server-2022-amd64-ocaml-4.14.2) (run - (cache (opam-archives (target /Users/opam/AppData/Local/opam/download-cache))) + (run (cache (opam-archives (target "c:\\Users\\opam\\AppData\\local\\opam\\download-cache"))) (shell "opam install tar") ) ) ``` A typical invocation via `obuilder build` would be as below. Note that -in this example, the base images would be in `/data/base-image/*.img`. +in this example, the base images would be in `/var/cache/obuilder/base-image/*.qcow2`. ``` -./_build/install/default/bin/obuilder build --store=qemu:/data -v -f test.spec --qemu-memory 16 --qemu-cpus 8 . +obuilder build --store=qemu:/var/cache/obuilder -v -f test.spec --qemu-memory 16 --qemu-cpus 8 --qemu-guest-os windows . ``` The `from` directive causes `qemu-img` to create a snapshot of the base @@ -43,11 +50,11 @@ image and stage it in the `result-tmp` folder. When this completes successfully, `result-tmp` is moved to `result`: ``` -(from windows-server-2022-x86_64-ocaml-4.14) -obuilder: [INFO] Base image not present; importing "windows-server-2022-x86_64-ocaml-4.14"… +(from windows-server-2022-amd64-ocaml-4.14) +obuilder: [INFO] Base image not present; importing "windows-server-2022-amd64-ocaml-4.14"… obuilder: [INFO] Exec "mkdir" "-m" "755" "--" "/var/lib/docker/test/result-tmp/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101/rootfs" -obuilder: [INFO] Exec "qemu-img" "create" "-f" "qcow2" "-b" "/var/lib/docker/test/base-image/windows-server-2022-x86_64-ocaml-4.14.img" "-F" "qcow2" "/var/lib/docker/test/result-tmp/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101/rootfs/image.qcow2" -Formatting '/var/lib/docker/test/result-tmp/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101/rootfs/image.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=42949672960 backing_file=/var/lib/docker/test/base-image/windows-server-2022-x86_64-ocaml-4.14.img backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 +obuilder: [INFO] Exec "qemu-img" "create" "-f" "qcow2" "-b" "/var/lib/docker/test/base-image/windows-server-2022-amd64-ocaml-4.14.qcow2" "-F" "qcow2" "/var/lib/docker/test/result-tmp/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101/rootfs/image.qcow2" +Formatting '/var/lib/docker/test/result-tmp/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101/rootfs/image.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=42949672960 backing_file=/var/lib/docker/test/base-image/windows-server-2022-amd64-ocaml-4.14.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 obuilder: [INFO] Exec "mv" "/var/lib/docker/test/result-tmp/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101" "/var/lib/docker/test/result/dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101" ---> saved as “dce4336e183de81da7537728ed710f2906e9f75431694d9de80b95a9d9ff1101” ``` @@ -110,13 +117,35 @@ obuilder: [INFO] Exec "mv" "/var/cache/obuilder/test/result-tmp/8a897f21e54db877 Got: "8a897f21e54db877fc971c757ef7ffc2e1293e191dc60c3a18f24f0d3f0926f3" ``` -# Note +# Machine architectures + +QEMU support a variety of machine architectures. The target architecture +can be selected using `--qemu-guest-arch` parameter. At the moment only +AMD64 and RISCV64 are implemented in obuilder. + +``` +obuilder build --store=qemu:/var/cache/obuilder -v -f test.spec --qemu-memory 16 --qemu-cpus 8 --qemu-guest-os linux --qemu-guest-arch riscv64 . +``` + +By default, guests are given 30 seconds to boot and respond to SSH. +If you have slower hardware, you can add `--qemu-boot-time` to allow more +time of the machine to boot. + +# Cache + +Caching is implemented using additional hard disks which are added +to the machine and mounted on the cache location. Different guest +operating systems will require different filesystems to be available. +The `Makefile` builds suitable empty disks to be used as cache disks. -While this initial version only runs on x86_64 targetting x86_64 -processors it would be entirely possibly to extend this to other -architectures. +The `spec` file could account for the different cache disks by using +`opam-archives-XXX` rather than just `opam-archives`. e.g. + +``` +run (cache (opam-archives-ntfs (target "C:\\Users\\opam\\AppData\\Local\\opam\\download-cache"))) +``` -# Project source +# Importing the project source Obuilder uses `tar` to copy the project source into the sandbox. Attempts to use `tar -xf - . | ssh opam@localhost -p 60022 tar -xf -` diff --git a/lib/build.ml b/lib/build.ml index cc1cbde2..c8c2126d 100644 --- a/lib/build.ml +++ b/lib/build.ml @@ -148,7 +148,7 @@ module Make (Raw_store : S.STORE) (Sandbox : S.SANDBOX) (Fetch : S.FETCHER) = st (* Fmt.pr "COPY: %a@." Sexplib.Sexp.pp_hum (sexp_of_copy_details details); *) let id = Sha256.to_hex (Sha256.string (Sexplib.Sexp.to_string (sexp_of_copy_details details))) in Store.build t.store ?switch ~base ~id ~log (fun ~cancelled ~log result_tmp -> - let argv = Option.value ~default:(["tar"; "-xf"; "-"]) Sandbox.tar in + let argv = Option.value ~default:(["tar"; "-xf"; "-"]) (Sandbox.tar t.sandbox) in let config = Config.v ~cwd:"/" ~argv @@ -279,8 +279,8 @@ module Make (Raw_store : S.STORE) (Sandbox : S.SANDBOX) (Fetch : S.FETCHER) = st let df t = Store.df t.store - let shell = - Sandbox.shell + let shell t = + Sandbox.shell t.sandbox let root t = Store.root t.store @@ -544,8 +544,7 @@ module Make_Docker (Raw_store : S.STORE) = struct let df t = Store.df t.store - let shell = - Sandbox.shell + let shell _ = None let root t = Store.root t.store diff --git a/lib/docker_sandbox.ml b/lib/docker_sandbox.ml index 4d59990e..a7b5a7fa 100644 --- a/lib/docker_sandbox.ml +++ b/lib/docker_sandbox.ml @@ -462,9 +462,9 @@ let create (c : config) = let finished () = Lwt.return () -let shell = None +let shell _ = None -let tar = None +let tar _ = None open Cmdliner diff --git a/lib/qemu_sandbox.ml b/lib/qemu_sandbox.ml index de0adaba..4fd9800e 100644 --- a/lib/qemu_sandbox.ml +++ b/lib/qemu_sandbox.ml @@ -12,16 +12,31 @@ let copy_to_log ~src ~dst = in aux () +type guest_os = + | Linux + | OpenBSD + | Windows +[@@deriving sexp] + +type guest_arch = + | Amd64 + | Riscv64 +[@@deriving sexp] + type t = { qemu_cpus : int; qemu_memory : int; - qemu_network : string; (* Default network, overridden by network stanza *) + qemu_guest_os : guest_os; + qemu_guest_arch : guest_arch; + qemu_boot_time : int; } type config = { cpus : int; memory : int; - network : string; + guest_os : guest_os; + guest_arch : guest_arch; + boot_time : int; } [@@deriving sexp] let get_free_port () = @@ -37,22 +52,27 @@ let run ~cancelled ?stdin ~log t config result_tmp = let pp f = Os.pp_cmd f ("", config.Config.argv) in let extra_mounts = List.map (fun { Config.Mount.src; _ } -> - ["-drive"; "file=" ^ src / "rootfs" / "image.qcow2" ^ ",format=qcow2"] + ["-drive"; "file=" ^ src / "rootfs" / "image.qcow2" ^ ",if=virtio"] ) config.Config.mounts |> List.flatten in Os.with_pipe_to_child @@ fun ~r:qemu_r ~w:qemu_w -> let qemu_stdin = `FD_move_safely qemu_r in let qemu_monitor = Lwt_io.(of_fd ~mode:output) qemu_w in let port = get_free_port () in - let cmd = [ "qemu-system-x86_64"; + let qemu_binary = match t.qemu_guest_arch with + | Amd64 -> [ "qemu-system-x86_64"; "-machine"; "accel=kvm,type=pc"; "-cpu"; "host"; "-display"; "none"; + "-device"; "virtio-net,netdev=net0" ] + | Riscv64 -> [ "qemu-system-riscv64"; "-machine"; "type=virt"; "-nographic"; + "-bios"; "/usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin"; + "-kernel"; "/usr/lib/u-boot/qemu-riscv64_smode/uboot.elf"; + "-device"; "virtio-net-device,netdev=net0"; + "-serial"; "none"] in + let cmd = qemu_binary @ [ + "-monitor"; "stdio"; "-m"; (string_of_int t.qemu_memory) ^ "G"; "-smp"; string_of_int t.qemu_cpus; - "-machine"; "accel=kvm,type=q35"; - "-cpu"; "host"; - "-nic"; "user,hostfwd=tcp::" ^ port ^ "-:22"; - "-display"; "none"; - "-monitor"; "stdio"; - "-drive"; "file=" ^ result_tmp / "rootfs" / "image.qcow2" ^ ",format=qcow2" ] + "-netdev"; "user,id=net0,hostfwd=tcp::" ^ port ^ "-:22"; + "-drive"; "file=" ^ result_tmp / "rootfs" / "image.qcow2" ^ ",if=virtio" ] @ extra_mounts in let _, proc = Os.open_process ~stdin:qemu_stdin ~stdout:`Dev_null ~pp cmd in @@ -65,12 +85,22 @@ let run ~cancelled ?stdin ~log t config result_tmp = | Ok _ -> Lwt_result.ok (Lwt.return ()) | _ -> Lwt_unix.sleep 1. >>= fun _ -> loop (n - 1) in Lwt_unix.sleep 5. >>= fun _ -> - loop 30 >>= fun _ -> + loop t.qemu_boot_time >>= fun _ -> Lwt_list.iteri_s (fun i { Config.Mount.dst; _ } -> - Os.exec (ssh @ ["cmd"; "/c"; "rmdir /s /q '" ^ dst ^ "'"]) >>= fun () -> - let drive_letter = String.init 1 (fun _ -> Char.chr (Char.code 'd' + i)) in - Os.exec (ssh @ ["cmd"; "/c"; "mklink /j '" ^ dst ^ "' '" ^ drive_letter ^ ":\\'"])) config.Config.mounts >>= fun () -> + match t.qemu_guest_os with + | Linux -> + let dev = Printf.sprintf "/dev/vd%c1" (Char.chr (Char.code 'b' + i)) in + Os.exec (ssh @ ["sudo"; "mount"; dev; dst]) + | OpenBSD -> + let dev = Printf.sprintf "/dev/sd%ca" (Char.chr (Char.code '1' + i)) in + Os.exec (ssh @ ["doas"; "fsck"; "-y"; dev]) >>= fun () -> + Os.exec (ssh @ ["doas"; "mount"; dev; dst]) + | Windows -> + Os.exec (ssh @ ["cmd"; "/c"; "rmdir /s /q '" ^ dst ^ "'"]) >>= fun () -> + let drive_letter = String.init 1 (fun _ -> Char.chr (Char.code 'd' + i)) in + Os.exec (ssh @ ["cmd"; "/c"; "mklink /j '" ^ dst ^ "' '" ^ drive_letter ^ ":\\'"]) + ) config.Config.mounts >>= fun () -> Os.with_pipe_from_child @@ fun ~r:out_r ~w:out_w -> let stdin = Option.map (fun x -> `FD_move_safely x) stdin in @@ -91,8 +121,14 @@ let run ~cancelled ?stdin ~log t config result_tmp = Os.process_result ~pp proc2 >>= fun res -> copy_log >>= fun () -> - Log.info (fun f -> f "Sending QEMU an ACPI shutdown event"); - Lwt_io.write qemu_monitor "system_powerdown\n" >>= fun () -> + (match t.qemu_guest_arch with + | Amd64 -> + Log.info (fun f -> f "Sending QEMU an ACPI shutdown event"); + Lwt_io.write qemu_monitor "system_powerdown\n" + | Riscv64 -> + (* QEMU RISCV does not support ACPI until >= v9 *) + Log.info (fun f -> f "Shutting down the VM"); + Os.exec (ssh @ ["sudo"; "poweroff"])) >>= fun () -> let rec loop = function | 0 -> Log.warn (fun f -> f "Powering off QEMU"); @@ -102,7 +138,7 @@ let run ~cancelled ?stdin ~log t config result_tmp = Lwt_unix.sleep 1. >>= fun () -> loop (n - 1) else Lwt.return () in - loop 30 >>= fun _ -> + loop t.qemu_boot_time >>= fun _ -> Os.process_result ~pp proc >>= fun _ -> @@ -110,15 +146,19 @@ let run ~cancelled ?stdin ~log t config result_tmp = else Lwt_result.fail `Cancelled let create (c : config) = - let t = { qemu_cpus = c.cpus; qemu_memory = c.memory; qemu_network = c.network } in + let t = { qemu_cpus = c.cpus; qemu_memory = c.memory; qemu_guest_os = c.guest_os; qemu_guest_arch = c.guest_arch; qemu_boot_time = c.boot_time } in Lwt.return t let finished () = Lwt.return () -let shell = Some [] +let shell _ = Some [] -let tar = Some ["/cygdrive/c/Windows/System32/tar.exe"; "-xf"; "-"; "-C"; "/"] +let tar t = + match t.qemu_guest_os with + | Linux -> None + | OpenBSD -> Some ["gtar"; "-xf"; "-"] + | Windows -> Some ["/cygdrive/c/Windows/System32/tar.exe"; "-xf"; "-"; "-C"; "/"] open Cmdliner @@ -140,16 +180,39 @@ let memory = ~docv:"MEMORY" ["qemu-memory"] -let network = +let guest_os = + let options = + [("linux", Linux); + ("openbsd", OpenBSD); + ("windows", Windows)] in + Arg.value @@ + Arg.opt Arg.(enum options) Linux @@ + Arg.info ~docs + ~doc:(Printf.sprintf "Set OS used by QEMU guest. $(docv) must be %s." (Arg.doc_alts_enum options)) + ~docv:"GUEST_OS" + ["qemu-guest-os"] + +let guest_arch = + let options = + [("amd64", Amd64); + ("riscv64", Riscv64)] in + Arg.value @@ + Arg.opt Arg.(enum options) Amd64 @@ + Arg.info ~docs + ~doc:(Printf.sprintf "Set system architecture used by QEMU guest. $(docv) must be %s." (Arg.doc_alts_enum options)) + ~docv:"GUEST_OS" + ["qemu-guest-arch"] + +let boot_time = Arg.value @@ - Arg.opt Arg.string (if Sys.unix then "host" else "nat") @@ + Arg.opt Arg.int 30 @@ Arg.info ~docs - ~doc:"Docker network used for the Docker backend setup." - ~docv:"NETWORK" - ["qemu-network"] + ~doc:"The maximum time in seconds to wait for the machine to boot/power off." + ~docv:"BOOT_TIME" + ["qemu-boot-time"] let cmdliner : config Term.t = - let make cpus memory network = - { cpus; memory; network; } + let make cpus memory guest_os guest_arch boot_time = + { cpus; memory; guest_os; guest_arch; boot_time } in - Term.(const make $ cpus $ memory $ network) + Term.(const make $ cpus $ memory $ guest_os $ guest_arch $ boot_time) diff --git a/lib/qemu_snapshot.ml b/lib/qemu_snapshot.ml index 84cfd002..6c38b906 100644 --- a/lib/qemu_snapshot.ml +++ b/lib/qemu_snapshot.ml @@ -4,9 +4,8 @@ let ( / ) = Filename.concat let fetch ~log:_ ~root ~rootfs base = let base_image = match base with - | "busybox" -> root / "base-image" / "ubuntu-noble-x86_64-ocaml-4.14.img" - | x -> root / "base-image" / (x ^ ".img") in + | "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 () -> Lwt.return [] - diff --git a/lib/s.ml b/lib/s.ml index 033027f7..decc4f0a 100644 --- a/lib/s.ml +++ b/lib/s.ml @@ -89,10 +89,10 @@ module type SANDBOX = sig @param log Used for child's stdout and stderr. *) - val shell : string list option + val shell : t -> string list option (** [shell] optional value to be used as the default shell. *) - val tar : string list option + val tar : t -> string list option (** [tar] tar command for this sandbox. *) val finished : unit -> unit Lwt.t @@ -134,7 +134,7 @@ module type BUILDER = sig val df : t -> float Lwt.t (** [df t] returns the percentage of free space in the store. *) - val shell : string list option + val shell : t -> string list option (** [shell] optional value to be used as the default shell. *) val cache_stats : t -> int * int diff --git a/lib/sandbox.jail.ml b/lib/sandbox.jail.ml index 9e897139..0b7c66bb 100644 --- a/lib/sandbox.jail.ml +++ b/lib/sandbox.jail.ml @@ -168,9 +168,9 @@ let create ~state_dir:_ _c = let finished () = Lwt.return () -let shell = None +let shell _ = None -let tar = None +let tar _ = None open Cmdliner diff --git a/lib/sandbox.macos.ml b/lib/sandbox.macos.ml index dbbab665..36b0879b 100644 --- a/lib/sandbox.macos.ml +++ b/lib/sandbox.macos.ml @@ -114,9 +114,9 @@ let finished () = Os.sudo [ "zfs"; "mount"; "obuilder/result" ] >>= fun () -> Lwt.return () -let shell = None +let shell _ = None -let tar = None +let tar _ = None let uid = Arg.required @@ diff --git a/lib/sandbox.runc.ml b/lib/sandbox.runc.ml index b780bbcb..ef9952e6 100644 --- a/lib/sandbox.runc.ml +++ b/lib/sandbox.runc.ml @@ -336,9 +336,9 @@ let create ~state_dir (c : config) = let finished () = Lwt.return () -let shell = None +let shell _ = None -let tar = None +let tar _ = None open Cmdliner diff --git a/main.ml b/main.ml index 6157ab6b..c431029b 100644 --- a/main.ml +++ b/main.ml @@ -64,7 +64,7 @@ let build () store spec native_conf docker_conf qemu_conf src_dir secrets = exit 1 in let secrets = List.map (fun (id, path) -> id, read_whole_file path) secrets in - let context = Obuilder.Context.v ~log ~src_dir ?shell:(Builder.shell) ~secrets () in + let context = Obuilder.Context.v ~log ~src_dir ?shell:(Builder.shell builder) ~secrets () in Builder.build builder context spec >>= function | Ok x -> Fmt.pr "Got: %S@." (x :> string); diff --git a/qemu/Makefile b/qemu/Makefile index ad5ba17e..692218e1 100644 --- a/qemu/Makefile +++ b/qemu/Makefile @@ -1,42 +1,31 @@ -all: windows-server-2022-x86_64-ocaml-4.14.img ubuntu-noble-x86_64-ocaml-4.14.img - clean: - rm -f unattend.iso seed.iso ubuntu-noble-x86_64-ocaml-4.14.img windows-server-2022-x86_64-ocaml-4.14.img + rm -f *.qcow2 # Windows -windows-server-2022-x86_64-ocaml-5.2.img: unattend-5.2.0.iso - qemu-img create -f qcow2 windows-server-2022-x86_64-ocaml-5.2.img 40G - qemu-img create -f qcow2 cache.qcow2 20G - qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22 \ - -drive file=windows-server-2022-x86_64-ocaml-5.2.img \ - -drive file=cache.qcow2 \ - -drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom \ - -drive file=unattend-5.2.0.iso,media=cdrom - -windows-server-2022-x86_64-ocaml-4.14.img: unattend-4.14.2.iso - qemu-img create -f qcow2 windows-server-2022-x86_64-ocaml-4.14.img 40G - qemu-img create -f qcow2 cache.qcow2 20G - qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22 \ - -drive file=windows-server-2022-x86_64-ocaml-4.14.img \ - -drive file=cache.qcow2 \ - -drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom \ - -drive file=unattend-4.14.2.iso,media=cdrom +windows: windows-server-2022-amd64-ocaml-4.14.2.qcow2 windows-server-2022-amd64-ocaml-5.2.0.qcow2 -unattend-4.14.2.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe - m4 -D VERSION=4.14.2 autounattend.xml.m4 > autounattend.xml - mkisofs -o unattend-4.14.2.iso -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe +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 \ + -netdev user,id=net0,hostfwd=tcp::60022-:22 -device virtio-net,netdev=net0 \ + -drive file=$@,if=virtio \ + -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 -unattend-5.2.0.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe - m4 -D VERSION=5.2.0 autounattend.xml.m4 > autounattend.xml - mkisofs -o unattend-5.2.0.iso -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe +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 + mkisofs -o $@ -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe opam-2.2.exe: - curl -L https://github.com/ocaml/opam/releases/download/2.2.1/opam-2.2.1-x86_64-windows.exe -o opam-2.2.exe + curl -L https://github.com/ocaml/opam/releases/download/2.2.1/opam-2.2.1-amd64-windows.exe -o opam-2.2.exe opam-dev.exe: - curl -L https://github.com/ocaml/opam/releases/download/2.3.0-beta1/opam-2.3.0-beta1-x86_64-windows.exe -o opam-dev.exe + curl -L https://github.com/ocaml/opam/releases/download/2.3.0-beta1/opam-2.3.0-beta1-amd64-windows.exe -o opam-dev.exe openssh-win64.msi: curl -L https://github.com/PowerShell/Win32-OpenSSH/releases/download/v9.2.2.0p1-Beta/OpenSSH-Win64-v9.2.2.0.msi -o openssh-win64.msi @@ -49,13 +38,67 @@ virtio-win.iso: # Ubuntu -seed.iso: user-data.yaml - cloud-localds seed.iso user-data.yaml - -ubuntu-noble-x86_64-ocaml-4.14.img: noble-server-cloudimg-amd64.img seed.iso - qemu-img create -f qcow2 -b noble-server-cloudimg-amd64.img -F qcow2 ubuntu-noble-x86_64-ocaml-4.14.img 20G - qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -drive file=ubuntu-noble-x86_64-ocaml-4.14.img -drive file=seed.iso,format=raw -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22 - -noble-server-cloudimg-amd64.img: - curl -L https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img -o noble-server-cloudimg-amd64.img +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 + +seed-%.iso: user-data.yaml.m4 + m4 -D VERSION=$* $< > user-data.yaml + cloud-localds $@ user-data.yaml + +ubuntu-noble-amd64-ocaml-%.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 + +ubuntu-noble-riscv64-ocaml-%.qcow2: noble-server-cloudimg-riscv64.qcow2 seed-%.iso + qemu-img create -f qcow2 -b $< -F qcow2 $@ 20G + qemu-system-riscv64 -m 16G -smp 8 -machine type=virt -nographic \ + -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin \ + -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \ + -drive file=$@,if=virtio \ + -drive file=seed-$*.iso,format=raw,if=virtio \ + -netdev user,id=net0,hostfwd=tcp::60022-:22 -device virtio-net-device,netdev=net0 + +.NOTINTERMEDIATE: $(wildcard noble-server-cloudimg-*.qcow2) + +noble-server-cloudimg-%.qcow2: noble-server-cloudimg-%.img + curl -C - -L https://cloud-images.ubuntu.com/noble/current/$< -o $@ + +noble-server-cloudimg-%.img: ; + +# OpenBSD + +openbsd: openbsd-76-amd64-ocaml-4.14.2.qcow2 openbsd-76-amd64-ocaml-5.2.0.qcow2 + +openbsd-76-amd64-ocaml-%.qcow2: tftp/auto_install tftp/bsd.rd tftp/etc/boot.conf mirror% + qemu-img create -f qcow2 $@ 24G + qemu-img create -f qcow2 cache-ffs.qcow2 20G + python3 -m http.server --directory mirror --bind 0.0.0.0 80 & \ + qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=pc -cpu host -display none -vnc :0 \ + -drive file=$@,if=virtio \ + -drive file=cache-ffs.qcow2,if=virtio \ + -nic user,model=virtio,tftp-server-name=10.0.2.2,tftp=tftp,bootfile=auto_install,hostfwd=tcp::60022-:22 ;\ + kill \%1 + +tftp/auto_install: + mkdir -p tftp + curl -L https://cdn.openbsd.org/pub/OpenBSD/7.6/amd64/pxeboot -o tftp/auto_install + +tftp/bsd.rd: + mkdir -p tftp + curl -L https://cdn.openbsd.org/pub/OpenBSD/7.6/amd64/bsd.rd -o tftp/bsd.rd + +tftp/etc/boot.conf: + mkdir -p tftp/etc + echo boot tftp:/bsd.rd > tftp/etc/boot.conf + +mirror%: install.site.m4 install.conf disklabel + m4 -D VERSION=$* $< > install.site + chmod +x install.site + mkdir -p mirror/pub/OpenBSD/7.6/amd64 + tar -czf mirror/pub/OpenBSD/7.6/amd64/site76.tgz install.site + for f in BUILDINFO SHA256.sig base76.tgz bsd bsd.mp bsd.rd comp76.tgz game76.tgz man76.tgz pxeboot xbase76.tgz xfont76.tgz xserv76.tgz xshare76.tgz ; do curl -C - -L https://cdn.openbsd.org/pub/OpenBSD/7.6/amd64/$$f -o mirror/pub/OpenBSD/7.6/amd64/$$f ; done + cd mirror/pub/OpenBSD/7.6/amd64 && ls -l > index.txt + cp install.conf disklabel mirror diff --git a/qemu/autounattend.xml.m4 b/qemu/autounattend.xml.m4 index 43d2276a..8e8348c9 100644 --- a/qemu/autounattend.xml.m4 +++ b/qemu/autounattend.xml.m4 @@ -1,335 +1,307 @@ - - - - - + + + + en-US + + en-US + en-US en-US - - en-US - en-US - en-US - en-US - en-US - - - - - - - 1 - BypassTPMCheck - cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d 1 - - - 2 - BypassSecureBootCheck - cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d 1 - - - 3 - BypassRAMCheck - cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1 - - - - - - - - Primary - 1 - 350 - - - 2 - Primary - true - - - - - true - NTFS - 1 - 1 - - - NTFS - C - 2 - 2 - - - 0 - true - - - - - 1 - Primary - true - - - - - NTFS - D - 1 - 1 - - - 1 - true - - - - - - - - - /IMAGE/NAME - Windows Server 2022 SERVERSTANDARDCORE - - - - - 0 - 2 - - - OnError - - - - - - - OnError - - true - - - - + en-US + en-US + + + + + f:\NetKVM\w11\amd64\ + + + f:\viostor\w11\amd64\ + + + + + + + 1 + BypassTPMCheck + cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d 1 + + + 2 + BypassSecureBootCheck + cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d 1 + + + 3 + BypassRAMCheck + cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1 + + + + + + + Primary + 1 + 350 + + + 2 + Primary + true + + + + + true + NTFS + 1 + 1 + + + NTFS + C + 2 + 2 + + + 0 + true + + + + + 1 + Primary + true + + + + + NTFS + Z + 1 + 1 + + + 1 + true + + + + + + + /IMAGE/NAME + Windows Server 2022 SERVERSTANDARDCORE + + + + 0 + 2 + + OnError + + + + + OnError + + true + + + + + + + + bwBwAGEAbQBBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA= + false</PlainText> + </AdministratorPassword> + <LocalAccounts> + <LocalAccount wcm:action="add"> + <Password> + <Value>bwBwAGEAbQBQAGEAcwBzAHcAbwByAGQA</Value> + <PlainText>false</PlainText> + </Password> + <Group>administrators</Group> + <DisplayName>opam</DisplayName> + <Name>opam</Name> + <Description>Opam User</Description> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <AutoLogon> + <Enabled>true</Enabled> + <LogonCount>3</LogonCount> + <Username>opam</Username> + <Password> + <Value>opam</Value> + <PlainText>true</PlainText> + </Password> + </AutoLogon> + <OOBE> + <HideEULAPage>true</HideEULAPage> + <ProtectYourPC>1</ProtectYourPC> + <HideLocalAccountScreen>true</HideLocalAccountScreen> + <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> + <HideOnlineAccountScreens>true</HideOnlineAccountScreens> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + </OOBE> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <Order>1</Order> + <CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Uninstall-WindowsFeature -Name Windows-Defender -Restart"</CommandLine> + <Description>Remove Windows-Defender</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>2</Order> + <CommandLine>cmd /C wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE</CommandLine> + <Description>PasswordExpires=FALSE</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>3</Order> + <CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Set-NetConnectionProfile -NetworkCategory Private -InputObject (Get-NetConnectionProfile)"</CommandLine> + <Description>NetworkLocation</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>4</Order> + <CommandLine>winrm quickconfig -q</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>5</Order> + <CommandLine>winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>6</Order> + <CommandLine>winrm set winrm/config/service/auth @{Basic="true"}</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>7</Order> + <CommandLine>netsh advfirewall firewall set rule group="remote administration" new enable=yes</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>8</Order> + <CommandLine>net stop winrm</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>9</Order> + <CommandLine>net start winrm</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>10</Order> + <CommandLine>cmd /c "copy e:\setup-x86_64.exe c:\windows\setup-x86_64.exe"</CommandLine> + <Description>Copy cygwin executable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>11</Order> + <CommandLine>c:\windows\setup-x86_64.exe -q -O --site https://cygwin.mirror.constant.com --symlink-type native -P mingw64-x86_64-gcc-core,rsync,git,make,patch,unzip,pkgconf,pkg-config</CommandLine> + <Description>Install cygwin</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>12</Order> + <CommandLine>setx /m PATH "c:\cygwin64\bin;c:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin;%PATH%"</CommandLine> + <Description>Set PATH environment variable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>13</Order> + <CommandLine>c:\cygwin64\bin\gawk.exe -i inplace "/(^#)|(^$)/{print;next}{$4=""noacl,""$4;print}" C:\cygwin64\etc\fstab</CommandLine> + <Description>Add opam-repository</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>14</Order> + <CommandLine>setx /m OPAMCONFIRMLEVEL unsafe-yes</CommandLine> + <Description>Set PATH environment variable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>15</Order> + <CommandLine>setx /m OPAMYES 1</CommandLine> + <Description>Set PATH environment variable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>16</Order> + <CommandLine>reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d c:\cygwin64\bin\bash.exe</CommandLine> + <Description>Configure WinRM</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>17</Order> + <CommandLine>cmd /c "msiexec /q /norestart /i e:\openssh-win64.msi"</CommandLine> + <Description>Install OpenSSH</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>18</Order> + <CommandLine>cmd /c "copy e:\id_ed25519.pub c:\programdata\ssh\administrators_authorized_keys"</CommandLine> + <Description>Install public key</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>19</Order> + <CommandLine>cmd /c "echo AcceptENV * &gt;&gt; c:\programdata\ssh\sshd_config"</CommandLine> + <Description>Install public key</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>20</Order> + <CommandLine>netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine> + <Description>Configure OpenSSH</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>21</Order> + <CommandLine>cmd /c "copy e:\opam-2.2.exe c:\cygwin64\bin\opam.exe"</CommandLine> + <Description>Copy opam executable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>22</Order> + <CommandLine>cmd /c "copy e:\opam-2.2.exe c:\cygwin64\bin\opam-2.2.exe"</CommandLine> + <Description>Copy opam executable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>23</Order> + <CommandLine>cmd /c "copy e:\opam-dev.exe c:\cygwin64\bin\opam-dev.exe"</CommandLine> + <Description>Copy opam executable</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>24</Order> + <CommandLine>c:\cygwin64\bin\bash.exe --login -c "cd /cygdrive/c/Users/opam &amp;&amp; git clone https://github.com/ocaml/opam-repository"</CommandLine> + <Description>Add opam-repository</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>25</Order> + <CommandLine>c:\cygwin64\bin\opam init -y -k local -a c:\users\opam\opam-repository --bare --cygwin-location=c:\cygwin64</CommandLine> + <Description>Opam init</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>26</Order> + <CommandLine>c:\cygwin64\bin\opam switch create VERSION --packages=ocaml-base-compiler.VERSION</CommandLine> + <Description>Opam switch</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>27</Order> + <CommandLine>c:\cygwin64\bin\opam pin add -k version ocaml-base-compiler VERSION</CommandLine> + <Description>Opam switch</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>28</Order> + <CommandLine>mkdir c:\users\opam\src</CommandLine> + <Description>Create a src directory</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>29</Order> + <CommandLine>shutdown /s /t 10</CommandLine> + <Description>Shutdown</Description> + </SynchronousCommand> + </FirstLogonCommands> + </component> + </settings> + <settings pass="offlineServicing"> + <component name="Microsoft-Windows-PartitionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <SanPolicy>1</SanPolicy> + </component> </settings> - - <settings pass="oobeSystem"> - - <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <Reseal> - <Mode>Audit</Mode> - </Reseal> - </component> - - <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <FirstLogonCommands> - - <SynchronousCommand wcm:action="add"> - <Order>1</Order> - <CommandLine>cmd /C wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE</CommandLine> - <Description>PasswordExpires=FALSE</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>2</Order> - <CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Set-NetConnectionProfile -NetworkCategory Private -InputObject (Get-NetConnectionProfile)"</CommandLine> - <Description>NetworkLocation</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>3</Order> - <CommandLine>winrm quickconfig -q</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>4</Order> - <CommandLine>winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>5</Order> - <CommandLine>winrm set winrm/config/service/auth @{Basic="true"}</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>6</Order> - <CommandLine>netsh advfirewall firewall set rule group="remote administration" new enable=yes</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>7</Order> - <CommandLine>net stop winrm</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>8</Order> - <CommandLine>net start winrm</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>9</Order> - <CommandLine>cmd /c "copy f:\setup-x86_64.exe c:\windows\setup-x86_64.exe"</CommandLine> - <Description>Copy cygwin executable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>10</Order> - <CommandLine>c:\windows\setup-x86_64.exe -q -O --site https://cygwin.mirror.constant.com --symlink-type native -P mingw64-x86_64-gcc-core,rsync,git,make,patch,unzip,pkgconf,pkg-config</CommandLine> - <Description>Install cygwin</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>11</Order> - <CommandLine>setx /m PATH "c:\cygwin64\bin;c:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin;%PATH%"</CommandLine> - <Description>Set PATH environment variable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>12</Order> - <CommandLine>c:\cygwin64\bin\gawk.exe -i inplace "/(^#)|(^$)/{print;next}{$4=""noacl,""$4;print}" C:\cygwin64\etc\fstab</CommandLine> - <Description>Add opam-repository</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>13</Order> - <CommandLine>setx /m OPAMCONFIRMLEVEL unsafe-yes</CommandLine> - <Description>Set PATH environment variable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>14</Order> - <CommandLine>setx /m OPAMYES 1</CommandLine> - <Description>Set PATH environment variable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>15</Order> - <CommandLine>reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d c:\cygwin64\bin\bash.exe</CommandLine> - <Description>Configure WinRM</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>16</Order> - <CommandLine>cmd /c "msiexec /q /norestart /i f:\openssh-win64.msi"</CommandLine> - <Description>Install OpenSSH</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>17</Order> - <CommandLine>cmd /c "copy f:\id_ed25519.pub c:\programdata\ssh\administrators_authorized_keys"</CommandLine> - <Description>Install public key</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>18</Order> - <CommandLine>cmd /c "echo AcceptENV * >> c:\programdata\ssh\sshd_config"</CommandLine> - <Description>Install public key</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>19</Order> - <CommandLine>netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine> - <Description>Configure OpenSSH</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>20</Order> - <CommandLine>cmd /c "copy f:\opam-2.2.exe c:\cygwin64\bin\opam.exe"</CommandLine> - <Description>Copy opam executable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>21</Order> - <CommandLine>cmd /c "copy f:\opam-2.2.exe c:\cygwin64\bin\opam-2.2.exe"</CommandLine> - <Description>Copy opam executable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>22</Order> - <CommandLine>cmd /c "copy f:\opam-dev.exe c:\cygwin64\bin\opam-dev.exe"</CommandLine> - <Description>Copy opam executable</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>23</Order> - <CommandLine>c:\cygwin64\bin\bash.exe --login -c "cd /cygdrive/c/Users/opam && git clone https://github.com/ocaml/opam-repository"</CommandLine> - <Description>Add opam-repository</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>24</Order> - <CommandLine>c:\cygwin64\bin\opam init -y -k local -a c:\users\opam\opam-repository --bare --cygwin-location=c:\cygwin64</CommandLine> - <Description>Opam init</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>25</Order> - <CommandLine>c:\cygwin64\bin\opam switch create VERSION --packages=ocaml-base-compiler.VERSION</CommandLine> - <Description>Opam switch</Description> - </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <Order>26</Order> - <CommandLine>c:\cygwin64\bin\opam pin add -k version ocaml-base-compiler VERSION</CommandLine> - <Description>Opam switch</Description> - </SynchronousCommand> - - </FirstLogonCommands> - - </component> - - </settings> - - <settings pass="auditSystem"> - - <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <UserAccounts> - - <AdministratorPassword> - <Value>opam</Value> - <PlainText>true</PlainText> - </AdministratorPassword> - - <LocalAccounts> - <LocalAccount wcm:action="add"> - <Password> - <Value>opam</Value> - <PlainText>true</PlainText> - </Password> - <Group>administrators</Group> - <DisplayName>opam</DisplayName> - <Name>opam</Name> - <Description>Opam User</Description> - </LocalAccount> - </LocalAccounts> - - </UserAccounts> - - <AutoLogon> - <Enabled>true</Enabled> - <LogonCount>3</LogonCount> - <Username>opam</Username> - <Password> - <Value>opam</Value> - <PlainText>true</PlainText> - </Password> - </AutoLogon> - - </component> - - </settings> - </unattend> - diff --git a/qemu/disklabel b/qemu/disklabel new file mode 100644 index 00000000..f6d5d805 --- /dev/null +++ b/qemu/disklabel @@ -0,0 +1,10 @@ +/ 2G +swap 2G +/tmp 1G +/var 1G +/usr 2G +/usr/X11R6 500M +/usr/local 4G +/usr/src 1M +/usr/obj 1M +/home 10G diff --git a/qemu/install.conf b/qemu/install.conf new file mode 100644 index 00000000..fd6eeb52 --- /dev/null +++ b/qemu/install.conf @@ -0,0 +1,16 @@ +Change the default console to com0 = no +Which speed should com0 use = 115200 +System hostname = openbsd +Password for root = ************* +Allow root ssh login = no +Setup a user = opam +Password for user = ************* +Public ssh key for user = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA09mqKPpMJ4tyOpl4l+KTTl1DqjFT2mRD29HW8VwnmB root@alpha +What timezone are you in = UTC +Location of sets = http +HTTP Server = 10.0.2.2 +Unable to connect using https. Use http instead = yes +URL to autopartitioning template for disklabel = http://10.0.2.2/disklabel +Set name(s) = site76.tgz +Checksum test for site76.tgz failed. Continue anyway = yes +Unverified sets: site76.tgz. Continue without verification = yes diff --git a/qemu/install.site.m4 b/qemu/install.site.m4 new file mode 100644 index 00000000..68c97e2c --- /dev/null +++ b/qemu/install.site.m4 @@ -0,0 +1,28 @@ +#!/bin/ksh +set -o errexit +echo "https://cdn.openbsd.org/pub/OpenBSD" > /etc/installurl +echo "permit nopass keepenv :wheel" >> /etc/doas.conf + +cat <<EOF >> /etc/rc.firsttime +echo "AcceptEnv=*" >> /etc/ssh/sshd_config +echo "PermitUserEnvironment=yes" >> /etc/ssh/sshd_config +pkg_add curl-- gmake gtar-- gpatch unzip-- rsync-- git +/usr/local/bin/curl -L https://github.com/ocaml/opam/releases/download/2.3.0-rc1/opam-2.3.0-rc1-x86_64-openbsd -o /usr/bin/opam +chmod +x /usr/bin/opam +su - opam -c "echo OPAMYES=1 >> .ssh/environment" +su - opam -c "echo OPAMCONFIRMLEVEL=unsafe-yes >> .ssh/environment" +su - opam -c "echo OPAMERRLOGLEN=0 >> .ssh/environment" +su - opam -c "echo OPAMPRECISETRACKING=1 >> .ssh/environment" +su - opam -c "git clone https://github.com/ocaml/opam-repository" +su - opam -c "opam init -k local -a /home/opam/opam-repository --bare" +su - opam -c "rm -rf .opam/repo/default/.git" +su - opam -c "opam switch create VERSION --packages=ocaml-base-compiler.VERSION" +su - opam -c "opam pin add -k version ocaml-base-compiler VERSION" +su - opam -c "opam install -y opam-depext" +su - opam -c "mkdir src" +echo '/ * 100%' > /tmp/sd1 +disklabel -Aw -T /tmp/sd1 sd1 +newfs sd1a +shutdown -p +1 +EOF + diff --git a/qemu/user-data.yaml b/qemu/user-data.yaml.m4 similarity index 53% rename from qemu/user-data.yaml rename to qemu/user-data.yaml.m4 index 99530235..f7e04e64 100644 --- a/qemu/user-data.yaml +++ b/qemu/user-data.yaml.m4 @@ -4,19 +4,25 @@ users: groups: [sudo] sudo: ALL=(ALL) NOPASSWD:ALL shell: /bin/bash - passwd: opam ssh_authorized_keys: - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA09mqKPpMJ4tyOpl4l+KTTl1DqjFT2mRD29HW8VwnmB root@alpha runcmd: - echo "AcceptEnv=*" > /etc/ssh/sshd_config.d/acceptenv.conf - - curl -L https://github.com/ocaml/opam/releases/download/2.2.1/opam-2.2.1-x86_64-linux -o /usr/bin/opam - - chmod +x /usr/bin/opam + - mkdir /tmp/opam + - curl -L https://opam.ocaml.org/install.sh -o /tmp/opam/install.sh + - chmod +x /tmp/opam/install.sh + - (cd /tmp/opam && ./install.sh --download-only --dev) + - mv /tmp/opam/opam-* /usr/bin/opam-dev + - chmod +x /usr/bin/opam-dev + - ln -s /usr/bin/opam-dev /usr/bin/opam + - apt update - 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" + - su - opam -c "opam init -k local -a /home/opam/opam-repository --bare --disable-sandboxing" - su - opam -c "rm -rf .opam/repo/default/.git" - - su - opam -c "echo export OPAMYES=1 OPAMCONFIRMLEVEL=unsafe-yes OPAMERRLOGLEN=0 OPAMPRECISETRACKING=1 >> .profile" - - su - opam -c "opam switch create 4.14 --packages=ocaml-base-compiler.4.14.2" - - su - opam -c "opam pin add -k version ocaml-base-compiler 4.14.2" + - su - opam -c "echo export OPAMYES=1 OPAMCONFIRMLEVEL=unsafe-yes OPAMERRLOGLEN=0 OPAMPRECISETRACKING=1 >> .bashrc" + - su - opam -c "opam switch create VERSION --packages=ocaml-base-compiler.VERSION" + - su - opam -c "opam pin add -k version ocaml-base-compiler VERSION" - su - opam -c "opam install -y opam-depext" + - su - opam -c "mkdir ~/src" - poweroff diff --git a/test/mock_sandbox.ml b/test/mock_sandbox.ml index 18852462..84cd56d5 100644 --- a/test/mock_sandbox.ml +++ b/test/mock_sandbox.ml @@ -25,6 +25,6 @@ let create () = { expect = Queue.create () } let finished () = Lwt.return () -let shell = None +let shell _ = None -let tar = None +let tar _ = None