mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
pmpkg: add missing directories to test packages
Several tests require complete file lists in order to provide accurate results. These can be non-obvious. Adding missing parent directories helps insure the integrity of tests against human error. Filling in parent directories also allows us to check that file lists are actually valid. There didn't seem to be a good place to do this that was always guaranteed to be run, so this adds a finalize() function to packages that will always be run before the package is actually used to allow for this type of tidying. Fixes FS#30723 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
2259dff7f3
commit
43a2f63194
@ -219,7 +219,7 @@ class pmdb(object):
|
|||||||
# files and install
|
# files and install
|
||||||
if self.is_local:
|
if self.is_local:
|
||||||
data = []
|
data = []
|
||||||
make_section(data, "FILES", pkg.full_filelist())
|
make_section(data, "FILES", pkg.filelist())
|
||||||
make_section(data, "BACKUP", pkg.local_backup_entries())
|
make_section(data, "BACKUP", pkg.local_backup_entries())
|
||||||
entry["files"] = "\n".join(data)
|
entry["files"] = "\n".join(data)
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ class pmpkg(object):
|
|||||||
"post_upgrade": "",
|
"post_upgrade": "",
|
||||||
}
|
}
|
||||||
self.path = None
|
self.path = None
|
||||||
|
self.finalized = False
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = ["%s" % self.fullname()]
|
s = ["%s" % self.fullname()]
|
||||||
@ -182,27 +183,38 @@ class pmpkg(object):
|
|||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
os.utime(path, (355, 355))
|
os.utime(path, (355, 355))
|
||||||
|
|
||||||
def full_filelist(self):
|
def filelist(self):
|
||||||
"""Generate a list of package files.
|
"""Generate a list of package files."""
|
||||||
|
return sorted([self.parse_filename(f) for f in self.files])
|
||||||
|
|
||||||
Each path is decomposed to generate the list of all directories leading
|
def finalize(self):
|
||||||
to the file.
|
"""Perform any necessary operations to ready the package for use."""
|
||||||
|
if self.finalized:
|
||||||
|
return
|
||||||
|
|
||||||
Example with 'usr/local/bin/dummy':
|
# add missing parent dirs to file list
|
||||||
The resulting list will be:
|
# use bare file names so trailing ' -> ', '*', etc don't throw off the
|
||||||
usr/
|
# checks for existing files
|
||||||
usr/local/
|
file_names = self.filelist()
|
||||||
usr/local/bin/
|
for name in list(file_names):
|
||||||
usr/local/bin/dummy
|
if os.path.isabs(name):
|
||||||
"""
|
raise ValueError("Absolute path in filelist '%s'." % name)
|
||||||
file_set = set()
|
|
||||||
for name in self.files:
|
name = os.path.dirname(name.rstrip("/"))
|
||||||
name = self.parse_filename(name)
|
while name:
|
||||||
file_set.add(name)
|
if name in file_names:
|
||||||
while "/" in name:
|
# path exists as both a file and a directory
|
||||||
name, tmp = name.rsplit("/", 1)
|
raise ValueError("Duplicate path in filelist '%s'." % name)
|
||||||
file_set.add(name + "/")
|
elif name + "/" in file_names:
|
||||||
return sorted(file_set)
|
# path was either manually included or already processed
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
file_names.append(name + "/")
|
||||||
|
self.files.append(name + "/")
|
||||||
|
name = os.path.dirname(name)
|
||||||
|
self.files.sort()
|
||||||
|
|
||||||
|
self.finalized = True
|
||||||
|
|
||||||
def local_backup_entries(self):
|
def local_backup_entries(self):
|
||||||
return ["%s\t%s" % (self.parse_filename(i), util.mkmd5sum(i)) for i in self.backup]
|
return ["%s\t%s" % (self.parse_filename(i), util.mkmd5sum(i)) for i in self.backup]
|
||||||
|
@ -147,8 +147,11 @@ class pmtest(object):
|
|||||||
vprint(" Creating package archives")
|
vprint(" Creating package archives")
|
||||||
for pkg in self.localpkgs:
|
for pkg in self.localpkgs:
|
||||||
vprint("\t%s" % os.path.join(util.TMPDIR, pkg.filename()))
|
vprint("\t%s" % os.path.join(util.TMPDIR, pkg.filename()))
|
||||||
|
pkg.finalize()
|
||||||
pkg.makepkg(tmpdir)
|
pkg.makepkg(tmpdir)
|
||||||
for key, value in self.db.iteritems():
|
for key, value in self.db.iteritems():
|
||||||
|
for pkg in value.pkgs:
|
||||||
|
pkg.finalize()
|
||||||
if key == "local" and not self.createlocalpkgs:
|
if key == "local" and not self.createlocalpkgs:
|
||||||
continue
|
continue
|
||||||
for pkg in value.pkgs:
|
for pkg in value.pkgs:
|
||||||
|
Loading…
Reference in New Issue
Block a user