Trim deps, remove legacy bins, fix clean without container

This commit is contained in:
Wildan M 2025-11-22 16:02:38 -08:00
parent d982644a73
commit bb57b364bb
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
7 changed files with 49 additions and 2400 deletions

2202
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -40,9 +40,9 @@ pbr = "1.0.2"
pkgar = { git = "https://gitlab.redox-os.org/redox-os/pkgar.git" }
pkgar-core = { git = "https://gitlab.redox-os.org/redox-os/pkgar.git" }
pkgar-keys = { git = "https://gitlab.redox-os.org/redox-os/pkgar.git" }
redox-pkg = { git = "https://gitlab.redox-os.org/redox-os/pkgutils.git" }
redox_installer = "0.2.37"
redoxer = { git = "https://gitlab.redox-os.org/redox-os/redoxer.git" }
redox-pkg = { git = "https://gitlab.redox-os.org/redox-os/pkgutils.git", default-features = false }
redox_installer = { git = "https://gitlab.redox-os.org/redox-os/installer.git", default-features = false }
redoxer = { git = "https://gitlab.redox-os.org/redox-os/redoxer.git", default-features = false }
regex = "1.11"
serde = { version = "=1.0.197", features = ["derive"] }
termion = "4"
@ -57,6 +57,3 @@ version = "0.29.0"
default-features = false
features = ["termion"]
optional = true
[dev-dependencies]
tempfile = "3"

View File

@ -37,8 +37,8 @@ ifeq ($(PODMAN_BUILD),1)
ifneq ("$(wildcard $(CONTAINER_TAG))","")
$(PODMAN_RUN) make $@
else
$(info will not run cookbook clean as container is not built)
$(MAKE) clean PODMAN_BUILD=0 NOT_ON_PODMAN=1
$(info will not run cookbook clean as container is not built)
$(MAKE) clean PODMAN_BUILD=0 NOT_ON_PODMAN=1 SKIP_CHECK_TOOLS=1
endif # CONTAINER_TAG
else
ifneq ($(NOT_ON_PODMAN),1)
@ -47,7 +47,6 @@ ifneq ($(NOT_ON_PODMAN),1)
-$(FUMOUNT) /tmp/redox_installer/ || true
endif # NOT_ON_PODMAN
rm -rf repo
rm -rf relibc/target
rm -rf $(BUILD) $(PREFIX)
$(MAKE) fstools_clean
endif # PODMAN_BUILD
@ -57,8 +56,8 @@ ifeq ($(PODMAN_BUILD),1)
ifneq ("$(wildcard $(CONTAINER_TAG))","")
$(PODMAN_RUN) make $@
else
$(info will not run cookbook unfetch as container is not built)
$(MAKE) distclean PODMAN_BUILD=0 NOT_ON_PODMAN=1
$(info will not run cookbook unfetch as container is not built)
$(MAKE) distclean PODMAN_BUILD=0 NOT_ON_PODMAN=1 SKIP_CHECK_TOOLS=1
endif # CONTAINER_TAG
else
ifneq ($(NOT_ON_PODMAN),1)

View File

