Merge branch 'tidy-up' into 'master'

Remove list_packages

See merge request redox-os/installer!58
This commit is contained in:
Jeremy Soller
2025-11-20 06:46:28 -07:00
5 changed files with 15 additions and 107 deletions
-4
View File
@@ -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"
+11 -27
View File
@@ -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);
}
}
+1 -1
View File
@@ -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();
-74
View File
@@ -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);
}
}
}
}
}
+3 -1
View File
@@ -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};