summaryrefslogtreecommitdiff
path: root/test
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
parent3ace8ceb2343621ada4a72fc60e8e03a570fd389 (diff)
downloadpacman-f15cce1d414cb497ee804d50c25c6d3d717240bd.tar.xz
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')
-rw-r--r--test/pacman/pmdb.py29
-rw-r--r--test/pacman/pmpkg.py38
-rw-r--r--test/pacman/util.py10
3 files changed, 39 insertions, 38 deletions
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index cff3358f..72f6dc45 100644
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -22,31 +22,6 @@ import tarfile
import pmpkg
import util
-def _mkfilelist(files):
- """Generate a list of files from the list supplied as an argument.
-
- 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 f in files:
- name = util.getfilename(f)
- file_set.add(name)
- while "/" in name:
- name, tmp = name.rsplit("/", 1)
- file_set.add(name + "/")
- return sorted(file_set)
-
-def _mkbackuplist(backup):
- return ["%s\t%s" % (util.getfilename(i), util.mkmd5sum(i)) for i in backup]
-
def _getsection(fd):
i = []
while 1:
@@ -244,8 +219,8 @@ class pmdb(object):
# files and install
if self.is_local:
data = []
- make_section(data, "FILES", _mkfilelist(pkg.files))
- make_section(data, "BACKUP", _mkbackuplist(pkg.backup))
+ make_section(data, "FILES", pkg.full_filelist())
+ make_section(data, "BACKUP", pkg.local_backup_entries())
filename = os.path.join(path, "files")
util.mkfile(filename, "\n".join(data))
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:
diff --git a/test/pacman/util.py b/test/pacman/util.py
index f971afd1..5e8d3dbc 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -47,16 +47,6 @@ def vprint(msg):
# Methods to generate files
#
-def getfilename(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 mkfile(name, data = ""):
isdir = 0
islink = 0