@ -1,165 +0,0 @@
use std::path::Path;
use std::{env, process};
use cookbook::cook::fetch::{fetch, fetch_offline};
use cookbook::cook::fs::create_target_dir;
use cookbook::cook::package::package;
use cookbook::recipe::{CookRecipe, Recipe};
use pkg::PackageName;
use cookbook::config::init_config;
use cookbook::cook::cook_build::build;
use termion::{color, style};
fn cook(
recipe_dir: &Path,
name: &PackageName,
recipe: &Recipe,
is_deps: bool,
fetch_only: bool,
is_offline: bool,
) -> Result<(), String> {
let source_dir = match is_offline {
true => fetch_offline(recipe_dir, recipe, &None),
false => fetch(recipe_dir, recipe, &None),
}
.map_err(|err| format!("failed to fetch: {}", err))?;
if fetch_only {
return Ok(());
}
let target_dir = create_target_dir(recipe_dir)?;
let (stage_dir, auto_deps) = build(
recipe_dir,
&source_dir,
&target_dir,
name,
recipe,
is_offline,
!is_deps,
&None,
)
.map_err(|err| format!("failed to build: {}", err))?;
package(&stage_dir, &target_dir, name, recipe, &auto_deps, &None)
.map_err(|err| format!("failed to package: {}", err))?;
Ok(())
}
fn main() {
init_config();
let mut matching = true;
let mut dry_run = false;
let mut fetch_only = false;
let mut with_package_deps = false;
let mut quiet = false;
let mut nonstop = false;
let mut is_offline = false;
let mut recipe_names = Vec::new();
for arg in env::args().skip(1) {
match arg.as_str() {
"--" if matching => matching = false,
"-d" | "--dry-run" if matching => dry_run = true,
"--with-package-deps" if matching => with_package_deps = true,
"--fetch-only" if matching => fetch_only = true,
"-q" | "--quiet" if matching => quiet = true,
"--nonstop" => nonstop = true,
"--offline" => is_offline = true,
_ => recipe_names.push(arg.try_into().expect("Invalid package name")),
}
}
if with_package_deps {
recipe_names = match CookRecipe::get_package_deps_recursive(&recipe_names, true) {
Ok(ok) => ok,
Err(err) => {
eprintln!(
"{}{}cook - error:{}{} {}",
style::Bold,
color::Fg(color::AnsiValue(196)),
color::Fg(color::Reset),
style::Reset,
err,
);
process::exit(1);
}
};
}
let recipes =
match CookRecipe::get_build_deps_recursive(&recipe_names, true, !with_package_deps) {
Ok(ok) => ok,
Err(err) => {
eprintln!(
"{}{}cook - error:{}{} {}",
style::Bold,
color::Fg(color::AnsiValue(196)),
color::Fg(color::Reset),
style::Reset,
err,
);
process::exit(1);
}
};
for recipe in recipes {
if !quiet {
eprintln!(
"{}{}cook - {}{}{}",
style::Bold,
color::Fg(color::AnsiValue(215)),
recipe.name,
color::Fg(color::Reset),
style::Reset,
);
}
let res = if dry_run {
if !quiet {
eprintln!("DRY RUN: {:#?}", recipe.recipe);
}
Ok(())
} else {
cook(
&recipe.dir,
&recipe.name,
&recipe.recipe,
recipe.is_deps,
fetch_only,
is_offline,
)
};
match res {
Ok(()) => {
if !quiet {
eprintln!(
"{}{}cook - {} - successful{}{}",
style::Bold,
color::Fg(color::AnsiValue(46)),
recipe.name,
color::Fg(color::Reset),
style::Reset,
);
}
}
Err(err) => {
eprintln!(
"{}{}cook - {} - error:{}{} {}",
style::Bold,
color::Fg(color::AnsiValue(196)),
recipe.name,
color::Fg(color::Reset),
style::Reset,
err,
);
if !nonstop {
process::exit(1);
}
}
}
}
}

View File

@ -1,25 +0,0 @@
use std::env::args;
use std::process::exit;
use pkg::recipes;
fn usage() {
println!("Usage: find_recipe recipe_name");
}
fn main() {
if args().len() != 2 {
usage();
exit(2);
}
let recipe_name = &args().last().unwrap();
match recipes::find(recipe_name) {
Some(path) => {
println!("{}", path.display());
exit(0);
}
None => {
eprintln!("recipe {} not found", recipe_name);
exit(1);
}
}
}

View File

@ -1,28 +0,0 @@
use std::process::exit;
use pkg::recipes;
fn main() {
let print_short = std::env::args()
.nth(1)
.map_or(false, |a| a == "-s" || a == "--short");
let result = recipes::list("");
if result.is_empty() {
eprintln!("recipes not found");
exit(1);
} else {
for path in result {
let Some(file_name) = path.file_name() else {
continue;
};
if print_short {
println!("{}", file_name.to_string_lossy());
} else {
println!("{}", path.to_string_lossy());
}
}
exit(0);
}
}

View File

@ -469,11 +469,14 @@ mod tests {
#[test]
fn file_system_loop_no_infinite_loop() {
let mut root = std::env::temp_dir();
root.push("temp_test_dir_file_system_loop_no_infinite_loop");
let _ = std::fs::remove_dir_all(&root);
std::fs::create_dir_all(&root).expect("Failed to create temporary root directory");
// Hierarchy with an infinite loop
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
let dir = root.join("loop");
unix::fs::symlink(root, &dir).expect("Linking {dir:?} to {root:?}");
unix::fs::symlink(&root, &dir).expect("Linking {dir:?} to {root:?}");
// Sanity check that we have a loop
assert_eq!(
@ -482,7 +485,7 @@ mod tests {
"Expected a loop where {dir:?} points to {root:?}"
);
let entries = auto_deps_from_dynamic_linking(root, &Default::default(), &None);
let entries = auto_deps_from_dynamic_linking(&root, &Default::default(), &None);
assert!(
entries.is_empty(),
"auto_deps shouldn't have yielded any libraries"