mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 13:07:58 -05:00
* Fixed an issue with globbing the --test argument
* Added a custom 'mkdir' function which makes parents and doesn't fail on existence * Added output for 'SKIP' messages (it did not indicate WHY it was skipped) * Added the ability to generate DB packages in the sync dir (not the cache dir) for testing downloading. (self.cachepkgs = False) * Added pmtest.path for the full path to the package file
This commit is contained in:
parent
714a414e72
commit
2caadb33bf
@ -36,7 +36,8 @@ def globTests(option, opt_str, value, parser):
|
|||||||
globlist = []
|
globlist = []
|
||||||
|
|
||||||
# maintain the idx so we can modify rargs
|
# maintain the idx so we can modify rargs
|
||||||
while not parser.rargs[idx].startswith('-'):
|
while idx < len(parser.rargs) and \
|
||||||
|
not parser.rargs[idx].startswith('-'):
|
||||||
globlist += glob.glob(parser.rargs[idx])
|
globlist += glob.glob(parser.rargs[idx])
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
|
@ -219,8 +219,7 @@ class pmdb:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
path = os.path.join(self.dbdir, self.treename, pkg.fullname())
|
path = os.path.join(self.dbdir, self.treename, pkg.fullname())
|
||||||
if not os.path.isdir(path):
|
mkdir(path)
|
||||||
os.makedirs(path);
|
|
||||||
|
|
||||||
# desc
|
# desc
|
||||||
# for local db entries: name, version, desc, groups, url, license,
|
# for local db entries: name, version, desc, groups, url, license,
|
||||||
@ -332,7 +331,7 @@ class pmdb:
|
|||||||
mkdescfile(pkg.fullname(), pkg)
|
mkdescfile(pkg.fullname(), pkg)
|
||||||
|
|
||||||
# Generate database archive
|
# Generate database archive
|
||||||
os.makedirs(path, 0755)
|
mkdir(path)
|
||||||
archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB))
|
archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB))
|
||||||
os.system("tar zcf %s *" % archive)
|
os.system("tar zcf %s *" % archive)
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ class pmpkg:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, version = "1.0-1"):
|
def __init__(self, name, version = "1.0-1"):
|
||||||
|
self.path = "" #the path of the generated package
|
||||||
# desc
|
# desc
|
||||||
self.name = name
|
self.name = name
|
||||||
self.version = version
|
self.version = version
|
||||||
@ -116,7 +117,7 @@ class pmpkg:
|
|||||||
A package archive is generated in the location 'path', based on the data
|
A package archive is generated in the location 'path', based on the data
|
||||||
from the object.
|
from the object.
|
||||||
"""
|
"""
|
||||||
archive = os.path.join(path, self.filename())
|
self.path = os.path.join(path, self.filename())
|
||||||
|
|
||||||
curdir = os.getcwd()
|
curdir = os.getcwd()
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
@ -172,8 +173,11 @@ class pmpkg:
|
|||||||
os.system("touch .FILELIST")
|
os.system("touch .FILELIST")
|
||||||
targets += " .FILELIST"
|
targets += " .FILELIST"
|
||||||
|
|
||||||
|
#safely create the dir
|
||||||
|
mkdir(os.path.dirname(self.path))
|
||||||
|
|
||||||
# Generate package archive
|
# Generate package archive
|
||||||
os.system("tar zcf %s %s" % (archive, targets))
|
os.system("tar zcf %s %s" % (self.path, targets))
|
||||||
|
|
||||||
os.chdir(curdir)
|
os.chdir(curdir)
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
|
@ -57,6 +57,7 @@ class pmrule:
|
|||||||
if not grep(os.path.join(root, LOGFILE), key):
|
if not grep(os.path.join(root, LOGFILE), key):
|
||||||
success = 0
|
success = 0
|
||||||
else:
|
else:
|
||||||
|
print "PACMAN rule '%s' not found" % case
|
||||||
success = -1
|
success = -1
|
||||||
elif kind == "PKG":
|
elif kind == "PKG":
|
||||||
newpkg = localdb.db_read(key)
|
newpkg = localdb.db_read(key)
|
||||||
@ -100,6 +101,7 @@ class pmrule:
|
|||||||
if not found:
|
if not found:
|
||||||
success = 0
|
success = 0
|
||||||
else:
|
else:
|
||||||
|
print "PKG rule '%s' not found" % case
|
||||||
success = -1
|
success = -1
|
||||||
elif kind == "FILE":
|
elif kind == "FILE":
|
||||||
filename = os.path.join(root, key)
|
filename = os.path.join(root, key)
|
||||||
@ -122,8 +124,10 @@ class pmrule:
|
|||||||
if not os.path.isfile("%s%s" % (filename, PM_PACSAVE)):
|
if not os.path.isfile("%s%s" % (filename, PM_PACSAVE)):
|
||||||
success = 0
|
success = 0
|
||||||
else:
|
else:
|
||||||
|
print "FILE rule '%s' not found" % case
|
||||||
success = -1
|
success = -1
|
||||||
else:
|
else:
|
||||||
|
print "Rule kind '%s' not found" % kind
|
||||||
success = -1
|
success = -1
|
||||||
|
|
||||||
if self.false and success != -1:
|
if self.false and success != -1:
|
||||||
|
@ -38,6 +38,7 @@ class pmtest:
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.testname = os.path.basename(name).replace('.py', '')
|
self.testname = os.path.basename(name).replace('.py', '')
|
||||||
self.root = root
|
self.root = root
|
||||||
|
self.cachepkgs = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "name = %s\n" \
|
return "name = %s\n" \
|
||||||
@ -130,14 +131,15 @@ class pmtest:
|
|||||||
vprint("\t%s" % os.path.join(TMPDIR, pkg.filename()))
|
vprint("\t%s" % os.path.join(TMPDIR, pkg.filename()))
|
||||||
pkg.makepkg(tmpdir)
|
pkg.makepkg(tmpdir)
|
||||||
for key, value in self.db.iteritems():
|
for key, value in self.db.iteritems():
|
||||||
if key == "local":
|
if key == "local": continue
|
||||||
continue
|
|
||||||
for pkg in value.pkgs:
|
for pkg in value.pkgs:
|
||||||
archive = pkg.filename()
|
vprint("\t%s" % os.path.join(PM_CACHEDIR, pkg.filename()))
|
||||||
vprint("\t%s" % os.path.join(PM_CACHEDIR, archive))
|
if self.cachepkgs:
|
||||||
pkg.makepkg(cachedir)
|
pkg.makepkg(cachedir)
|
||||||
pkg.md5sum = getmd5sum(os.path.join(cachedir, archive))
|
else:
|
||||||
pkg.csize = os.stat(os.path.join(cachedir, archive))[stat.ST_SIZE]
|
pkg.makepkg(os.path.join(syncdir, value.treename))
|
||||||
|
pkg.md5sum = getmd5sum(pkg.path)
|
||||||
|
pkg.csize = os.stat(pkg.path)[stat.ST_SIZE]
|
||||||
|
|
||||||
# Populating databases
|
# Populating databases
|
||||||
vprint(" Populating databases")
|
vprint(" Populating databases")
|
||||||
@ -151,8 +153,7 @@ class pmtest:
|
|||||||
# Creating sync database archives
|
# Creating sync database archives
|
||||||
vprint(" Creating sync database archives")
|
vprint(" Creating sync database archives")
|
||||||
for key, value in self.db.iteritems():
|
for key, value in self.db.iteritems():
|
||||||
if key == "local":
|
if key == "local": continue
|
||||||
continue
|
|
||||||
archive = value.treename + PM_EXT_DB
|
archive = value.treename + PM_EXT_DB
|
||||||
vprint("\t" + os.path.join(SYNCREPO, archive))
|
vprint("\t" + os.path.join(SYNCREPO, archive))
|
||||||
value.gensync(os.path.join(syncdir, value.treename))
|
value.gensync(os.path.join(syncdir, value.treename))
|
||||||
|
@ -247,6 +247,16 @@ def grep(filename, pattern):
|
|||||||
fd.close()
|
fd.close()
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
def mkdir(dir):
|
||||||
|
if os.path.isdir(dir):
|
||||||
|
return
|
||||||
|
elif os.path.isfile(dir):
|
||||||
|
raise OSError("'%s' already exists and is not a directory" % dir)
|
||||||
|
else:
|
||||||
|
parent, thisdir = os.path.split(dir)
|
||||||
|
if parent: mkdir(parent) #recurse to make all parents
|
||||||
|
print "making dir %s" % thisdir
|
||||||
|
if thisdir: os.mkdir(dir)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user