diff --git a/src/bin/installer.rs b/src/bin/installer.rs index f6b729d739b2a1adac2ba5e8edd10fa13869b32a..1ba226a922a53915dfd3bb91ab23a96112aa03d7 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 2d86a933d7ce55f6ffefa2a09181d50029095610..44e214669f1f6b4f4043dd88304e3c2ded74d23f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,7 +334,7 @@ pub fn with_redoxfs<D, T, F>(disk: D, password_opt: Option<&[u8]>, callback: F) res } -pub fn fetch_bootloaders<S: AsRef<str>>(cookbook: Option<S>, live: bool) -> Result<(Vec<u8>, Vec<u8>)> { +pub fn fetch_bootloaders<S: AsRef<str>>(config: &Config, cookbook: Option<S>, live: bool) -> Result<(Vec<u8>, Vec<u8>)> { //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<S: AsRef<str>>(cookbook: Option<S>, 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<P, S>(config: Config, output: P, cookbook: Option<S>, 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)