From 13b54713e859c2d562c92a496c31870370e9b8e8 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 13 Apr 2012 17:42:17 +0200 Subject: [PATCH] Skip empty directories if there is a link pointing to them. --- python/pakfire/packages/packager.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/python/pakfire/packages/packager.py b/python/pakfire/packages/packager.py index c756b0c5a..0895c55f8 100644 --- a/python/pakfire/packages/packager.py +++ b/python/pakfire/packages/packager.py @@ -296,6 +296,20 @@ class BinaryPackager(Packager): # List of all patterns, which grows. patterns = self.pkg.files + # ... + orphan_directories = [] + for d in ORPHAN_DIRECTORIES: + if d.startswith("usr/"): + b = os.path.basename(d) + b = os.path.join(self.buildroot, b) + + if os.path.islink(b): + continue + + d = os.path.join(self.buildroot, d) + if not os.path.islink(d): + orphan_directories.append(d) + for pattern in patterns: # Check if we are running in include or exclude mode. if pattern.startswith("!"): @@ -334,7 +348,7 @@ class BinaryPackager(Packager): for dir, subdirs, _files in os.walk(pattern): for subdir in subdirs: - if subdir in ORPHAN_DIRECTORIES: + if subdir in orphan_directories: continue subdir = os.path.join(dir, subdir) @@ -348,9 +362,6 @@ class BinaryPackager(Packager): else: files.append(pattern) - # ... - orphan_directories = [os.path.join(self.buildroot, d) for d in ORPHAN_DIRECTORIES] - files = [] for file in includes: # Skip if file is already in the file set or -- 2.39.5