From 21356e4be68adc73ed212944c9d5aad01fefd4a7 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Thu, 7 May 2026 13:50:28 +0700 Subject: [PATCH] Fix pushing metapackages --- src/cook/package.rs | 50 +++++++++++++++++---------------------------- src/cook/tree.rs | 12 +++++++---- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/cook/package.rs b/src/cook/package.rs index d94c20b4..29ff9ca8 100644 --- a/src/cook/package.rs +++ b/src/cook/package.rs @@ -251,38 +251,26 @@ pub fn package_handle_push( let archive_toml = archive_path.with_extension("toml"); let pkey_path = "build/id_ed25519.pub.toml"; let pkg_toml = Package::from_file(&archive_toml)?; - match state.installed.get(&pkg_toml.name) { - Some(s) if !reinstall && pkg_toml.blake3 == s.blake3 => Ok(true), - Some(s) => { - // "local" is what remote name from installer is hardcoded into - let remote_name = "local".to_string(); - - let install_state = - InstallState::from_package(&pkg_toml, remote_name, s.manual, s.dependents.clone()); - - // TODO: use pkgar::replace unless forced reinstall - pkgar::extract(pkey_path, &archive_path, sysroot_dir)?; - - state.installed.insert(pkg_toml.name.clone(), install_state); - - Ok(false) - } + // "local" is what remote name from installer is hardcoded into + let remote_name = "local".to_string(); + let (cached, pstate) = match state.installed.get(&pkg_toml.name) { + Some(s) if !reinstall && pkg_toml.blake3 == s.blake3 => (true, None), + Some(s) => (false, Some((s.manual, s.dependents.clone()))), None => { - // "local" is what remote name from installer is hardcoded into - let remote_name = "local".to_string(); - - // TODO: Handle manual & depedents - let install_state = - InstallState::from_package(&pkg_toml, remote_name, true, BTreeSet::new()); - - pkgar::extract(pkey_path, &archive_path, sysroot_dir)?; - - // TODO: Inject dependencies - // TODO: Check if we need to inject remote key - - state.installed.insert(pkg_toml.name.clone(), install_state); - - Ok(false) + // TODO: Handle manual & dependents + (false, Some((true, BTreeSet::new()))) } + }; + + if let Some((manual, dependents)) = pstate { + if archive_path.is_file() { + pkgar::extract(pkey_path, &archive_path, sysroot_dir)?; + } + + // TODO: Check if we need to inject remote key + let install_state = InstallState::from_package(&pkg_toml, remote_name, manual, dependents); + state.installed.insert(pkg_toml.name.clone(), install_state); } + + Ok(cached) } diff --git a/src/cook/tree.rs b/src/cook/tree.rs index 475fbbcc..66412e6d 100644 --- a/src/cook/tree.rs +++ b/src/cook/tree.rs @@ -62,10 +62,14 @@ pub fn walk_tree_entry( let (_, pkg_path, pkg_toml) = cook_recipe.stage_paths(); let deduped = visited.contains(package_name); - let entry = match (std::fs::metadata(&pkg_path), deduped) { - (_, true) => WalkTreeEntry::Deduped, - (Ok(meta), _) => WalkTreeEntry::Built(&pkg_path, meta.len()), - (Err(_), _) => WalkTreeEntry::NotBuilt, + let entry = if deduped { + WalkTreeEntry::Deduped + } else { + match (std::fs::metadata(&pkg_path), pkg_toml.is_file()) { + (Ok(meta), _) => WalkTreeEntry::Built(&pkg_path, meta.len()), + (Err(_), true) => WalkTreeEntry::Built(&pkg_path, 0), + (Err(_), false) => WalkTreeEntry::NotBuilt, + } }; let cached = op(package_name, prefix, is_last, &entry)?;