]> git.ipfire.org Git - pakfire.git/commitdiff
Change the way of packaging files.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Oct 2011 09:29:47 +0000 (11:29 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Oct 2011 10:07:43 +0000 (12:07 +0200)
We now package all directories until the top.

python/pakfire/packages/packager.py
python/pakfire/transaction.py

index b50483b49c00dd9f4803e0c721420f43afab4d5c..7ff97773b292096bf86d58520966fa65a327d9aa 100644 (file)
@@ -301,6 +301,9 @@ 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
@@ -308,7 +311,22 @@ class BinaryPackager(Packager):
                        if file in excludes or file in files:
                                continue
 
+                       # Skip orphan directories.
+                       if file in orphan_directories and not os.listdir(file):
+                               logging.debug("Found an orphaned directory: %s" % file)
+                               continue
+
                        files.append(file)
+
+                       while True:
+                               file = os.path.dirname(file)
+
+                               if file == self.buildroot:
+                                       break
+
+                               if not file in files:
+                                       files.append(file)
+
                files.sort()
 
                # Load progressbar.
@@ -331,21 +349,9 @@ class BinaryPackager(Packager):
                        if os.path.normpath(file) == os.path.normpath(basedir):
                                continue
 
+                       # Name of the file in the archive.
                        arcname = "/%s" % os.path.relpath(file, basedir)
 
-                       # Special handling for directories.
-                       if os.path.isdir(file):
-                               # Empty directories that are in the list of ORPHAN_DIRECTORIES
-                               # can be skipped and removed.
-                               if arcname in ORPHAN_DIRECTORIES and not os.listdir(file):
-                                       logging.debug("Found an orphaned directory: %s" % arcname)
-                                       try:
-                                               os.unlink(file)
-                                       except OSError:
-                                               pass
-
-                                       continue
-
                        # Add file to tarball.
                        tar.add(file, arcname=arcname, recursive=False)
 
index a778876210396a5ee6b2eb2106ad53d6d63bee58..77e738e73e20fc0b3ea3ba6412f979b78d4bf52a 100644 (file)
@@ -104,6 +104,12 @@ class TransactionCheck(object):
 
        def remove(self, pkg):
                for file in pkg.filelist:
+                       if file.is_dir():
+                               continue
+
+                       if not self.filelist.has_key(file):
+                               continue
+
                        for f in self.filelist[file.name]:
                                if not f.pkg == pkg:
                                        continue