From b23b2f6e5db1a463769ff864aac994ff0eb83119 Mon Sep 17 00:00:00 2001 From: Ron Williams Date: Thu, 9 Mar 2023 21:17:13 -0800 Subject: [PATCH] fix mixed build in a new clone --- src/bin/installer.rs | 32 +++++++++++++++++++++++--------- src/lib.rs | 5 +++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/bin/installer.rs b/src/bin/installer.rs index f6b729d739..1ba226a922 100644 --- a/src/bin/installer.rs +++ b/src/bin/installer.rs @@ -18,7 +18,7 @@ fn main() { let mut parser = ArgParser::new(4) .add_opt("b", "cookbook") .add_opt("c", "config") - .add_flag(&["cooking"]) + .add_flag(&["p", "cooking"]) .add_flag(&["l", "list-packages"]) .add_flag(&["live"]); parser.parse(env::args()); @@ -96,18 +96,32 @@ fn main() { // Add cookbook key to config let key_path = Path::new(&path).join("build/id_ed25519.pub.toml"); match fs::read_to_string(&key_path) { - Ok(data) => config.files.push(redox_installer::FileConfig { - path: "pkg/id_ed25519.pub.toml".to_string(), - data: data, - ..Default::default() - }), + Ok(data) => { + config.files.push(redox_installer::FileConfig { + path: "pkg/id_ed25519.pub.toml".to_string(), + data: data, + ..Default::default() + }); + Some(path) + }, Err(err) => { - writeln!(stderr, "installer: {}: failed to read cookbook key: {}", key_path.display(), err).unwrap(); - process::exit(1); + // if there are no recipes coming from the cookbook, this is not a fatal error + if config.packages.clone().into_iter().any(| (_packagename, package) | + match package { + PackageConfig::Empty => false, + PackageConfig::Spec { version: None, git: None, path: None, } => false, + _ => true, + }) + { + writeln!(stderr, "installer: {}: failed to read cookbook key: {}", key_path.display(), err).unwrap(); + process::exit(1); + } else { + writeln!(stderr, "installer: {}: (non-fatal) missing cookbook key: {}", key_path.display(), err).unwrap(); + None + } } } - Some(path) } else { None }; diff --git a/src/lib.rs b/src/lib.rs index 2d86a933d7..44e214669f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,7 +334,7 @@ pub fn with_redoxfs(disk: D, password_opt: Option<&[u8]>, callback: F) res } -pub fn fetch_bootloaders>(cookbook: Option, live: bool) -> Result<(Vec, Vec)> { +pub fn fetch_bootloaders>(config: &Config, cookbook: Option, live: bool) -> Result<(Vec, Vec)> { //TODO: make it safe to run this concurrently let bootloader_dir = "/tmp/redox_installer_bootloader"; if Path::new(bootloader_dir).exists() { @@ -344,6 +344,7 @@ pub fn fetch_bootloaders>(cookbook: Option, live: bool) -> Resu fs::create_dir(bootloader_dir)?; let mut bootloader_config = Config::default(); + bootloader_config.general = config.general.clone(); bootloader_config.packages.insert("bootloader".to_string(), PackageConfig::default()); install_packages(&bootloader_config, bootloader_dir, cookbook.as_ref()); @@ -538,7 +539,7 @@ pub fn install(config: Config, output: P, cookbook: Option, live: bool) if output.as_ref().is_dir() { install_dir(config, output, cookbook) } else { - let (bootloader_bios, bootloader_efi) = fetch_bootloaders(cookbook.as_ref(), live)?; + let (bootloader_bios, bootloader_efi) = fetch_bootloaders(&config, cookbook.as_ref(), live)?; with_whole_disk(output, &bootloader_bios, &bootloader_efi, None, move |mount_path| { install_dir(config, mount_path, cookbook)