fix(bls): swap from intaking \\loader\\entries to just \\loader

This prepares for further BLS integration.
This commit is contained in:
2025-10-27 00:31:07 -04:00
parent 094128de58
commit e47c813536
3 changed files with 30 additions and 16 deletions

View File

@@ -135,10 +135,10 @@ version = 1
path = "\\sprout\\drivers\\ext4.efi" path = "\\sprout\\drivers\\ext4.efi"
# extract the full path of the first filesystem # extract the full path of the first filesystem
# that contains \loader\entries as a directory # that contains \loader as a directory
# into the value called "boot" # into the value called "boot"
[extractors.boot.filesystem-device-match] [extractors.boot.filesystem-device-match]
has-item = "\\loader\\entries" has-item = "\\loader"
# use the sprout bls module to scan a bls # use the sprout bls module to scan a bls
# directory for entries and load them as boot # directory for entries and load them as boot
@@ -146,7 +146,7 @@ has-item = "\\loader\\entries"
# as specified here. the bls action below will # as specified here. the bls action below will
# be passed the extracted values from bls. # be passed the extracted values from bls.
[generators.boot.bls] [generators.boot.bls]
path = "$boot\\loader\\entries" path = "$boot\\loader"
entry.title = "$title" entry.title = "$title"
entry.actions = ["bls"] entry.actions = ["bls"]

View File

@@ -40,10 +40,10 @@ version = 1
path = "\\sprout\\drivers\\ext4.efi" path = "\\sprout\\drivers\\ext4.efi"
# extract the full path of the first filesystem # extract the full path of the first filesystem
# that contains \loader\entries as a directory # that contains \loader as a directory
# into the value called "boot" # into the value called "boot"
[extractors.boot.filesystem-device-match] [extractors.boot.filesystem-device-match]
has-item = "\\loader\\entries" has-item = "\\loader"
# use the sprout bls module to scan a bls # use the sprout bls module to scan a bls
# directory for entries and load them as boot # directory for entries and load them as boot
@@ -51,7 +51,7 @@ has-item = "\\loader\\entries"
# as specified here. the bls action below will # as specified here. the bls action below will
# be passed the extracted values from bls. # be passed the extracted values from bls.
[generators.boot.bls] [generators.boot.bls]
path = "$boot\\loader\\entries" path = "$boot\\loader"
entry.title = "$title" entry.title = "$title"
entry.actions = ["bls"] entry.actions = ["bls"]

View File

@@ -6,15 +6,16 @@ use anyhow::{Context, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::rc::Rc; use std::rc::Rc;
use std::str::FromStr; use std::str::FromStr;
use uefi::fs::{FileSystem, Path}; use uefi::fs::{FileSystem, Path, PathBuf};
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly}; use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
use uefi::proto::media::fs::SimpleFileSystem; use uefi::proto::media::fs::SimpleFileSystem;
use uefi::{CString16, cstr16};
/// BLS entry parser. /// BLS entry parser.
mod entry; mod entry;
/// The default path to the BLS entries directory. /// The default path to the BLS directory.
const BLS_TEMPLATE_PATH: &str = "\\loader\\entries"; const BLS_TEMPLATE_PATH: &str = "\\loader";
/// The configuration of the BLS generator. /// The configuration of the BLS generator.
/// The BLS uses the Bootloader Specification to produce /// The BLS uses the Bootloader Specification to produce
@@ -23,7 +24,7 @@ const BLS_TEMPLATE_PATH: &str = "\\loader\\entries";
pub struct BlsConfiguration { pub struct BlsConfiguration {
/// The entry to use for as a template. /// The entry to use for as a template.
pub entry: EntryDeclaration, pub entry: EntryDeclaration,
/// The path to the BLS entries directory. /// The path to the BLS directory.
#[serde(default = "default_bls_path")] #[serde(default = "default_bls_path")]
pub path: String, pub path: String,
} }
@@ -44,20 +45,33 @@ fn quirk_initrd_remove_tuned(input: String) -> String {
pub fn generate(context: Rc<SproutContext>, bls: &BlsConfiguration) -> Result<Vec<BootableEntry>> { pub fn generate(context: Rc<SproutContext>, bls: &BlsConfiguration) -> Result<Vec<BootableEntry>> {
let mut entries = Vec::new(); let mut entries = Vec::new();
// Stamp the path to the BLS entries directory. // Stamp the path to the BLS directory.
let path = context.stamp(&bls.path); let path = context.stamp(&bls.path);
// Convert the path to a UEFI PathBuf.
let path = PathBuf::from(
CString16::try_from(path.as_str()).context("unable to convert bls path to CString16")?,
);
// Construct the path to the BLS entries directory.
let mut entries_path = path.clone();
entries_path.push(cstr16!("entries"));
// Resolve the path to the BLS entries directory. // Resolve the path to the BLS entries directory.
let resolved = utils::resolve_path(context.root().loaded_image_path()?, &path) let entries_resolved = utils::resolve_path(
.context("unable to resolve bls path")?; context.root().loaded_image_path()?,
&path.to_cstr16().to_string(),
)
.context("unable to resolve bls path")?;
// Open exclusive access to the BLS filesystem. // Open exclusive access to the BLS filesystem.
let fs = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(resolved.filesystem_handle) let fs =
.context("unable to open bls filesystem")?; uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(entries_resolved.filesystem_handle)
.context("unable to open bls filesystem")?;
let mut fs = FileSystem::new(fs); let mut fs = FileSystem::new(fs);
// Convert the subpath to the BLS entries directory to a string. // Convert the subpath to the BLS entries directory to a string.
let sub_text_path = resolved let sub_text_path = entries_resolved
.sub_path .sub_path
.to_string(DisplayOnly(false), AllowShortcuts(false)) .to_string(DisplayOnly(false), AllowShortcuts(false))
.context("unable to convert subpath to string")?; .context("unable to convert subpath to string")?;