diff --git a/src/cook/package.rs b/src/cook/package.rs index 13781621e..9bc86c6c2 100644 --- a/src/cook/package.rs +++ b/src/cook/package.rs @@ -8,6 +8,7 @@ use pkgar::ext::PackageSrcExt; use pkgar_core::HeaderFlags; use crate::{ + Error, config::CookConfig, cook::{cook_build::BuildResult, fetch, fs::*, pty::PtyOut}, log_to_pty, @@ -29,6 +30,7 @@ pub fn package( target_dir.join("stage.toml"), recipe, None, + None, recipe.recipe.package.dependencies.clone(), &auto_deps, )?; @@ -109,6 +111,7 @@ pub fn package( package_meta, recipe, Some((Path::new(public_path), &package_file)), + package, package_deps, &deps, )?; @@ -122,6 +125,7 @@ pub fn package_toml( toml_path: PathBuf, recipe: &CookRecipe, package_file: Option<(&Path, &PathBuf)>, + package_suffix: Option<&OptionalPackageRecipe>, mut package_deps: Vec, auto_deps: &BTreeSet, ) -> Result<(), String> { @@ -149,9 +153,13 @@ pub fn package_toml( ) })?; let package_size = mt.len(); - let storage_size = match package.header().flags.packaging() { + let header = package.header(); + let storage_size = match header.flags.packaging() { pkgar_core::Packaging::LZMA2 => { - let mut size = 0; + let mut size = header + .total_size() + .map_err(|e| Error::Pkgar(pkgar::Error::Core(e)))? + as u64; let entries = package .read_entries() .map_err(|e| format!("Unable to get lzma entry: {e}"))?; @@ -183,7 +191,11 @@ pub fn package_toml( let ident_source = fetch::fetch_get_source_info(recipe)?; let package = Package { - name: recipe.name.with_prefix(PackagePrefix::Any), + name: PackageName::new(get_package_name( + recipe.name.without_prefix(), + package_suffix, + )) + .unwrap(), version: recipe.guess_version().unwrap_or("TODO".into()), target: recipe.target.to_string(), blake3: hash, diff --git a/src/cook/tree.rs b/src/cook/tree.rs index a37fb29a2..e811c5083 100644 --- a/src/cook/tree.rs +++ b/src/cook/tree.rs @@ -149,7 +149,8 @@ pub fn walk_file_tree(dir: &PathBuf, prefix: &str, buffer: &mut String) -> std:: return Ok(0); } let fmt_err = std::io::Error::other; - let entries: Vec<_> = std::fs::read_dir(dir)?.filter_map(|e| e.ok()).collect(); + let mut entries: Vec<_> = std::fs::read_dir(dir)?.filter_map(|e| e.ok()).collect(); + entries.sort_by(|a, b| a.file_name().cmp(&b.file_name())); let mut total_size = 0; for (index, entry) in entries.iter().enumerate() { let path = entry.path(); diff --git a/src/recipe.rs b/src/recipe.rs index 299b15ef2..6f20632f3 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -214,7 +214,7 @@ impl CookRecipe { pub fn new(name: PackageName, dir: PathBuf, mut recipe: Recipe) -> Result { let target = cook_package::package_target(&name); if name.is_host() { - let thisname = name.name(); + let thisname = name.without_host(); let fn_map = |p: PackageName| { if p.is_host() { if p.name() == thisname { None } else { Some(p) } diff --git a/src/staged_pkg.rs b/src/staged_pkg.rs index c406ec190..d7abbce01 100644 --- a/src/staged_pkg.rs +++ b/src/staged_pkg.rs @@ -95,8 +95,8 @@ pub fn new_recursive( } } -// list ordered success packages and map of failed packages -// a package can be both success and failed if dependencies aren't satistied +/// List ordered success packages and map of failed packages. +/// A package can be both success and failed if dependencies aren't satistied. pub fn new_recursive_nonstop( names: &[PackageName], recursion: usize, @@ -137,7 +137,7 @@ pub fn new_recursive_nonstop( has_invalid_dependency = true; } } - // TODO: this if check is redundant + // TODO: this check is redundant if !packages_map.contains_key(name) { packages_map.insert( name.clone(), diff --git a/src/web.rs b/src/web.rs index 3c5765054..e669bc8ad 100644 --- a/src/web.rs +++ b/src/web.rs @@ -66,11 +66,11 @@ pub fn generate_web(all_packages: &Vec, config: &CliWebConfig) { let Some(recipe_path) = staged_pkg::find(package_name.name()) else { continue; }; - let Ok(package) = staged_pkg::from_path(&recipe_path, package_name.suffix()) else { + let Ok(mut package) = staged_pkg::from_path(&recipe_path, package_name.suffix()) else { // TODO: report failed build continue; }; - let Ok(recipe) = CookRecipe::from_path(&recipe_path, true, false) else { + let Ok(mut recipe) = CookRecipe::from_path(&recipe_path, true, false) else { continue; }; @@ -81,6 +81,11 @@ pub fn generate_web(all_packages: &Vec, config: &CliWebConfig) { .insert(package.name.to_string()); } + // TODO: temporary bug fix in the suffix lost + package.name = package_name.clone(); + // CookRecipe::from_path always have no suffix + recipe.name = package_name; + valid_packages.push((package, recipe)); } diff --git a/src/web/html.rs b/src/web/html.rs index 1f4d405eb..e7905fe23 100644 --- a/src/web/html.rs +++ b/src/web/html.rs @@ -108,7 +108,7 @@ pub fn generate_html_pkg( &config.this_repo, host, &package.commit_identifier, - Some(&format!("recipes/{category}/{name}/recipe.toml")), + Some(&format!("recipes/{category}/{}/recipe.toml", name.name())), ); let short_commit = get_short_commit(&package.commit_identifier); source_html += &format!(