diff --git a/boot/Dockerfile b/boot/Dockerfile index 459036a..aeb4be3 100644 --- a/boot/Dockerfile +++ b/boot/Dockerfile @@ -9,8 +9,9 @@ COPY sprout.efi /work/${EFI_NAME}.EFI COPY sprout.toml /work/SPROUT.TOML COPY kernel.efi /work/KERNEL.EFI COPY shell.efi /work/SHELL.EFI +COPY initramfs /work/INITRAMFS COPY edera-splash.png /work/EDERA-SPLASH.PNG -RUN truncate -s256MiB sprout.img && \ +RUN truncate -s128MiB sprout.img && \ parted --script sprout.img mklabel gpt > /dev/null 2>&1 && \ parted --script sprout.img mkpart primary fat32 1MiB 100% > /dev/null 2>&1 && \ parted --script sprout.img set 1 esp on > /dev/null 2>&1 && \ @@ -22,6 +23,7 @@ RUN truncate -s256MiB sprout.img && \ mcopy -i sprout.img SHELL.EFI ::/EFI/BOOT/ && \ mcopy -i sprout.img SPROUT.TOML ::/ && \ mcopy -i sprout.img EDERA-SPLASH.PNG ::/ && \ + mcopy -i sprout.img INITRAMFS ::/ && \ mv sprout.img /sprout.img FROM scratch AS final diff --git a/hack/boot.sh b/hack/boot.sh index 46dae95..3494d9a 100755 --- a/hack/boot.sh +++ b/hack/boot.sh @@ -27,14 +27,9 @@ else -chardev stdio,id=stdio0 \ -device virtconsole,chardev=stdio0,id=console0 - if [ "${TARGET_ARCH}" = "x86_64" ]; then - set -- "${@}" \ - -vga std - else - set -- "${@}" \ - -vga none \ - -device "virtio-gpu,edid=on,xres=1024,yres=768" - fi + set -- "${@}" \ + -vga none \ + -device "virtio-gpu,edid=on,xres=1024,yres=768" fi rm -f "${FINAL_DIR}/ovmf-boot.fd" diff --git a/hack/build.sh b/hack/build.sh index 627edf6..7928454 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -79,6 +79,8 @@ if [ "${SKIP_VM_BUILD}" != "1" ]; then docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}:${DOCKER_TAG}" -f vm/Dockerfile.ovmf "${FINAL_DIR}" copy_from_image "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}" "ovmf.fd" "${FINAL_DIR}/ovmf.fd" copy_from_image "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}" "shell.efi" "${FINAL_DIR}/shell.efi" + docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-initramfs-${TARGET_ARCH}:${DOCKER_TAG}" -f vm/Dockerfile.initramfs "${FINAL_DIR}" + copy_from_image "${DOCKER_PREFIX}/sprout-initramfs-${TARGET_ARCH}" "initramfs" "${FINAL_DIR}/initramfs" fi if [ "${SKIP_SPROUT_BUILD}" != "1" ]; then @@ -102,6 +104,7 @@ if [ "${SKIP_SPROUT_BUILD}" != "1" ]; then fi cp "${FINAL_DIR}/sprout.toml" "${FINAL_DIR}/efi/SPROUT.TOML" cp "${FINAL_DIR}/edera-splash.png" "${FINAL_DIR}/efi/EDERA-SPLASH.PNG" + cp "${FINAL_DIR}/initramfs" "${FINAL_DIR}/efi/INITRAMFS" fi if [ "${SKIP_BOOT_BUILD}" != "1" ]; then diff --git a/hack/configs/kernel.sprout.toml b/hack/configs/kernel.sprout.toml index 5e65ee1..0a1c2c6 100644 --- a/hack/configs/kernel.sprout.toml +++ b/hack/configs/kernel.sprout.toml @@ -1,19 +1,22 @@ version = 1 [values] -default-options = "console=hvc0" +default-options = "initrd=\\initramfs init=/bin/sh console=hvc0" [actions.welcome] print.text = "Welcome to Sprout!" [actions.splash] splash.image = "edera-splash.png" -splash.time = 5 +splash.time = 1 [actions.chainload-kernel] chainload.path = "$path" chainload.options = ["$default-options"] +[actions.chainload-shell] +chainload.path = "\\EFI\\BOOT\\shell.efi" + [generators.kernels.matrix] entry.title = "Boot Kernel $name" entry.values.path = "\\EFI\\BOOT\\$name" @@ -21,4 +24,4 @@ entry.actions = ["chainload-kernel"] values.name = ["kernel.efi"] [[phases.startup]] -actions = ["splash", "welcome"] +actions = ["welcome", "splash"] diff --git a/hack/configs/kernel.sprout.yaml b/hack/configs/kernel.sprout.yaml deleted file mode 100644 index 08a1160..0000000 --- a/hack/configs/kernel.sprout.yaml +++ /dev/null @@ -1,29 +0,0 @@ -version: 1 - -values: - default-options: "console=hvc0" - -phases: - startup: - - actions: ["welcome"] - -actions: - welcome: - print: - text: "Welcome to Sprout!" - chainload-kernel: - chainload: - path: "$path" - options: - - "$default-options" - -generators: - kernels: - matrix: - entry: - title: "Boot Kernel $name" - values: - path: "\\EFI\\BOOT\\$name" - actions: ["chainload-kernel"] - values: - name: ["kernel.efi"] diff --git a/vm/Dockerfile.initramfs b/vm/Dockerfile.initramfs new file mode 100644 index 0000000..fc1d188 --- /dev/null +++ b/vm/Dockerfile.initramfs @@ -0,0 +1,11 @@ +FROM alpine:3.22@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 AS build +RUN apk --no-cache add busybox-static +RUN mkdir -p /tmp/initramfs/bin && cp /bin/busybox.static /tmp/initramfs/bin/busybox && \ + chroot /tmp/initramfs /bin/busybox --install -s /bin && \ + chroot /tmp/initramfs ln -s /bin/sh /init && \ + cd /tmp/initramfs && \ + find . | cpio -R 0:0 --ignore-devno --renumber-inodes -o -H newc --quiet > /initramfs && \ + rm -rf /tmp/initramfs + +FROM scratch AS final +COPY --from=build /initramfs /initramfs