From 93f1b13179a9c3bfbaff3cadc54011e8f36badc4 Mon Sep 17 00:00:00 2001 From: SFG545 Date: Sun, 8 Mar 2026 17:20:15 -0500 Subject: [PATCH] feat: update depot version to 0.10.1 and implement logic to skip purged payload paths --- Cargo.lock | 2 +- Cargo.toml | 2 +- meson.build | 2 +- src/package/packager.rs | 99 +++++++++++++++++++++++++++++++++++++++++ src/staging/mod.rs | 8 +++- 5 files changed, 108 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c8f516..72640f3 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -382,7 +382,7 @@ checksum = "807800ff3288b621186fe0a8f3392c4652068257302709c24efd918c3dffcdc2" [[package]] name = "depot" -version = "0.10.0" +version = "0.10.1" dependencies = [ "anyhow", "ar", diff --git a/Cargo.toml b/Cargo.toml index 43e7b3a..7472f78 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "depot" -version = "0.10.0" +version = "0.10.1" edition = "2024" [lints.rust] diff --git a/meson.build b/meson.build index d4a71c2..2db8be7 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'depot', - version: '0.10.0', + version: '0.10.1', meson_version: '>=0.60.0', ) diff --git a/src/package/packager.rs b/src/package/packager.rs index cd92569..9d34978 100644 --- a/src/package/packager.rs +++ b/src/package/packager.rs @@ -16,6 +16,10 @@ fn is_internal_staging_rel_path(rel_path: &Path) -> bool { .is_some_and(|rest| rest.starts_with('/')) } +fn is_skipped_package_payload_rel_path(rel_path: &Path) -> bool { + crate::staging::is_purged_payload_path(&rel_path.to_string_lossy()) +} + fn license_value(licenses: &[String]) -> toml::Value { if licenses.len() == 1 { toml::Value::String(licenses[0].clone()) @@ -89,6 +93,9 @@ impl Packager { if is_internal_staging_rel_path(rel_path) { continue; } + if is_skipped_package_payload_rel_path(rel_path) { + continue; + } let file_type = entry.file_type(); if file_type.is_dir() { @@ -225,6 +232,9 @@ impl Packager { if is_internal_staging_rel_path(Path::new(&relative)) { continue; } + if is_skipped_package_payload_rel_path(Path::new(&relative)) { + continue; + } if file_type.is_dir() { self.collect_files(base, &path, files)?; @@ -246,6 +256,7 @@ fn num_cpus() -> usize { mod tests { use super::*; use crate::package::{Alternatives, Build, BuildFlags, BuildType, Dependencies, PackageInfo}; + use std::io::Read; fn mk_packager(destdir: PathBuf) -> Packager { Packager::new( @@ -311,6 +322,42 @@ mod tests { assert!(!files.iter().any(|f| f.starts_with(".depot/outputs/"))); } + #[test] + fn test_collect_files_skips_purged_payload_paths() { + let tmp = tempfile::tempdir().unwrap(); + let dest = tmp.path(); + fs::create_dir_all(dest.join("usr/share/info")).unwrap(); + fs::create_dir_all(dest.join("usr/lib/perl5/5.42/core_perl")).unwrap(); + fs::create_dir_all(dest.join("usr/lib/perl5/5.42/vendor_perl/auto/Error")).unwrap(); + fs::create_dir_all(dest.join("usr/share/doc/perl-error")).unwrap(); + fs::create_dir_all(dest.join("usr/bin")).unwrap(); + fs::write(dest.join("usr/share/info/dir"), "index").unwrap(); + fs::write( + dest.join("usr/lib/perl5/5.42/core_perl/perllocal.pod"), + "pod", + ) + .unwrap(); + fs::write( + dest.join("usr/lib/perl5/5.42/vendor_perl/auto/Error/.packlist"), + "packlist", + ) + .unwrap(); + fs::write(dest.join("usr/share/doc/perl-error/Error.pod"), "pod").unwrap(); + fs::write(dest.join("usr/bin/foo"), "x").unwrap(); + + let packager = mk_packager(dest.to_path_buf()); + let mut files = Vec::new(); + packager.collect_files(dest, dest, &mut files).unwrap(); + + assert!(!files.contains(&"usr/share/info/dir".to_string())); + assert!(!files.contains(&"usr/lib/perl5/5.42/core_perl/perllocal.pod".to_string())); + assert!( + !files.contains(&"usr/lib/perl5/5.42/vendor_perl/auto/Error/.packlist".to_string()) + ); + assert!(!files.contains(&"usr/share/doc/perl-error/Error.pod".to_string())); + assert!(files.contains(&"usr/bin/foo".to_string())); + } + #[test] fn test_generate_files_yaml() { let tmp = tempfile::tempdir().unwrap(); @@ -372,4 +419,56 @@ mod tests { assert_eq!(arr[0].as_str(), Some("MIT")); assert_eq!(arr[1].as_str(), Some("Apache-2.0")); } + + #[test] + fn test_create_package_skips_purged_payload_paths() { + let tmp = tempfile::tempdir().unwrap(); + let dest = tmp.path().join("dest"); + let out = tmp.path().join("out"); + fs::create_dir_all(dest.join("usr/share/info")).unwrap(); + fs::create_dir_all(dest.join("usr/lib/perl5/5.42/core_perl")).unwrap(); + fs::create_dir_all(dest.join("usr/lib/perl5/5.42/vendor_perl/auto/Error")).unwrap(); + fs::create_dir_all(dest.join("usr/share/doc/perl-error")).unwrap(); + fs::create_dir_all(dest.join("usr/bin")).unwrap(); + fs::write(dest.join("usr/share/info/dir"), "index").unwrap(); + fs::write( + dest.join("usr/lib/perl5/5.42/core_perl/perllocal.pod"), + "pod", + ) + .unwrap(); + fs::write( + dest.join("usr/lib/perl5/5.42/vendor_perl/auto/Error/.packlist"), + "packlist", + ) + .unwrap(); + fs::write(dest.join("usr/share/doc/perl-error/Error.pod"), "pod").unwrap(); + fs::write(dest.join("usr/bin/foo"), "x").unwrap(); + fs::create_dir_all(&out).unwrap(); + + let packager = mk_packager(dest.clone()); + let archive_path = packager.create_package(&out, "x86_64").unwrap(); + + let archive_file = fs::File::open(&archive_path).unwrap(); + let decoder = zstd::Decoder::new(archive_file).unwrap(); + let mut archive = tar::Archive::new(decoder); + let mut paths = Vec::new(); + + for entry in archive.entries().unwrap() { + let mut entry = entry.unwrap(); + let path = entry.path().unwrap().to_string_lossy().to_string(); + let mut sink = Vec::new(); + let _ = entry.read_to_end(&mut sink); + paths.push(path); + } + + assert!(!paths.contains(&"usr/share/info/dir".to_string())); + assert!(!paths.contains(&"usr/lib/perl5/5.42/core_perl/perllocal.pod".to_string())); + assert!( + !paths.contains(&"usr/lib/perl5/5.42/vendor_perl/auto/Error/.packlist".to_string()) + ); + assert!(!paths.contains(&"usr/share/doc/perl-error/Error.pod".to_string())); + assert!(paths.contains(&"usr/bin/foo".to_string())); + assert!(paths.contains(&".metadata.toml".to_string())); + assert!(paths.contains(&".files.yaml".to_string())); + } } diff --git a/src/staging/mod.rs b/src/staging/mod.rs index 571aaea..adfd17f 100755 --- a/src/staging/mod.rs +++ b/src/staging/mod.rs @@ -31,6 +31,11 @@ fn is_purged_install_basename(rel_path: &str) -> bool { .is_some_and(|name| name == ".packlist" || name.ends_with(".pod")) } +pub(crate) fn is_purged_payload_path(rel_path: &str) -> bool { + let p = rel_path.trim_start_matches('/'); + is_info_dir_index_path(p) || is_purged_install_basename(p) +} + fn is_skipped_install_path(rel_path: &str) -> bool { let p = rel_path.trim_start_matches('/'); p == ".metadata.toml" @@ -40,8 +45,7 @@ fn is_skipped_install_path(rel_path: &str) -> bool { .is_some_and(|rest| rest.starts_with('/')) || p == "scripts" || p.starts_with("scripts/") - || is_info_dir_index_path(p) - || is_purged_install_basename(p) + || is_purged_payload_path(p) } /// Return the internal split-output staging root inside a package `destdir`.