]> git.ipfire.org Git - pakfire.git/commitdiff
Skip empty directories if there is a link pointing to them.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 13 Apr 2012 15:42:17 +0000 (17:42 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 13 Apr 2012 15:42:17 +0000 (17:42 +0200)
python/pakfire/packages/packager.py

index c756b0c5aed60363b96341573e8d8cc5815ffb80..0895c55f8923d55e5c3e09d71e38cfbc23354acb 100644 (file)
@@ -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