From 213fb926e54d348f52897ab5f094be253425556d Mon Sep 17 00:00:00 2001 From: Dark Knight <> Date: Mon, 18 Nov 2024 23:11:20 -0800 Subject: [PATCH] Revert D66033287 Summary: This diff reverts D66033287 https://fb.workplace.com/groups/registryusers/posts/977713264117672 Test Plan: NA Reviewed By: justintrudell Differential Revision: D66151496 fbshipit-source-id: 81b17abc2bd628215ca6e01cba85f4fae4b12751 --- antlir/antlir2/antlir2_packager/src/rpm.rs | 27 +++------------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/antlir/antlir2/antlir2_packager/src/rpm.rs b/antlir/antlir2/antlir2_packager/src/rpm.rs index a60b4fa9f1..e98e175461 100644 --- a/antlir/antlir2/antlir2_packager/src/rpm.rs +++ b/antlir/antlir2/antlir2_packager/src/rpm.rs @@ -277,6 +277,9 @@ AutoProv: {autoprov} spec.push_str("%files\n"); for entry in walkdir::WalkDir::new(layer) { let entry = entry.context("while walking layer")?; + if entry.file_type().is_dir() { + continue; + } let relpath = Path::new("/").join( entry .path() @@ -286,30 +289,6 @@ AutoProv: {autoprov} if relpath == Path::new("/") { continue; } - if entry.file_type().is_dir() { - let is_empty = std::fs::read_dir(entry.path())?.next().is_none(); - // non-empty directories are not marked as provided in the rpm spec, - // since they are likely to conflict with other RPMs. For example, - // an rpm that installs a binary to /usr/local/bin/foo should not conflict - // with one that installs a binary to /usr/local/bin/bar, but they would - // conflict if they were both declared to provide the dir /usr/local/bin. - // On the other hand, an RPM that explicitly creates an empty directory is - // probably done intentionally, so empty directories are recorded in the spec. - if !is_empty { - continue; - } - let mut dir_path_str = relpath - .to_str() - .expect("our paths are always valid utf8") - .to_owned(); - if dir_path_str.contains(" ") { - dir_path_str = format!("\"{dir_path_str}\""); - } - spec.push_str("%dir "); - spec.push_str(&dir_path_str); - spec.push('\n'); - continue; - } if !entry.file_type().is_symlink() { let f = std::fs::File::open(entry.path())?; #[cfg(feature = "libcap")]