diff --git a/Cargo.toml b/Cargo.toml index 003cb7f5d0..cc35de4cc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,6 @@ path = "src/bin/installer.rs" name = "redox_installer_tui" path = "src/bin/installer_tui.rs" -[[bin]] -name = "list_packages" -path = "src/bin/list_packages.rs" - [lib] name = "redox_installer" path = "src/lib.rs" diff --git a/src/bin/installer.rs b/src/bin/installer.rs index 5d8a7bef31..bf14f10303 100644 --- a/src/bin/installer.rs +++ b/src/bin/installer.rs @@ -3,18 +3,14 @@ extern crate redox_installer; extern crate serde; extern crate toml; -use std::io::Write; use std::path::Path; -use std::{env, fs, io, process}; +use std::{env, fs, process}; use arg_parser::ArgParser; use redox_installer::{Config, PackageConfig}; fn main() { - let stderr = io::stderr(); - let mut stderr = stderr.lock(); - let mut parser = ArgParser::new(4) .add_opt("b", "cookbook") .add_opt("c", "config") @@ -34,7 +30,7 @@ fn main() { match Config::from_file(Path::new(&path)) { Ok(config) => config, Err(err) => { - writeln!(stderr, "installer: {err}").unwrap(); + eprintln!("installer: {err}"); process::exit(1); } } @@ -69,26 +65,18 @@ fn main() { // List the packages that should be fetched or built by the cookbook for (packagename, package) in &config.packages { match package { - PackageConfig::Build(rule) if rule == "recipe" || rule == "source" => { - println!("{}", packagename); - } - PackageConfig::Build(rule) if rule == "binary" || rule == "ignore" => { + PackageConfig::Build(rule) if rule == "ignore" => { // skip this package } _ => { - if config.general.repo_binary == Some(true) { - // default action is to not build this package, skip it - } else { - // default action is to build - println!("{}", packagename); - } + println!("{}", packagename); } } } } else { let cookbook = if let Some(path) = parser.get_opt("cookbook") { if !Path::new(&path).is_dir() { - writeln!(stderr, "installer: {}: cookbook not found", path).unwrap(); + eprintln!("installer: {}: cookbook not found", path); process::exit(1); } @@ -119,22 +107,18 @@ fn main() { _ => true, }) { - writeln!( - stderr, + eprintln!( "installer: {}: failed to read cookbook key: {}", key_path.display(), err - ) - .unwrap(); + ); process::exit(1); } else { - writeln!( - stderr, + eprintln!( "installer: {}: (non-fatal) missing cookbook key: {}", key_path.display(), err - ) - .unwrap(); + ); None } } @@ -151,11 +135,11 @@ fn main() { parser.found("live"), parser.get_opt("write-bootloader").as_deref(), ) { - writeln!(stderr, "installer: failed to install: {}", err).unwrap(); + eprintln!("installer: failed to install: {}", err); process::exit(1); } } else { - writeln!(stderr, "installer: output or list-packages not found").unwrap(); + eprintln!("installer: output or list-packages not found"); process::exit(1); } } diff --git a/src/bin/installer_tui.rs b/src/bin/installer_tui.rs index 851637febe..af36648546 100644 --- a/src/bin/installer_tui.rs +++ b/src/bin/installer_tui.rs @@ -353,7 +353,7 @@ fn main() { eprintln!("configuring system"); let cookbook: Option<&'static str> = None; redox_installer::install_dir(config, mount_path, cookbook) - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + .map_err(|err| io::Error::other(err))?; // Sort and remove duplicates files.sort(); diff --git a/src/bin/list_packages.rs b/src/bin/list_packages.rs deleted file mode 100644 index abb4a59b86..0000000000 --- a/src/bin/list_packages.rs +++ /dev/null @@ -1,74 +0,0 @@ -/// List packages for compilation, skip binary packages to be downloaded -extern crate arg_parser; -extern crate redox_installer; -extern crate serde; -extern crate toml; - -use std::io::Write; -use std::path::Path; -use std::{env, io, process}; - -use arg_parser::ArgParser; - -use redox_installer::{Config, PackageConfig}; - -fn main() { - let stderr = io::stderr(); - let mut stderr = stderr.lock(); - - let mut parser = ArgParser::new(4) - .add_opt("c", "config") - .add_flag(&["r", "repo-binary"]); - parser.parse(env::args()); - - // Use pre-built binaries for packages as the default. - // If not set on the command line or the filesystem config, then build packages from source. - let repo_binary = parser.found("repo-binary"); - - let mut config = if let Some(path) = parser.get_opt("config") { - match Config::from_file(Path::new(&path)) { - Ok(config) => config, - Err(err) => { - writeln!(stderr, "installer: {err}").unwrap(); - process::exit(1); - } - } - } else { - redox_installer::Config::default() - }; - - // Get toml of merged config - let merged_toml = toml::to_string_pretty(&config).unwrap(); - - // Add filesystem.toml to config - config.files.push(redox_installer::FileConfig { - path: "filesystem.toml".to_string(), - data: merged_toml, - ..Default::default() - }); - - // Add command line flags to config, command line takes priority - if repo_binary { - config.general.repo_binary = Some(true); - } - - // List the packages that should be fetched or built by the cookbook - for (packagename, package) in &config.packages { - match package { - PackageConfig::Build(rule) if rule == "recipe" || rule == "source" => { - println!("{}", packagename); - } - PackageConfig::Build(rule) if rule == "binary" || rule == "ignore" => { - // skip this package - } - _ => { - if config.general.repo_binary == Some(true) { - // default action is to not build this package, skip it - } else { - // default action is to build - println!("{}", packagename); - } - } - } - } -} diff --git a/src/lib.rs b/src/lib.rs index 5c3019cbd8..5aaec029a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,9 @@ pub use crate::config::package::PackageConfig; pub use crate::config::Config; use crate::disk_wrapper::DiskWrapper; -use anyhow::{anyhow, bail, Context, Result}; +#[cfg(target_os = "redox")] +use anyhow::anyhow; +use anyhow::{bail, Result}; use pkg::Library; use rand::{rngs::OsRng, TryRngCore}; use redoxfs::{unmount_path, Disk, DiskIo, FileSystem};