diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..01e273f --- /dev/null +++ b/Containerfile @@ -0,0 +1,11 @@ +# mkosi container +# +# Builds and boots a test VM where the host has no systemd, such as a dev +# container (README.md). mkosi vm needs systemd to run qemu in a scope, so +# systemd runs as init here and mkosi runs through podman exec. +FROM registry.fedoraproject.org/fedora:45 +RUN dnf install -y --setopt=install_weak_deps=False mkosi dbus-broker \ + qemu-kvm-core edk2-ovmf /usr/bin/systemd-repart openssh-clients && \ + dnf install -y --setopt=install_weak_deps=False $(mkosi dependencies) && \ + dnf clean all +CMD ["/sbin/init"] diff --git a/README.md b/README.md index 0be543b..f1e89d4 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,21 @@ mkosi genkey # local test only, CI uses the SECUREBOOT_KEY secret mkosi build ``` -`mkosi.output/` then holds the disk image (`agent_.raw`) and the UKI and root partitions that make up an update. To build and boot a test VM with Secure Boot (needs `qemu-kvm-core edk2-ovmf`): +`mkosi.output/` then holds the disk image (`agent_.raw`) and the UKI and root partitions that make up an update. + +To build and boot a test VM with Secure Boot (needs `qemu-kvm-core edk2-ovmf`): ```sh mkosi -f vm ``` The `[Runtime]` section of `mkosi.conf` answers the setup, so it boots straight to a login (root, password `test`). Then `ssh -p 2222 claude@localhost` with your own key (`mkosi.credentials/agent.ssh-key`). + +`mkosi vm` needs systemd on the host. Without it, such as in a dev container, run mkosi in a container with systemd ([Containerfile](Containerfile)): + +```sh +podman build -t mkosi-vm . +podman run -d --name mkosi --systemd=always --privileged --device /dev/kvm -v .:/repo -v ~/.ssh:/root/.ssh:ro -w /repo mkosi-vm +podman exec -it mkosi mkosi -f vm +podman exec -it mkosi ssh -p 2222 claude@localhost # in another terminal +```