mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 16:42:20 +00:00
feat(boot): add the bls-strict-mode option
Add --bls-strict-mode and bls-strict-mode in the options of sprout.toml. It does nothing yet; the behaviors it controls follow.
This commit is contained in:
1 parent
bfca43fe07
commit
7e1207097b
3 files changed
+30
No files matched your search
@@ -199,6 +199,13 @@ fn run(reboot_on_error: &mut bool) -> Result<()> {
|
||||
.context("unable to set loader path in bootloader interface"),
|
||||
);
|
||||
|
||||
// Strict mode can be asked for on the command line or in the configuration.
|
||||
let mut options = options;
|
||||
options.bls_strict_mode |= config.options.bls_strict_mode;
|
||||
if options.bls_strict_mode {
|
||||
info!("BLS strict mode is enabled");
|
||||
}
|
||||
|
||||
// Create the root context.
|
||||
let mut root = RootContext::new(loaded_image_path, timer, options);
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ pub struct SproutOptions {
|
||||
pub menu_style: Option<MenuStyle>,
|
||||
/// Retains the boot console before boot.
|
||||
pub retain_boot_console: bool,
|
||||
/// Makes Sprout follow the Boot Loader Specification and systemd-boot exactly.
|
||||
pub bls_strict_mode: bool,
|
||||
}
|
||||
|
||||
/// The default Sprout options.
|
||||
@@ -42,6 +44,7 @@ impl Default for SproutOptions {
|
||||
menu_timeout: None,
|
||||
menu_style: None,
|
||||
retain_boot_console: false,
|
||||
bls_strict_mode: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +63,7 @@ impl SproutOptions {
|
||||
MenuTimeout,
|
||||
MenuStyle,
|
||||
RetainBootConsole,
|
||||
BlsStrictMode,
|
||||
}
|
||||
|
||||
// All the options for the Sprout executable.
|
||||
@@ -78,6 +82,8 @@ impl SproutOptions {
|
||||
.help_text("Boot menu style, basic, simple or graphical"),
|
||||
Opt::flag(ArgID::RetainBootConsole, &["--retain-boot-console"])
|
||||
.help_text("Retain boot console before boot"),
|
||||
Opt::flag(ArgID::BlsStrictMode, &["--bls-strict-mode"])
|
||||
.help_text("Follow the BLS specification and systemd-boot exactly"),
|
||||
]);
|
||||
|
||||
// Acquire the arguments as determined by the UEFI core.
|
||||
@@ -141,6 +147,10 @@ impl SproutOptions {
|
||||
// Retain the boot console before booting.
|
||||
result.retain_boot_console = true;
|
||||
}
|
||||
ArgID::BlsStrictMode => {
|
||||
// Follow the BLS specification and systemd-boot exactly.
|
||||
result.bls_strict_mode = true;
|
||||
}
|
||||
ArgID::Help => {
|
||||
let ctx = HelpWriterContext {
|
||||
options: &OPTIONS,
|
||||
|
||||
@@ -91,6 +91,12 @@ pub struct OptionsConfiguration {
|
||||
/// Enables autoconfiguration of Sprout based on the environment.
|
||||
#[serde(default)]
|
||||
pub autoconfigure: bool,
|
||||
/// Makes Sprout follow the Boot Loader Specification and systemd-boot exactly where it
|
||||
/// otherwise differs for convenience or safety. For example, the extended boot loader
|
||||
/// partition is always read, a one-shot entry only sets the default entry, and entries with
|
||||
/// missing files are hidden. See the README for everything it changes.
|
||||
#[serde(rename = "bls-strict-mode", default)]
|
||||
pub bls_strict_mode: bool,
|
||||
}
|
||||
|
||||
/// The default configuration, which matches an empty configuration file.
|
||||
@@ -118,6 +124,7 @@ impl Default for OptionsConfiguration {
|
||||
menu_timeout: None,
|
||||
menu_style: Default::default(),
|
||||
autoconfigure: false,
|
||||
bls_strict_mode: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,6 +171,12 @@ mod tests {
|
||||
assert_eq!(default.options.autoconfigure, empty.options.autoconfigure);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bls_strict_mode_is_off_by_default() {
|
||||
assert!(!RootConfiguration::default().options.bls_strict_mode);
|
||||
assert!(!empty().options.bls_strict_mode);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn menu_timeout_is_unset_by_default() {
|
||||
assert_eq!(RootConfiguration::default().options.menu_timeout, None);
|
||||
|
||||
Reference in new issue
Block a user