summaryrefslogtreecommitdiff
path: root/test/pacman/pmpkg.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-22 15:05:53 -0500
committerDan McGee <dan@archlinux.org>2011-06-24 01:36:48 -0500
commitf15cce1d414cb497ee804d50c25c6d3d717240bd (patch)
treeac2db9dc2eb519dd592ad0e898d54a944d2e253e /test/pacman/pmpkg.py
parent3ace8ceb2343621ada4a72fc60e8e03a570fd389 (diff)
pactest: move filelist/backup generation into package object
These are definite methods that operate on a package, so move them there which cleans up util a bit more. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test/pacman/pmpkg.py')
-rw-r--r--test/pacman/pmpkg.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index 3d2a6cf4..43edd8f0 100644
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -89,6 +89,17 @@ class pmpkg(object):
"""
return "%s%s" % (self.fullname(), util.PM_EXT_PKG)
+ @staticmethod
+ def parse_filename(name):
+ filename = name
+ if filename[-1] == "*":
+ filename = filename.rstrip("*")
+ if filename.find(" -> ") != -1:
+ filename, extra = filename.split(" -> ")
+ elif filename.find("|") != -1:
+ filename, extra = filename.split("|")
+ return filename
+
def makepkg(self, path):
"""Creates an Arch Linux package archive.
@@ -104,7 +115,7 @@ class pmpkg(object):
# Generate package file system
for f in self.files:
util.mkfile(f, f)
- self.size += os.lstat(util.getfilename(f))[stat.ST_SIZE]
+ self.size += os.lstat(self.parse_filename(f))[stat.ST_SIZE]
# .PKGINFO
data = ["pkgname = %s" % self.name]
@@ -150,4 +161,29 @@ class pmpkg(object):
os.chdir(curdir)
shutil.rmtree(tmpdir)
+ def full_filelist(self):
+ """Generate a list of package files.
+
+ Each path is decomposed to generate the list of all directories leading
+ to the file.
+
+ Example with 'usr/local/bin/dummy':
+ The resulting list will be:
+ usr/
+ usr/local/
+ usr/local/bin/
+ usr/local/bin/dummy
+ """
+ file_set = set()
+ for name in self.files:
+ name = self.parse_filename(name)
+ file_set.add(name)
+ while "/" in name:
+ name, tmp = name.rsplit("/", 1)
+ file_set.add(name + "/")
+ return sorted(file_set)
+
+ def local_backup_entries(self):
+ return ["%s\t%s" % (self.parse_filename(i), util.mkmd5sum(i)) for i in self.backup]
+
# vim: set ts=4 sw=4 et: