From fd2e9df3f18b4c8e8d93ff8b249217d8d50fdebd Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 1 Nov 2025 01:58:55 -0400 Subject: [PATCH] fix(autoconfigure): detect kernel and initramfs case-insensitive, even at the root --- hack/dev/boot/Dockerfile | 4 ++-- hack/dev/configs/all.sprout.toml | 4 ++-- hack/dev/configs/bls.conf | 2 +- hack/dev/configs/kernel.sprout.toml | 4 ++-- src/autoconfigure/linux.rs | 36 ++++++++++++++++++++++------- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/hack/dev/boot/Dockerfile b/hack/dev/boot/Dockerfile index 45010f5..5c77726 100644 --- a/hack/dev/boot/Dockerfile +++ b/hack/dev/boot/Dockerfile @@ -7,7 +7,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install - WORKDIR /work COPY sprout.efi /work/${EFI_NAME}.EFI COPY sprout.toml /work/SPROUT.TOML -COPY kernel.efi /work/KERNEL.EFI +COPY kernel.efi /work/VMLINUZ COPY shell.efi /work/SHELL.EFI COPY xen.efi /work/XEN.EFI COPY xen.cfg /work/XEN.CFG @@ -24,7 +24,7 @@ RUN truncate -s128MiB sprout.img && \ mmd -i sprout.img ::/LOADER && \ mmd -i sprout.img ::/LOADER/ENTRIES && \ mcopy -i sprout.img ${EFI_NAME}.EFI ::/EFI/BOOT/ && \ - mcopy -i sprout.img KERNEL.EFI ::/EFI/BOOT/ && \ + mcopy -i sprout.img VMLINUZ ::/VMLINUZ && \ mcopy -i sprout.img SHELL.EFI ::/EFI/BOOT/ && \ mcopy -i sprout.img XEN.EFI ::/EFI/BOOT/ && \ mcopy -i sprout.img XEN.CFG ::/EFI/BOOT/ && \ diff --git a/hack/dev/configs/all.sprout.toml b/hack/dev/configs/all.sprout.toml index 0bcdb00..6f9d2e9 100644 --- a/hack/dev/configs/all.sprout.toml +++ b/hack/dev/configs/all.sprout.toml @@ -4,10 +4,10 @@ version = 1 default-entry = "kernel" [extractors.boot.filesystem-device-match] -has-item = "\\EFI\\BOOT\\kernel.efi" +has-item = "\\vmlinuz" [actions.chainload-kernel] -chainload.path = "$boot\\EFI\\BOOT\\kernel.efi" +chainload.path = "$boot\\vmlinuz" chainload.options = ["console=hvc0"] chainload.linux-initrd = "$boot\\initramfs" diff --git a/hack/dev/configs/bls.conf b/hack/dev/configs/bls.conf index ff0017e..86c3d0f 100644 --- a/hack/dev/configs/bls.conf +++ b/hack/dev/configs/bls.conf @@ -1,4 +1,4 @@ title Boot Linux -linux /efi/boot/kernel.efi +linux /vmlinuz options console=hvc0 initrd /initramfs diff --git a/hack/dev/configs/kernel.sprout.toml b/hack/dev/configs/kernel.sprout.toml index c9983a4..162fd2b 100644 --- a/hack/dev/configs/kernel.sprout.toml +++ b/hack/dev/configs/kernel.sprout.toml @@ -5,10 +5,10 @@ default-entry = "kernel" menu-timeout = 0 [extractors.boot.filesystem-device-match] -has-item = "\\EFI\\BOOT\\kernel.efi" +has-item = "\\vmlinuz" [actions.chainload-kernel] -chainload.path = "$boot\\EFI\\BOOT\\kernel.efi" +chainload.path = "$boot\\vmlinuz" chainload.options = ["console=hvc0"] chainload.linux-initrd = "$boot\\initramfs" diff --git a/src/autoconfigure/linux.rs b/src/autoconfigure/linux.rs index 9fa2c44..4bd4fd0 100644 --- a/src/autoconfigure/linux.rs +++ b/src/autoconfigure/linux.rs @@ -6,9 +6,10 @@ use crate::generators::GeneratorDeclaration; use crate::generators::list::ListConfiguration; use crate::utils; use anyhow::{Context, Result}; +use log::info; use std::collections::BTreeMap; use uefi::CString16; -use uefi::fs::{FileSystem, Path}; +use uefi::fs::{FileSystem, Path, PathBuf}; use uefi::proto::device_path::DevicePath; use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly}; @@ -17,7 +18,8 @@ const LINUX_CHAINLOAD_ACTION_PREFIX: &str = "linux-chainload-"; /// The locations to scan for kernel pairs. /// We will check for symlinks and if this directory is a symlink, we will skip it. -const SCAN_LOCATIONS: &[&str] = &["/boot", "/"]; +/// The empty string represents the root of the filesystem. +const SCAN_LOCATIONS: &[&str] = &["\\boot", "\\"]; /// Prefixes of kernel files to scan for. const KERNEL_PREFIXES: &[&str] = &["vmlinuz"]; @@ -39,6 +41,9 @@ fn scan_directory(filesystem: &mut FileSystem, path: &str) -> Result Result Result Result Result