index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
diff --git a/test/pacman/README b/test/pacman/README index 8f97a17d..0bd02138 100644 --- a/test/pacman/README +++ b/test/pacman/README @@ -290,7 +290,6 @@ challenge the requested data with it. Possible rules are: PKG_EXIST=name - PKG_MODIFIED=name PKG_VERSION=name|version PKG_GROUPS=name|group PKG_PROVIDES=name|providename diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py index f95ef3c1..69e655a0 100755 --- a/test/pacman/pactest.py +++ b/test/pacman/pactest.py @@ -30,7 +30,7 @@ def resolveBinPath(option, opt_str, value, parser): setattr(parser.values, option.dest, os.path.abspath(value)) def globTests(option, opt_str, value, parser): - idx=0 + idx = 0 globlist = [] # maintain the idx so we can modify rargs @@ -81,8 +81,8 @@ def createOptParser(): if __name__ == "__main__": # instantiate env and parser objects env = pmenv.pmenv() - parser = createOptParser() - (opts, args) = parser.parse_args() + opt_parser = createOptParser() + (opts, args) = opt_parser.parse_args() # add parsed options to env object util.verbose = opts.verbose diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index 218e3b58..b31498a7 100755 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -17,13 +17,10 @@ import os -import tempfile -import shutil import tarfile import pmpkg -from util import * - +import util def _mkfilelist(files): """Generate a list of files from the list supplied as an argument. @@ -38,19 +35,19 @@ def _mkfilelist(files): usr/local/bin/ usr/local/bin/dummy """ - file_list = set() + file_set = set() for f in files: - dir = getfilename(f) - file_list.add(dir) - while "/" in dir: - [dir, tmp] = dir.rsplit("/", 1) - file_list.add(dir + "/") - return sorted(file_list) + 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" % (getfilename(i), mkmd5sum(i)) for i in backup] + return ["%s\t%s" % (util.getfilename(i), util.mkmd5sum(i)) for i in backup] def _getsection(fd): """ @@ -75,15 +72,19 @@ def _mksection(title, data): "%s\n" % (title, s) -class pmdb: +class pmdb(object): """Database object """ - def __init__(self, treename, dbdir): + def __init__(self, treename, root): self.treename = treename - self.dbdir = dbdir self.pkgs = [] self.option = {} + if self.treename == "local": + self.dbdir = os.path.join(root, util.PM_DBPATH, treename) + else: + self.dbdir = os.path.join(root, util.PM_SYNCDBPATH, treename) + self.dbfile = os.path.join(root, util.PM_SYNCDBPATH, treename + ".db") def __str__(self): return "%s" % self.treename @@ -98,8 +99,7 @@ class pmdb: def db_read(self, name): """ """ - - path = os.path.join(self.dbdir, self.treename) + path = self.dbdir if not os.path.isdir(path): return None @@ -152,12 +152,15 @@ class pmdb: pkg.md5sum = fd.readline().strip("\n") elif line == "%REPLACES%": pkg.replaces = _getsection(fd) - elif line == "%FORCE%": - fd.readline() - pkg.force = 1 + elif line == "%DEPENDS%": + pkg.depends = _getsection(fd) + elif line == "%OPTDEPENDS%": + pkg.optdepends = _getsection(fd) + elif line == "%CONFLICTS%": + pkg.conflicts = _getsection(fd) + elif line == "%PROVIDES%": + pkg.provides = _getsection(fd) fd.close() - pkg.checksum["desc"] = getmd5sum(filename) - pkg.mtime["desc"] = getmtime(filename) # files filename = os.path.join(path, "files") @@ -178,43 +181,9 @@ class pmdb: if line == "%BACKUP%": pkg.backup = _getsection(fd) fd.close() - pkg.checksum["files"] = getmd5sum(filename) - pkg.mtime["files"] = getmtime(filename) - - # depends - filename = os.path.join(path, "depends") - if not os.path.isfile(filename): - print "invalid db entry found (depends missing) for pkg", pkgname - return None - fd = file(filename, "r") - while 1: - line = fd.readline() - if not line: - break - line = line.strip("\n") - if line == "%DEPENDS%": - pkg.depends = _getsection(fd) - elif line == "%OPTDEPENDS%": - pkg.optdepends = _getsection(fd) - elif line == "%CONFLICTS%": - pkg.conflicts = _getsection(fd) - elif line == "%PROVIDES%": - pkg.provides = _getsection(fd) - # TODO this was going to be changed, but isn't anymore - #elif line == "%REPLACES%": - # pkg.replaces = _getsection(fd) - #elif line == "%FORCE%": - # fd.readline() - # pkg.force = 1 - fd.close() - pkg.checksum["depends"] = getmd5sum(filename) - pkg.mtime["depends"] = getmtime(filename) # install filename = os.path.join(path, "install") - if os.path.isfile(filename): - pkg.checksum["install"] = getmd5sum(filename) - pkg.mtime["install"] = getmtime(filename) return pkg @@ -224,19 +193,15 @@ class pmdb: def db_write(self, pkg): """ """ - - if self.treename == "local": - path = os.path.join(self.dbdir, self.treename, pkg.fullname()) - else: - path = os.path.join(self.dbdir, "sync", self.treename, pkg.fullname()) - mkdir(path) + path = os.path.join(self.dbdir, pkg.fullname()) + util.mkdir(path) # desc # for local db entries: name, version, desc, groups, url, license, # arch, builddate, installdate, packager, - # size, reason + # size, reason, depends, conflicts, provides # for sync entries: name, version, desc, groups, csize, md5sum, - # replaces, force + # replaces, force, depends, conflicts, provides data = [_mksection("NAME", pkg.name)] data.append(_mksection("VERSION", pkg.version)) if pkg.desc: @@ -251,6 +216,14 @@ class pmdb: data.append(_mksection("BUILDDATE", pkg.builddate)) if pkg.packager: data.append(_mksection("PACKAGER", pkg.packager)) + if pkg.depends: + data.append(_mksection("DEPENDS", pkg.depends)) + if pkg.optdepends: + data.append(_mksection("OPTDEPENDS", pkg.optdepends)) + if pkg.conflicts: + data.append(_mksection("CONFLICTS", pkg.conflicts)) + if pkg.provides: + data.append(_mksection("PROVIDES", pkg.provides)) if self.treename == "local": if pkg.url: data.append(_mksection("URL", pkg.url)) @@ -264,8 +237,6 @@ class pmdb: data.append(_mksection("FILENAME", pkg.filename())) if pkg.replaces: data.append(_mksection("REPLACES", pkg.replaces)) - if pkg.force: - data.append(_mksection("FORCE", "")) if pkg.csize: data.append(_mksection("CSIZE", pkg.csize)) if pkg.md5sum: @@ -273,9 +244,7 @@ class pmdb: if data: data.append("") filename = os.path.join(path, "desc") - mkfile(filename, "\n".join(data)) - pkg.checksum["desc"] = getmd5sum(filename) - pkg.mtime["desc"] = getmtime(filename) + util.mkfile(filename, "\n".join(data)) # files # for local entries, fields are: files, backup @@ -289,33 +258,7 @@ class pmdb: if data: data.append("") filename = os.path.join(path, "files") - mkfile(filename, "\n".join(data)) - pkg.checksum["files"] = getmd5sum(filename) - pkg.mtime["files"] = getmtime(filename) - - # depends - # for local db entries: depends, conflicts, provides - # for sync ones: depends, conflicts, provides - data = [] - if pkg.depends: - data.append(_mksection("DEPENDS", pkg.depends)) - if pkg.optdepends: - data.append(_mksection("OPTDEPENDS", pkg.optdepends)) - if pkg.conflicts: - data.append(_mksection("CONFLICTS", pkg.conflicts)) - if pkg.provides: - data.append(_mksection("PROVIDES", pkg.provides)) - #if self.treename != "local": - # if pkg.replaces: - # data.append(_mksection("REPLACES", pkg.replaces)) - # if pkg.force: - # data.append(_mksection("FORCE", "")) - if data: - data.append("") - filename = os.path.join(path, "depends") - mkfile(filename, "\n".join(data)) - pkg.checksum["depends"] = getmd5sum(filename) - pkg.mtime["depends"] = getmtime(filename) + util.mkfile(filename, "\n".join(data)) # install if self.treename == "local": @@ -325,60 +268,23 @@ class pmdb: empty = 0 if not empty: filename = os.path.join(path, "install") - mkinstallfile(filename, pkg.install) - pkg.checksum["install"] = getmd5sum(filename) - pkg.mtime["install"] = getmtime(filename) + util.mkinstallfile(filename, pkg.install) - def gensync(self, path): + def gensync(self): """ """ + if not self.dbfile: + return curdir = os.getcwd() - tmpdir = tempfile.mkdtemp() - os.chdir(tmpdir) - - for pkg in self.pkgs: - mkdescfile(pkg.fullname(), pkg) + os.chdir(self.dbdir) # Generate database archive - mkdir(path) - archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB)) - tar = tarfile.open(archive, "w:gz") - for root, dirs, files in os.walk('.'): - for d in dirs: - tar.add(os.path.join(root, d), recursive=False) - for f in files: - tar.add(os.path.join(root, f)) + tar = tarfile.open(self.dbfile, "w:gz") + for i in os.listdir("."): + tar.add(i) tar.close() os.chdir(curdir) - shutil.rmtree(tmpdir) - - def ispkgmodified(self, pkg): - """ - """ - - modified = 0 - - oldpkg = self.getpkg(pkg.name) - if not oldpkg: - return 0 - - vprint("\toldpkg.checksum : %s" % oldpkg.checksum) - vprint("\toldpkg.mtime : %s" % oldpkg.mtime) - - for key in pkg.mtime.keys(): - if key == "install" \ - and oldpkg.mtime[key] == (0, 0, 0) \ - and pkg.mtime[key] == (0, 0, 0): - continue - if oldpkg.mtime[key][1:3] != pkg.mtime[key][1:3]: - modified += 1 - - return modified - -if __name__ == "__main__": - db = pmdb("local") - print db # vim: set ts=4 sw=4 et: diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py index cc433dd0..40444829 100755 --- a/test/pacman/pmenv.py +++ b/test/pacman/pmenv.py @@ -18,12 +18,11 @@ import os import os.path -import time import pmtest -class pmenv: +class pmenv(object): """Environment object """ @@ -69,13 +68,6 @@ class pmenv: print "----------"*8 t.generate() - # Hack for mtimes consistency - for i in t.rules: - if i.rule.find("FILE_MODIFIED") != -1: - [test, arg] = i.rule.split("=") - for f in t.files: - if f.name == arg: - f.resettimes() t.run(self.pacman) diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py index ab4aa2c7..bd03a24e 100755 --- a/test/pacman/pmfile.py +++ b/test/pacman/pmfile.py @@ -18,20 +18,19 @@ import os -from util import * +import util - -class pmfile: +class pmfile(object): """File object """ def __init__(self, root, name): self.name = name self.root = root + self.filename = os.path.join(self.root, self.name) - filename = os.path.join(self.root, self.name) - self.checksum = getmd5sum(filename) - self.mtime = getmtime(filename) + self.checksum = util.getmd5sum(self.filename) + self.mtime = util.getmtime(self.filename) def __str__(self): return "%s (%s / %lu)" % (self.name, self.checksum, self.mtime) @@ -39,33 +38,17 @@ class pmfile: def ismodified(self): """ """ + checksum = util.getmd5sum(self.filename) + mtime = util.getmtime(self.filename) - retval = 0 - - filename = os.path.join(self.root, self.name) - checksum = getmd5sum(filename) - mtime = getmtime(filename) - - vprint("\tismodified(%s)" % self.name) - vprint("\t\told: %s / %s" % (self.checksum, self.mtime)) - vprint("\t\tnew: %s / %s" % (checksum, mtime)) + util.vprint("\tismodified(%s)" % self.name) + util.vprint("\t\told: %s / %s" % (self.checksum, self.mtime)) + util.vprint("\t\tnew: %s / %s" % (checksum, mtime)) if self.checksum != checksum \ or (self.mtime[1], self.mtime[2]) != (mtime[1], mtime[2]): - retval = 1 - - return retval - - def resettimes(self): - """ - """ + return 1 - filename = os.path.join(self.root, self.name) - os.utime(filename, (355, 355)) - self.mtime = getmtime(filename) - vprint("\tmtime reset (%s)" % self.name) + return 0 -if __name__ == "__main__": - f = pmfile("/tmp", "foobar") - print f # vim: set ts=4 sw=4 et: diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 1d55175e..73156ab2 100755 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -22,10 +22,9 @@ import stat import shutil import tarfile -from util import * +import util - -class pmpkg: +class pmpkg(object): """Package object. Object holding data from an ArchLinux package. @@ -48,9 +47,7 @@ class pmpkg: self.csize = 0 self.reason = 0 self.md5sum = "" # sync only - self.replaces = [] # sync only (will be moved to depends) - self.force = 0 # sync only (will be moved to depends) - # depends + self.replaces = [] self.depends = [] self.optdepends = [] self.conflicts = [] @@ -67,24 +64,11 @@ class pmpkg: "pre_upgrade": "", "post_upgrade": "" } - self.checksum = { - "desc": "", - "depends": "", - "files": "", - "install": "" - } - self.mtime = { - "desc": (0, 0, 0), - "depends": (0, 0, 0), - "files": (0, 0, 0), - "install": (0, 0, 0) - } def __str__(self): s = ["%s" % self.fullname()] s.append("description: %s" % self.desc) s.append("url: %s" % self.url) - s.append("depends: %s" % " ".join(self.depends)) s.append("files: %s" % " ".join(self.files)) s.append("reason: %d" % self.reason) return "\n".join(s) @@ -101,14 +85,7 @@ class pmpkg: Returns a string formatted as follows: "pkgname-pkgver.PKG_EXT_PKG". """ - return "%s%s" % (self.fullname(), PM_EXT_PKG) - - def install_files(self, root): - """Install files in the filesystem located under "root". - - Files are created with content generated automatically. - """ - [mkfile(os.path.join(root, f), f) for f in self.files] + return "%s%s" % (self.fullname(), util.PM_EXT_PKG) def makepkg(self, path): """Creates an ArchLinux package archive. @@ -124,8 +101,8 @@ class pmpkg: # Generate package file system for f in self.files: - mkfile(f, f) - self.size += os.stat(getfilename(f))[stat.ST_SIZE] + util.mkfile(f, f) + self.size += os.stat(util.getfilename(f))[stat.ST_SIZE] # .PKGINFO data = ["pkgname = %s" % self.name] @@ -153,14 +130,14 @@ class pmpkg: data.append("provides = %s" % i) for i in self.backup: data.append("backup = %s" % i) - mkfile(".PKGINFO", "\n".join(data)) + util.mkfile(".PKGINFO", "\n".join(data)) # .INSTALL if len(self.install.values()) > 0: - mkinstallfile(".INSTALL", self.install) + util.mkinstallfile(".INSTALL", self.install) # safely create the dir - mkdir(os.path.dirname(self.path)) + util.mkdir(os.path.dirname(self.path)) # Generate package archive tar = tarfile.open(self.path, "w:gz") @@ -171,8 +148,4 @@ class pmpkg: os.chdir(curdir) shutil.rmtree(tmpdir) - -if __name__ == "__main__": - pkg = pmpkg("dummy") - print pkg # vim: set ts=4 sw=4 et: diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index e7c9c44f..62630457 100755 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -16,10 +16,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os -from util import * -from stat import * +import stat -class pmrule: +import util + +class pmrule(object): """Rule object """ @@ -29,19 +30,20 @@ class pmrule: self.result = 0 def __str__(self): - return "rule = %s" % self.rule + if len(self.rule) <= 40: + return self.rule + return self.rule[:37] + '...' - def check(self, root, retcode, localdb, files): + def check(self, test): """ """ - success = 1 - [test, args] = self.rule.split("=") - if test[0] == "!": + [testname, args] = self.rule.split("=") + if testname[0] == "!": self.false = 1 - test = test.lstrip("!") - [kind, case] = test.split("_") + testname = testname.lstrip("!") + [kind, case] = testname.split("_") if "|" in args: [key, value] = args.split("|", 1) else: @@ -49,33 +51,32 @@ class pmrule: if kind == "PACMAN": if case == "RETCODE": - if retcode != int(key): + if test.retcode != int(key): success = 0 elif case == "OUTPUT": - logfile = os.path.join(root, LOGFILE) + logfile = os.path.join(test.root, util.LOGFILE) if not os.access(logfile, os.F_OK): print "LOGFILE not found, cannot validate 'OUTPUT' rule" success = 0 - elif not grep(os.path.join(root, LOGFILE), key): + elif not util.grep(logfile, key): success = 0 else: print "PACMAN rule '%s' not found" % case success = -1 elif kind == "PKG": + localdb = test.db["local"] newpkg = localdb.db_read(key) if not newpkg: success = 0 else: - vprint("\tnewpkg.checksum : %s" % newpkg.checksum) - vprint("\tnewpkg.mtime : %s" % newpkg.mtime) if case == "EXIST": success = 1 - elif case == "MODIFIED": - if not localdb.ispkgmodified(newpkg): - success = 0 elif case == "VERSION": if value != newpkg.version: success = 0 + elif case == "DESC": + if value != newpkg.desc: + success = 0 elif case == "GROUPS": if not value in newpkg.groups: success = 0 @@ -106,21 +107,22 @@ class pmrule: print "PKG rule '%s' not found" % case success = -1 elif kind == "FILE": - filename = os.path.join(root, key) + filename = os.path.join(test.root, key) if case == "EXIST": if not os.path.isfile(filename): success = 0 elif case == "MODIFIED": - for f in files: + for f in test.files: if f.name == key: if not f.ismodified(): success = 0 + break elif case == "MODE": if not os.path.isfile(filename): success = 0 else: - mode = os.lstat(filename)[ST_MODE] - if int(value,8) != S_IMODE(mode): + mode = os.lstat(filename)[stat.ST_MODE] + if int(value, 8) != stat.S_IMODE(mode): success = 0 elif case == "TYPE": if value == "dir": @@ -133,13 +135,13 @@ class pmrule: if not os.path.islink(filename): success = 0 elif case == "PACNEW": - if not os.path.isfile("%s%s" % (filename, PM_PACNEW)): + if not os.path.isfile("%s.pacnew" % filename): success = 0 elif case == "PACORIG": - if not os.path.isfile("%s%s" % (filename, PM_PACORIG)): + if not os.path.isfile("%s.pacorig" % filename): success = 0 elif case == "PACSAVE": - if not os.path.isfile("%s%s" % (filename, PM_PACSAVE)): + if not os.path.isfile("%s.pacsave" % filename): success = 0 else: print "FILE rule '%s' not found" % case @@ -153,7 +155,4 @@ class pmrule: self.result = success return success - -if __name__ != "__main__": - rule = pmrule("PKG_EXIST=dummy") # vim: set ts=4 sw=4 et: diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index f3026f29..958e2630 100755 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -19,16 +19,16 @@ import os import os.path import shutil +import stat import time import pmrule import pmdb import pmfile -from pmpkg import pmpkg -from util import * +import util +from util import vprint - -class pmtest: +class pmtest(object): """Test object """ @@ -47,7 +47,7 @@ class pmtest: """ """ if not treename in self.db: - self.db[treename] = pmdb.pmdb(treename, os.path.join(self.root, PM_DBPATH)) + self.db[treename] = pmdb.pmdb(treename, self.root) self.db[treename].pkgs.append(pkg) def addpkg(self, pkg): @@ -73,7 +73,7 @@ class pmtest: self.args = "" self.retcode = 0 self.db = { - "local": pmdb.pmdb("local", os.path.join(self.root, PM_DBPATH)) + "local": pmdb.pmdb("local", self.root) } self.localpkgs = [] self.filesystem = [] @@ -87,9 +87,11 @@ class pmtest: self.expectfailure = False if os.path.isfile(self.name): + # all tests expect this to be available + from pmpkg import pmpkg execfile(self.name) else: - raise IOerror("file %s does not exist!" % self.name) + raise IOError("file %s does not exist!" % self.name) def generate(self): """ @@ -104,39 +106,40 @@ class pmtest: # Create directory structure vprint(" Creating directory structure:") - dbdir = os.path.join(self.root, PM_DBPATH) - cachedir = os.path.join(self.root, PM_CACHEDIR) - syncdir = os.path.join(self.root, SYNCREPO) - tmpdir = os.path.join(self.root, TMPDIR) - logdir = os.path.join(self.root, os.path.dirname(LOGFILE)) - etcdir = os.path.join(self.root, os.path.dirname(PACCONF)) + dbdir = os.path.join(self.root, util.PM_DBPATH) + cachedir = os.path.join(self.root, util.PM_CACHEDIR) + syncdir = os.path.join(self.root, util.SYNCREPO) + tmpdir = os.path.join(self.root, util.TMPDIR) + logdir = os.path.join(self.root, os.path.dirname(util.LOGFILE)) + etcdir = os.path.join(self.root, os.path.dirname(util.PACCONF)) bindir = os.path.join(self.root, "bin") - for dir in [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir]: - if not os.path.isdir(dir): - vprint("\t%s" % dir[len(self.root)+1:]) - os.makedirs(dir, 0755) + sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir] + for sys_dir in sys_dirs: + if not os.path.isdir(sys_dir): + vprint("\t%s" % sys_dir[len(self.root)+1:]) + os.makedirs(sys_dir, 0755) # Only the dynamically linked binary is needed for fakechroot shutil.copy("/bin/sh", bindir) # Configuration file vprint(" Creating configuration file") - vprint("\t%s" % PACCONF) - mkcfgfile(PACCONF, self.root, self.option, self.db) + util.mkcfgfile(util.PACCONF, self.root, self.option, self.db) # Creating packages vprint(" Creating package archives") for pkg in self.localpkgs: - vprint("\t%s" % os.path.join(TMPDIR, pkg.filename())) + vprint("\t%s" % os.path.join(util.TMPDIR, pkg.filename())) pkg.makepkg(tmpdir) for key, value in self.db.iteritems(): - if key == "local": continue + if key == "local": + continue for pkg in value.pkgs: - vprint("\t%s" % os.path.join(PM_CACHEDIR, pkg.filename())) + vprint("\t%s" % os.path.join(util.PM_CACHEDIR, pkg.filename())) if self.cachepkgs: pkg.makepkg(cachedir) else: pkg.makepkg(os.path.join(syncdir, value.treename)) - pkg.md5sum = getmd5sum(pkg.path) + pkg.md5sum = util.getmd5sum(pkg.path) pkg.csize = os.stat(pkg.path)[stat.ST_SIZE] # Populating databases @@ -151,19 +154,30 @@ class pmtest: # Creating sync database archives vprint(" Creating sync database archives") for key, value in self.db.iteritems(): - if key == "local": continue - archive = value.treename + PM_EXT_DB - vprint("\t" + os.path.join(SYNCREPO, archive)) - value.gensync(os.path.join(syncdir, value.treename)) + if key == "local": + continue + vprint("\t" + value.treename) + value.gensync() + serverpath = os.path.join(syncdir, value.treename) + util.mkdir(serverpath) + shutil.copy(value.dbfile, serverpath) # Filesystem vprint(" Populating file system") for pkg in self.db["local"].pkgs: vprint("\tinstalling %s" % pkg.fullname()) - pkg.install_files(self.root) + for f in pkg.files: + vprint("\t%s" % f) + path = os.path.join(self.root, f) + util.mkfile(path, f) + if os.path.isfile(path): + os.utime(path, (355, 355)) for f in self.filesystem: vprint("\t%s" % f) - mkfile(os.path.join(self.root, f), f) + path = os.path.join(self.root, f) + util.mkfile(path, f) + if os.path.isfile(path): + os.utime(path, (355, 355)) # Done. vprint(" Taking a snapshot of the file system") @@ -178,7 +192,7 @@ class pmtest: """ """ - if os.path.isfile(PM_LOCK): + if os.path.isfile(util.PM_LOCK): print "\tERROR: another pacman session is on-going -- skipping" return @@ -187,45 +201,45 @@ class pmtest: cmd = [""] if os.geteuid() != 0: - fakeroot = which("fakeroot") + fakeroot = util.which("fakeroot") if not fakeroot: print "WARNING: fakeroot not found!" else: cmd.append("fakeroot") - fakechroot = which("fakechroot") + fakechroot = util.which("fakechroot") if fakechroot: cmd.append("fakechroot") if pacman["gdb"]: cmd.append("libtool execute gdb --args") if pacman["valgrind"]: - cmd.append("valgrind -q --tool=memcheck --leak-check=full --show-reachable=yes") + cmd.append("valgrind -q --tool=memcheck --leak-check=full --show-reachable=yes --suppressions=%s/valgrind.supp" % os.getcwd()) cmd.append("\"%s\" --config=\"%s\" --root=\"%s\" --dbpath=\"%s\" --cachedir=\"%s\"" \ % (pacman["bin"], - os.path.join(self.root, PACCONF), + os.path.join(self.root, util.PACCONF), self.root, - os.path.join(self.root, PM_DBPATH), - os.path.join(self.root, PM_CACHEDIR))) + os.path.join(self.root, util.PM_DBPATH), + os.path.join(self.root, util.PM_CACHEDIR))) if not pacman["manual-confirm"]: cmd.append("--noconfirm") if pacman["debug"]: cmd.append("--debug=%s" % pacman["debug"]) cmd.append("%s" % self.args) if not pacman["gdb"] and not pacman["valgrind"] and not pacman["nolog"]: - cmd.append(">\"%s\" 2>&1" % os.path.join(self.root, LOGFILE)) + cmd.append(">\"%s\" 2>&1" % os.path.join(self.root, util.LOGFILE)) vprint("\trunning: %s" % " ".join(cmd)) # Change to the tmp dir before running pacman, so that local package # archives are made available more easily. curdir = os.getcwd() - tmpdir = os.path.join(self.root, TMPDIR) + tmpdir = os.path.join(self.root, util.TMPDIR) os.chdir(tmpdir) - t0 = time.time() + time_start = time.time() self.retcode = os.system(" ".join(cmd)) - t1 = time.time() - vprint("\ttime elapsed: %ds" % (t1-t0)) + time_end = time.time() + vprint("\ttime elapsed: %ds" % (time_end - time_start)) if self.retcode == None: self.retcode = 0 @@ -235,11 +249,11 @@ class pmtest: os.chdir(curdir) # Check if the lock is still there - if os.path.isfile(PM_LOCK): - print "\tERROR: %s not removed" % PM_LOCK - os.unlink(PM_LOCK) + if os.path.isfile(util.PM_LOCK): + print "\tERROR: %s not removed" % util.PM_LOCK + os.unlink(util.PM_LOCK) # Look for a core file - if os.path.isfile(os.path.join(self.root, TMPDIR, "core")): + if os.path.isfile(os.path.join(self.root, util.TMPDIR, "core")): print "\tERROR: pacman dumped a core file" def check(self): @@ -249,7 +263,7 @@ class pmtest: print "==> Checking rules" for i in self.rules: - success = i.check(self.root, self.retcode, self.db["local"], self.files) + success = i.check(self) if success == 1: msg = " OK " self.result["success"] += 1 @@ -258,11 +272,6 @@ class pmtest: self.result["fail"] += 1 else: msg = "SKIP" - print "\t[%s] %s" % (msg, i.rule) - i.result = success - - -if __name__ == "__main__": - pass + print "\t[%s] %s" % (msg, i) # vim: set ts=4 sw=4 et: diff --git a/test/pacman/tests/database012.py b/test/pacman/tests/database012.py index a1f86980..52813ec6 100644 --- a/test/pacman/tests/database012.py +++ b/test/pacman/tests/database012.py @@ -21,11 +21,5 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_EXIST=dummy") self.addrule("PKG_VERSION=dummy|2.0-1") for f in lp.files: - self.addrule("!FILE_EXIST=%s" % f) -# TODO: I honestly think the above should NOT delete the original files, it -# should upgrade the DB entry without touching anything on the file system. -# E.g. this test should be the same as: -# pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz -#for f in lp.files: -# self.addrule("FILE_EXIST=%s" % f) + self.addrule("FILE_EXIST=%s" % f) self.addrule("!FILE_EXIST=bin/dummy2") diff --git a/test/pacman/tests/epoch001.py b/test/pacman/tests/epoch001.py new file mode 100644 index 00000000..ac6c41a6 --- /dev/null +++ b/test/pacman/tests/epoch001.py @@ -0,0 +1,12 @@ +self.description = "Sysupgrade with a sync package having higher epoch" + +sp = pmpkg("dummy", "1:1.0-1") +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "1.1-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1:1.0-1") diff --git a/test/pacman/tests/epoch002.py b/test/pacman/tests/epoch002.py new file mode 100644 index 00000000..8ca4afc6 --- /dev/null +++ b/test/pacman/tests/epoch002.py @@ -0,0 +1,12 @@ +self.description = "Sysupgrade with an epoch and ignore on same package" + +lp = pmpkg("dummy", "1.0-1") +self.addpkg2db("local", lp) + +sp = pmpkg("dummy", "1:1.0-2") +self.addpkg2db("sync", sp) + +self.args = "-Su --ignore %s" % lp.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.0-1") diff --git a/test/pacman/tests/epoch003.py b/test/pacman/tests/epoch003.py new file mode 100644 index 00000000..ac395e30 --- /dev/null +++ b/test/pacman/tests/epoch003.py @@ -0,0 +1,12 @@ +self.description = "Sysupgrade with an epoch package overriding a force package" + +sp = pmpkg("dummy", "2:1.4-1") +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "1:2.0-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|2:1.4-1") diff --git a/test/pacman/tests/epoch004.py b/test/pacman/tests/epoch004.py new file mode 100644 index 00000000..74b00c2b --- /dev/null +++ b/test/pacman/tests/epoch004.py @@ -0,0 +1,16 @@ +self.description = "Sysupgrade with same version, different epochs" + +sp = pmpkg("dummy", "2:2.0-1") +sp.files = ["bin/dummynew"] +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "1:2.0-1") +lp.files = ["bin/dummyold"] +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|2:2.0-1") +self.addrule("FILE_EXIST=bin/dummynew") +self.addrule("!FILE_EXIST=bin/dummyold") diff --git a/test/pacman/tests/epoch010.py b/test/pacman/tests/epoch010.py new file mode 100644 index 00000000..03bba273 --- /dev/null +++ b/test/pacman/tests/epoch010.py @@ -0,0 +1,12 @@ +self.description = "usbutils case study: force in new package" + +sp = pmpkg("usbutils", "1:001-1") +self.addpkg2db("sync", sp) + +lp = pmpkg("usbutils", "0.91-4") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=usbutils|1:001-1") diff --git a/test/pacman/tests/epoch011.py b/test/pacman/tests/epoch011.py new file mode 100644 index 00000000..bc5ee619 --- /dev/null +++ b/test/pacman/tests/epoch011.py @@ -0,0 +1,12 @@ +self.description = "usbutils case study: force stays, epoch now in local db" + +sp = pmpkg("usbutils", "1:002-1") +self.addpkg2db("sync", sp) + +lp = pmpkg("usbutils", "1:001-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=usbutils|1:002-1") diff --git a/test/pacman/tests/epoch012.py b/test/pacman/tests/epoch012.py new file mode 100644 index 00000000..2a7a7ac2 --- /dev/null +++ b/test/pacman/tests/epoch012.py @@ -0,0 +1,13 @@ +self.description = "usbutils case study: maintainer screws up and removes force" + +sp = pmpkg("usbutils", "003-1") +self.addpkg2db("sync", sp) + +lp = pmpkg("usbutils", "1:002-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +# remember, this is how we have to handle this- 003 will not be installed +self.addrule("PKG_VERSION=usbutils|1:002-1") diff --git a/test/pacman/tests/ignore001.py b/test/pacman/tests/ignore001.py index bb3fa59a..e9764bc9 100644 --- a/test/pacman/tests/ignore001.py +++ b/test/pacman/tests/ignore001.py @@ -9,7 +9,7 @@ self.addpkg2db("local", package2) package2up = pmpkg("package2", "2.0-1") self.addpkg2db("sync", package2up) -self.option["IgnorePkg"] = ["irrelavent"] +self.option["IgnorePkg"] = ["irrelevant"] self.args = "-Su" self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/tests/pacman005.py b/test/pacman/tests/pacman005.py new file mode 100644 index 00000000..bb21ad4f --- /dev/null +++ b/test/pacman/tests/pacman005.py @@ -0,0 +1,8 @@ +self.description = "Test invalid combination of command line options (-Qy)" + +p = pmpkg("foobar") +self.addpkg2db("local", p) + +self.args = "-Qy" + +self.addrule("PACMAN_RETCODE=1") diff --git a/test/pacman/tests/provision002.py b/test/pacman/tests/provision002.py new file mode 100644 index 00000000..49b88a18 --- /dev/null +++ b/test/pacman/tests/provision002.py @@ -0,0 +1,22 @@ +self.description = "-S provision, multiple providers, one installed" + +sp = pmpkg("pkg1", "1.0-2") +sp.provides = ["pkg-env"] +self.addpkg2db("sync", sp) + +sp = pmpkg("pkg2", "1.0-2") +sp.provides = ["pkg-env"] +self.addpkg2db("sync", sp) + +lp = pmpkg("pkg2") +lp.provides = ["pkg-env"] +self.addpkg2db("local", lp) + +self.args = "-S pkg-env" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=pkg2") +self.addrule("PKG_VERSION=pkg2|1.0-2") + +self.expectfailure = True diff --git a/test/pacman/tests/provision003.py b/test/pacman/tests/provision003.py new file mode 100644 index 00000000..9308be6e --- /dev/null +++ b/test/pacman/tests/provision003.py @@ -0,0 +1,23 @@ +self.description = "-S provision, multiple providers, one installed, different repos" + +sp = pmpkg("pkg1", "1.0-2") +sp.provides = ["pkg-env"] +self.addpkg2db("sync", sp) + +sp = pmpkg("pkg2", "1.0-2") +sp.provides = ["pkg-env"] +# this repo will be sorted second alphabetically +self.addpkg2db("sync2", sp) + +lp = pmpkg("pkg2") +lp.provides = ["pkg-env"] +self.addpkg2db("local", lp) + +self.args = "-S pkg-env" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=pkg2") +self.addrule("PKG_VERSION=pkg2|1.0-2") + +self.expectfailure = True diff --git a/test/pacman/tests/provision004.py b/test/pacman/tests/provision004.py new file mode 100644 index 00000000..696fa79f --- /dev/null +++ b/test/pacman/tests/provision004.py @@ -0,0 +1,21 @@ +self.description = "-S literal with provision of same name installed" + +sp = pmpkg("provision", "1.0-2") +sp.provides = ["literal"] +sp.conflicts = ["literal"] +self.addpkg2db("sync", sp) + +sp = pmpkg("literal", "1.0-2") +self.addpkg2db("sync2", sp) + +lp = pmpkg("provision") +lp.provides = ["literal"] +lp.conflicts = ["literal"] +self.addpkg2db("local", lp) + +self.args = "-S literal --ask=4" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=provision") +self.addrule("PKG_EXIST=literal") +self.addrule("PKG_VERSION=literal|1.0-2") diff --git a/test/pacman/tests/remove002.py b/test/pacman/tests/remove002.py new file mode 100644 index 00000000..1deffb0d --- /dev/null +++ b/test/pacman/tests/remove002.py @@ -0,0 +1,12 @@ +self.description = "Remove a package with several files" + +p = pmpkg("foo") +p.files = ["usr/share/file_%d" % n for n in range(1000)] +self.addpkg2db("local", p) + +self.args = "-R %s" % p.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=foo") +self.addrule("!FILE_EXIST=usr/share/file_0") +self.addrule("!FILE_EXIST=usr/share/file_999") diff --git a/test/pacman/tests/scriptlet001.py b/test/pacman/tests/scriptlet001.py index ff7fcd20..1cf9053b 100644 --- a/test/pacman/tests/scriptlet001.py +++ b/test/pacman/tests/scriptlet001.py @@ -15,6 +15,6 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_OUTPUT=" + pre) self.addrule("PACMAN_OUTPUT=" + post) -fakechroot = which("fakechroot") +fakechroot = util.which("fakechroot") if not fakechroot: self.expectfailure = True diff --git a/test/pacman/tests/scriptlet002.py b/test/pacman/tests/scriptlet002.py index cc316a10..59f60427 100644 --- a/test/pacman/tests/scriptlet002.py +++ b/test/pacman/tests/scriptlet002.py @@ -15,6 +15,6 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PACMAN_OUTPUT=" + pre) self.addrule("PACMAN_OUTPUT=" + post) -fakechroot = which("fakechroot") +fakechroot = util.which("fakechroot") if not fakechroot: self.expectfailure = True diff --git a/test/pacman/tests/smoke002.py b/test/pacman/tests/smoke002.py new file mode 100644 index 00000000..44f2d0ec --- /dev/null +++ b/test/pacman/tests/smoke002.py @@ -0,0 +1,19 @@ +self.description = "Install packages with huge descriptions" + +p1 = pmpkg("pkg1") +p1.desc = 'A' * 500 * 1024 +self.addpkg(p1) + +p2 = pmpkg("pkg2") +p2.desc = 'A' * 600 * 1024 +self.addpkg(p2) + +self.args = "-U %s %s" % (p1.filename(), p2.filename()) + +# Note that the current cutoff on line length is 512K, so the first package +# will succeed while the second one will fail to record the description. +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("PKG_DESC=pkg1|%s" % p1.desc) +self.addrule("PKG_EXIST=pkg1") +self.addrule("!PKG_DESC=pkg1|%s" % p2.desc) diff --git a/test/pacman/tests/sync023.py b/test/pacman/tests/sync023.py index 8233ab73..3644c9de 100644 --- a/test/pacman/tests/sync023.py +++ b/test/pacman/tests/sync023.py @@ -15,7 +15,8 @@ for p in lp1, lp2, lp3, sp1, sp2, sp3, newp1: for p in lp1, lp2, lp3: self.addpkg2db("local", p) -self.addpkg2db("testing", newp1); +# repos are sorted in alpha order +self.addpkg2db("atesting", newp1); for p in sp1, sp2, sp3: self.addpkg2db("sync", p); diff --git a/test/pacman/tests/sync024.py b/test/pacman/tests/sync024.py new file mode 100644 index 00000000..6d1192f0 --- /dev/null +++ b/test/pacman/tests/sync024.py @@ -0,0 +1,23 @@ +self.description = "Install a group from a sync db repo/group syntax" + +sp1 = pmpkg("pkg1") +sp2 = pmpkg("pkg2") +sp3 = pmpkg("pkg3") +newp1 = pmpkg("pkg1", "1.2-1") + +for p in sp1, sp2, sp3, newp1: + setattr(p, "groups", ["grp"]) + +self.addpkg2db("testing", newp1); + +for p in sp1, sp2, sp3: + self.addpkg2db("sync", p); + +self.args = "-S testing/grp" + +self.addrule("PACMAN_RETCODE=0") +for p in sp2, sp3: + self.addrule("!PKG_EXIST=%s" % p.name) +self.addrule("PKG_EXIST=%s" % newp1.name) +# The newer version should still be installed +self.addrule("PKG_VERSION=pkg1|1.2-1") diff --git a/test/pacman/tests/sync101.py b/test/pacman/tests/sync101.py index 5d39ecb9..a4bde3e2 100644 --- a/test/pacman/tests/sync101.py +++ b/test/pacman/tests/sync101.py @@ -1,7 +1,9 @@ self.description = "Sysupgrade with same version for local and sync packages" sp = pmpkg("dummy") +sp.files = ["bin/foo"] lp = pmpkg("dummy") +lp.files = ["bin/foo"] self.addpkg2db("sync", sp) self.addpkg2db("local", lp) @@ -9,4 +11,5 @@ self.addpkg2db("local", lp) self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("!PKG_MODIFIED=dummy") +self.addrule("PKG_VERSION=dummy|1.0-1") +self.addrule("!FILE_MODIFIED=bin/foo") diff --git a/test/pacman/tests/sync102.py b/test/pacman/tests/sync102.py index 40a7ec99..bbd72147 100644 --- a/test/pacman/tests/sync102.py +++ b/test/pacman/tests/sync102.py @@ -1,7 +1,9 @@ self.description = "Sysupgrade with a newer local package" sp = pmpkg("dummy", "0.9-1") +sp.files = ["bin/foo", "bin/bar"] lp = pmpkg("dummy") +lp.files = ["bin/foo", "bin/baz"] self.addpkg2db("sync", sp) self.addpkg2db("local", lp) @@ -9,4 +11,7 @@ self.addpkg2db("local", lp) self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("!PKG_MODIFIED=dummy") +self.addrule("PKG_VERSION=dummy|1.0-1") +self.addrule("FILE_EXIST=bin/foo") +self.addrule("FILE_EXIST=bin/baz") +self.addrule("!FILE_EXIST=bin/bar") diff --git a/test/pacman/tests/sync103.py b/test/pacman/tests/sync103.py index 15e7c8e1..b740294b 100644 --- a/test/pacman/tests/sync103.py +++ b/test/pacman/tests/sync103.py @@ -9,5 +9,5 @@ self.addpkg2db("local", lp) self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("!PKG_MODIFIED=lpkg") +self.addrule("PKG_EXIST=lpkg") self.addrule("!PKG_EXIST=spkg") diff --git a/test/pacman/tests/sync120.py b/test/pacman/tests/sync120.py index 994e440e..d1ace800 100644 --- a/test/pacman/tests/sync120.py +++ b/test/pacman/tests/sync120.py @@ -18,4 +18,4 @@ self.args = "-Su" self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_VERSION=pkg1|1.0-2") -self.addrule("!PKG_MODIFIED=pkg2") +self.addrule("PKG_VERSION=pkg2|1.0-1") diff --git a/test/pacman/tests/sync136.py b/test/pacman/tests/sync136.py index 58d08eb0..b31aae2c 100644 --- a/test/pacman/tests/sync136.py +++ b/test/pacman/tests/sync136.py @@ -1,7 +1,6 @@ self.description = "Sysupgrade with a sync package forcing a downgrade" -sp = pmpkg("dummy", "1.0-1") -sp.force = 1 +sp = pmpkg("dummy", "1:1.0-1") self.addpkg2db("sync", sp) @@ -12,4 +11,4 @@ self.addpkg2db("local", lp) self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_VERSION=dummy|1.0-1") +self.addrule("PKG_VERSION=dummy|1:1.0-1") diff --git a/test/pacman/tests/sync137.py b/test/pacman/tests/sync137.py index 94caca70..d76ac49d 100644 --- a/test/pacman/tests/sync137.py +++ b/test/pacman/tests/sync137.py @@ -4,8 +4,7 @@ lp = pmpkg("dummy", "1.0-1") self.addpkg2db("local", lp) -sp = pmpkg("dummy", "1.0-2") -sp.force = 1 +sp = pmpkg("dummy", "1:1.0-2") self.addpkg2db("sync", sp) self.args = "-Su --ignore %s" % lp.name diff --git a/test/pacman/tests/sync138.py b/test/pacman/tests/sync138.py index e67c4f46..bef07683 100644 --- a/test/pacman/tests/sync138.py +++ b/test/pacman/tests/sync138.py @@ -19,4 +19,4 @@ self.args = "-Su" self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_VERSION=pkg1|1.0-2") -self.addrule("!PKG_MODIFIED=pkg2") +self.addrule("PKG_VERSION=pkg2|1.0-1") diff --git a/test/pacman/tests/sync407.py b/test/pacman/tests/sync407.py new file mode 100644 index 00000000..a2d30299 --- /dev/null +++ b/test/pacman/tests/sync407.py @@ -0,0 +1,38 @@ +self.description = "FS#7524, versioned dependency resolving with conflict" + +sp1 = pmpkg("compiz-git", "20070626-1") +sp1.depends = ["cairo"] +sp1.groups = ["compiz-fusion"] +self.addpkg2db("sync", sp1) + +sp2 = pmpkg("ccsm-git", "20070626-1") +sp2.depends = ["pygtk"] +sp2.groups = ["compiz-fusion"] +self.addpkg2db("sync", sp2) + +sp3 = pmpkg("pygtk", "2.22.0-1") +sp3.depends = ["pycairo"] +self.addpkg2db("sync", sp3) + +sp4 = pmpkg("pycairo", "1.4.0-2") +sp4.depends = ["cairo>=1.4.6-2"] +self.addpkg2db("sync", sp4) + +sp5 = pmpkg("cairo", "1.4.6-2") +self.addpkg2db("sync", sp5) + +lp1 = pmpkg("cairo-lcd", "1.4.6-1") +lp1.provides = "cairo" +lp1.conflicts = ["cairo"] +self.addpkg2db("local", lp1) + +self.args = "-S compiz-fusion" + +self.addrule("PACMAN_RETCODE=1") +self.addrule("PKG_EXIST=cairo-lcd") +self.addrule("PKG_VERSION=cairo-lcd|1.4.6-1") +self.addrule("!PKG_EXIST=cairo") +self.addrule("!PKG_EXIST=compiz-git") +self.addrule("!PKG_EXIST=ccsm-git") +self.addrule("!PKG_EXIST=pygtk") +self.addrule("!PKG_EXIST=pycairo") diff --git a/test/pacman/tests/sync898.py b/test/pacman/tests/sync898.py index af16801d..8fd59f19 100644 --- a/test/pacman/tests/sync898.py +++ b/test/pacman/tests/sync898.py @@ -14,5 +14,5 @@ self.addpkg2db("local", lp1) self.args = "-S %s" % " ".join([p.name for p in sp1, sp2]) self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_MODIFIED=pkg1") +self.addrule("PKG_VERSION=pkg1|1.0-2") self.addrule("!PKG_EXIST=pkg2") diff --git a/test/pacman/tests/upgrade001.py b/test/pacman/tests/upgrade001.py index 2a9538e0..2e85ce67 100644 --- a/test/pacman/tests/upgrade001.py +++ b/test/pacman/tests/upgrade001.py @@ -12,7 +12,6 @@ self.addpkg(p) self.args = "-U %s" % p.filename() -self.addrule("PKG_MODIFIED=dummy") self.addrule("PKG_VERSION=dummy|1.0-2") for f in lp.files: self.addrule("FILE_MODIFIED=%s" % f) diff --git a/test/pacman/tests/upgrade002.py b/test/pacman/tests/upgrade002.py index d561d894..c7706efe 100644 --- a/test/pacman/tests/upgrade002.py +++ b/test/pacman/tests/upgrade002.py @@ -12,7 +12,6 @@ self.addpkg(p) self.args = "-U %s" % p.filename() -self.addrule("PKG_MODIFIED=dummy") self.addrule("PKG_VERSION=dummy|1.0-1") for f in lp.files: self.addrule("FILE_MODIFIED=%s" % f) diff --git a/test/pacman/tests/upgrade003.py b/test/pacman/tests/upgrade003.py index a67a2653..284c9f35 100644 --- a/test/pacman/tests/upgrade003.py +++ b/test/pacman/tests/upgrade003.py @@ -12,7 +12,6 @@ self.addpkg(p) self.args = "-U %s" % p.filename() -self.addrule("PKG_MODIFIED=dummy") self.addrule("PKG_VERSION=dummy|1.0-1") for f in lp.files: self.addrule("FILE_MODIFIED=%s" % f) diff --git a/test/pacman/tests/upgrade006.py b/test/pacman/tests/upgrade006.py new file mode 100644 index 00000000..5e5173b5 --- /dev/null +++ b/test/pacman/tests/upgrade006.py @@ -0,0 +1,18 @@ +self.description = "Upgrade a package with several files" + +lp = pmpkg("dummy") +lp.files = ["usr/share/file_%d" % n for n in range(250, 750)] +self.addpkg2db("local", lp) + +p = pmpkg("dummy", "1.1-1") +p.files = ["usr/share/file_%d" % n for n in range(600, 1000)] +self.addpkg(p) + +self.args = "-U %s" % p.filename() + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.1-1") +self.addrule("!FILE_EXIST=usr/share/file_250") +self.addrule("!FILE_EXIST=usr/share/file_599") +self.addrule("FILE_EXIST=usr/share/file_600") +self.addrule("FILE_EXIST=usr/share/file_999") diff --git a/test/pacman/util.py b/test/pacman/util.py index e01a3b8f..359b42bf 100755 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -16,7 +16,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import sys import os import hashlib import stat @@ -25,13 +24,10 @@ import stat # ALPM PM_ROOT = "/" PM_DBPATH = "var/lib/pacman" +PM_SYNCDBPATH = "var/lib/pacman/sync" PM_LOCK = "var/lib/pacman/db.lck" PM_CACHEDIR = "var/cache/pacman/pkg" PM_EXT_PKG = ".pkg.tar.gz" -PM_EXT_DB = ".db.tar.gz" -PM_PACNEW = ".pacnew" -PM_PACORIG = ".pacorig" -PM_PACSAVE = ".pacsave" # Pacman PACCONF = "etc/pacman.conf" @@ -89,11 +85,8 @@ def mkfile(name, data = ""): path = filename else: path = os.path.dirname(filename) - try: - if path and not os.path.isdir(path): - os.makedirs(path, 0755) - except: - error("mkfile: could not create directory hierarchy '%s'" % path) + if path and not os.path.isdir(path): + os.makedirs(path, 0755) if isdir: return @@ -113,52 +106,6 @@ def mkfile(name, data = ""): if setperms: os.chmod(filename, int(perms, 8)) -def mkdescfile(filename, pkg): - """ - """ - - data = [] - - # desc - #data.append("pkgname = %s" % pkg.name) - #data.append("pkgver = %s" % pkg.version) - if pkg.desc: - data.append("pkgdesc = %s" % pkg.desc) - if pkg.url: - data.append("url = %s" % pkg.url) - if pkg.builddate: - data.append("builddate = %s" % pkg.builddate) - if pkg.packager: - data.append("packager = %s" % pkg.packager) - if pkg.size: - data.append("size = %s" % pkg.size) - if pkg.arch: - data.append("arch = %s" % pkg.arch) - for i in pkg.groups: - data.append("group = %s" % i) - for i in pkg.license: - data.append("license = %s" % i) - if pkg.md5sum: - data.append("md5sum = %s" % pkg.md5sum) - - # depends - for i in pkg.replaces: - data.append("replaces = %s" % i) - for i in pkg.depends: - data.append("depend = %s" % i) - for i in pkg.optdepends: - data.append("optdepend = %s" % i) - for i in pkg.conflicts: - data.append("conflict = %s" % i) - for i in pkg.provides: - data.append("provides = %s" % i) - for i in pkg.backup: - data.append("backup = %s" % i) - if pkg.force: - data.append("force = 1") - - mkfile(filename, "\n".join(data)) - def mkinstallfile(filename, install): """ """ @@ -178,8 +125,11 @@ def mkcfgfile(filename, root, option, db): data.extend(["%s = %s" % (key, j) for j in value]) # Repositories - for key, value in db.iteritems(): + # sort by repo name so tests can predict repo order, rather than be + # subjects to the whims of python dict() ordering + for key in sorted(db.iterkeys()): if key != "local": + value = db[key] data.append("[%s]\n" \ "Server = file://%s" \ % (value.treename, @@ -203,21 +153,19 @@ def getmd5sum(filename): fd = open(filename, "rb") checksum = hashlib.md5() while 1: - block = fd.read(1048576) + block = fd.read(32 * 1024) if not block: break checksum.update(block) fd.close() - digest = checksum.digest() - return "%02x"*len(digest) % tuple(map(ord, digest)) + return checksum.hexdigest() def mkmd5sum(data): """ """ checksum = hashlib.md5() checksum.update("%s\n" % data) - digest = checksum.digest() - return "%02x"*len(digest) % tuple(map(ord, digest)) + return checksum.hexdigest() # @@ -233,12 +181,6 @@ def getmtime(filename): st = os.stat(filename) return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME] -def diffmtime(mt1, mt2): - """ORE: TBD - """ - return not mt1 == mt2 - - # # Miscellaneous # @@ -259,18 +201,11 @@ def grep(filename, pattern): return True return False -def mkdir(dir): - if os.path.isdir(dir): +def mkdir(path): + if os.path.isdir(path): 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 - vprint("making dir %s" % thisdir) - if thisdir: os.mkdir(dir) - -if __name__ == "__main__": - pass + elif os.path.isfile(path): + raise OSError("'%s' already exists and is not a directory" % path) + os.makedirs(path, 0755) # vim: set ts=4 sw=4 et: diff --git a/test/util/vercmptest.sh b/test/util/vercmptest.sh index fca06578..a9ed3b2a 100755 --- a/test/util/vercmptest.sh +++ b/test/util/vercmptest.sh @@ -118,6 +118,25 @@ runtest 1.5.1 1.5.b 1 runtest 1.5.b-1 1.5.b 0 runtest 1.5-1 1.5.b -1 +# epoch included version comparisons +runtest 0:1.0 0:1.0 0 +runtest 0:1.0 0:1.1 -1 +runtest 1:1.0 0:1.0 1 +runtest 1:1.0 0:1.1 1 +runtest 1:1.0 2:1.1 -1 + +# epoch + sometimes present pkgrel +runtest 1:1.0 0:1.0-1 1 +runtest 1:1.0-1 0:1.1-1 1 + +# epoch included on one version +runtest 0:1.0 1.0 0 +runtest 0:1.0 1.1 -1 +runtest 0:1.1 1.0 1 +runtest 1:1.0 1.0 1 +runtest 1:1.0 1.1 1 +runtest 1:1.1 1.1 1 + #END TESTS echo |