From 4ac242ed7b1042558f46aa7c9ee551fef6a3e010 Mon Sep 17 00:00:00 2001 From: SFG545 Date: Sun, 15 Mar 2026 23:05:24 -0500 Subject: [PATCH] test: rename and update lib32 installation tests to reflect changes in path handling --- src/builder/custom.rs | 7 +-- src/builder/makefile.rs | 4 +- src/builder/mod.rs | 99 +---------------------------------------- 3 files changed, 6 insertions(+), 104 deletions(-) diff --git a/src/builder/custom.rs b/src/builder/custom.rs index 10faafe..d10e831 100755 --- a/src/builder/custom.rs +++ b/src/builder/custom.rs @@ -489,7 +489,7 @@ exit 0 } #[test] - fn test_build_lib32_stages_usr_lib_and_keeps_non_library_paths() -> Result<()> { + fn test_build_lib32_stages_only_usr_lib_payload() -> Result<()> { let tmp_src = tempdir()?; let tmp_dest = tempdir()?; let tmp_tools = tempdir()?; @@ -545,10 +545,7 @@ exec "$@" std::fs::read_to_string(tmp_dest.path().join("usr/lib32/libfoo.so.1"))?, "lib32" ); - assert_eq!( - std::fs::read_to_string(tmp_dest.path().join("usr/share/man/man1/foo.1"))?, - "manpage" - ); + assert!(!tmp_dest.path().join("usr/share/man/man1/foo.1").exists()); assert!(!tmp_dest.path().join("usr/lib").exists()); Ok(()) diff --git a/src/builder/makefile.rs b/src/builder/makefile.rs index fca0735..e3baed7 100644 --- a/src/builder/makefile.rs +++ b/src/builder/makefile.rs @@ -241,7 +241,7 @@ exec "$@" } #[test] - fn test_makefile_lib32_install_relocates_usr_lib_and_keeps_other_paths() -> Result<()> { + fn test_makefile_lib32_install_relocates_usr_lib_without_copying_other_paths() -> Result<()> { let tmp_src = tempdir()?; let tmp_dest = tempdir()?; let tmp_tools = tempdir()?; @@ -277,7 +277,7 @@ exec "$@" fs::read_to_string(dest_path.join("usr/lib32/libfoo.so.1"))?, "lib32" ); - assert_eq!(fs::read_to_string(dest_path.join("usr/bin/foo"))?, "bin"); + assert!(!dest_path.join("usr/bin/foo").exists()); assert!(!dest_path.join("usr/lib").exists()); Ok(()) diff --git a/src/builder/mod.rs b/src/builder/mod.rs index e1a3a04..25b2b94 100755 --- a/src/builder/mod.rs +++ b/src/builder/mod.rs @@ -181,7 +181,6 @@ pub(crate) fn install_destdir_path( pub(crate) fn stage_lib32_install_tree(staging_destdir: &Path, destdir: &Path) -> Result<()> { let lib_rel = lib32_stage_source_rel(staging_destdir)?; - copy_install_tree_preserving_links(staging_destdir, destdir, Some(&lib_rel))?; copy_tree_preserving_links(&staging_destdir.join(&lib_rel), &destdir.join("usr/lib32")) } @@ -241,84 +240,6 @@ fn copy_tree_preserving_links(src: &Path, dst: &Path) -> Result<()> { Ok(()) } - -fn copy_install_tree_preserving_links( - src: &Path, - dst: &Path, - relocated_lib_rel: Option<&Path>, -) -> Result<()> { - fs::create_dir_all(dst) - .with_context(|| format!("Failed to create destination dir: {}", dst.display()))?; - - for entry in WalkDir::new(src) { - let entry = entry?; - let rel = entry - .path() - .strip_prefix(src) - .with_context(|| format!("Failed to strip prefix: {}", src.display()))?; - if should_skip_staged_install_entry(rel, relocated_lib_rel) { - continue; - } - - let target = dst.join(rel); - - if entry.file_type().is_dir() { - fs::create_dir_all(&target) - .with_context(|| format!("Failed to create dir: {}", target.display()))?; - continue; - } - - if let Some(parent) = target.parent() { - fs::create_dir_all(parent) - .with_context(|| format!("Failed to create dir: {}", parent.display()))?; - } - - if entry.file_type().is_symlink() { - let link_target = fs::read_link(entry.path()) - .with_context(|| format!("Failed to read symlink: {}", entry.path().display()))?; - #[cfg(unix)] - { - use std::os::unix::fs as unix_fs; - unix_fs::symlink(&link_target, &target).with_context(|| { - format!( - "Failed to create symlink {} -> {}", - target.display(), - link_target.display() - ) - })?; - } - #[cfg(not(unix))] - { - anyhow::bail!( - "Symlink-preserving lib32 staging copy is only supported on unix hosts" - ); - } - } else { - fs::copy(entry.path(), &target).with_context(|| { - format!( - "Failed to copy {} to {}", - entry.path().display(), - target.display() - ) - })?; - } - } - - Ok(()) -} - -fn should_skip_staged_install_entry(rel: &Path, relocated_lib_rel: Option<&Path>) -> bool { - if rel.as_os_str().is_empty() { - return false; - } - - if rel.starts_with(Path::new(crate::shell_helpers::INTERNAL_DEPOT_DIR)) { - return true; - } - - relocated_lib_rel.is_some_and(|lib_rel| rel.starts_with(lib_rel)) -} - fn lib32_stage_source_rel(staging_destdir: &Path) -> Result { let staged_lib32 = PathBuf::from("usr/lib32"); if staging_destdir.join(&staged_lib32).exists() { @@ -1064,13 +985,6 @@ mod tests { fs::create_dir_all(staging.join("usr/bin"))?; fs::write(staging.join("usr/lib32/libfoo.so.1"), "lib32")?; fs::write(staging.join("usr/bin/foo"), "bin")?; - fs::create_dir_all(staging.join(crate::shell_helpers::INTERNAL_DEPOT_DIR))?; - fs::write( - staging - .join(crate::shell_helpers::INTERNAL_DEPOT_DIR) - .join("internal.txt"), - "skip", - )?; stage_lib32_install_tree(&staging, &dest)?; @@ -1078,13 +992,7 @@ mod tests { fs::read_to_string(dest.join("usr/lib32/libfoo.so.1"))?, "lib32" ); - assert_eq!(fs::read_to_string(dest.join("usr/bin/foo"))?, "bin"); - assert!( - !dest - .join(crate::shell_helpers::INTERNAL_DEPOT_DIR) - .join("internal.txt") - .exists() - ); + assert!(!dest.join("usr/bin/foo").exists()); Ok(()) } @@ -1112,10 +1020,7 @@ mod tests { fs::read_link(dest.join("usr/lib32/libfoo.so"))?, PathBuf::from("libfoo.so.1") ); - assert_eq!( - fs::read_to_string(dest.join("usr/share/man/man1/foo.1"))?, - "manpage" - ); + assert!(!dest.join("usr/share/man/man1/foo.1").exists()); assert!(!dest.join("usr/lib").exists()); Ok(()) }