From c00c6f3329ad2415abb4bd440af256a45597c848 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 3 Oct 2011 11:29:47 +0200 Subject: [PATCH] Change the way of packaging files. We now package all directories until the top. --- python/pakfire/packages/packager.py | 32 +++++++++++++++++------------ python/pakfire/transaction.py | 6 ++++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/python/pakfire/packages/packager.py b/python/pakfire/packages/packager.py index b50483b49..7ff97773b 100644 --- a/python/pakfire/packages/packager.py +++ b/python/pakfire/packages/packager.py @@ -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) diff --git a/python/pakfire/transaction.py b/python/pakfire/transaction.py index a77887621..77e738e73 100644 --- a/python/pakfire/transaction.py +++ b/python/pakfire/transaction.py @@ -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 -- 2.39.5