index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | test/pacman/pmdb.py | 117 | ||||
-rwxr-xr-x | test/pacman/pmpkg.py | 9 | ||||
-rwxr-xr-x | test/pacman/pmrule.py | 10 | ||||
-rwxr-xr-x | test/pacman/pmtest.py | 21 | ||||
-rw-r--r-- | test/pacman/tests/database012.py | 8 | ||||
-rw-r--r-- | test/pacman/tests/ignore001.py | 2 | ||||
-rw-r--r-- | test/pacman/tests/ignore007.py | 23 | ||||
-rw-r--r-- | test/pacman/tests/pacman005.py | 8 | ||||
-rw-r--r-- | test/pacman/tests/smoke002.py | 19 | ||||
-rw-r--r-- | test/pacman/tests/sync024.py | 23 | ||||
-rw-r--r-- | test/pacman/tests/sync140.py | 13 | ||||
-rw-r--r-- | test/pacman/tests/sync141.py | 13 | ||||
-rw-r--r-- | test/pacman/tests/sync142.py | 14 | ||||
-rw-r--r-- | test/pacman/tests/sync143.py | 18 | ||||
-rwxr-xr-x | test/pacman/util.py | 6 |
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index 8cb1b832..7f798192 100755 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -81,11 +81,15 @@ class pmdb: """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, PM_DBPATH, treename) + else: + self.dbdir = os.path.join(root, PM_SYNCDBPATH, treename) + self.dbfile = os.path.join(root, PM_SYNCDBPATH, treename + ".db") def __str__(self): return "%s" % self.treename @@ -101,7 +105,7 @@ class pmdb: """ """ - path = os.path.join(self.dbdir, self.treename) + path = self.dbdir if not os.path.isdir(path): return None @@ -154,9 +158,19 @@ class pmdb: pkg.md5sum = fd.readline().strip("\n") elif line == "%REPLACES%": pkg.replaces = _getsection(fd) + elif line == "%EPOCH%": + pkg.epoch = int(fd.readline().strip("\n")) 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) @@ -183,35 +197,6 @@ class pmdb: 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): @@ -227,18 +212,15 @@ class pmdb: """ """ - 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()) + path = os.path.join(self.dbdir, pkg.fullname()) 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: @@ -253,6 +235,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)) @@ -266,6 +256,11 @@ class pmdb: data.append(_mksection("FILENAME", pkg.filename())) if pkg.replaces: data.append(_mksection("REPLACES", pkg.replaces)) + if pkg.epoch: + data.append(_mksection("EPOCH", pkg.epoch)) + # for backward compatibility + if not pkg.force: + data.append(_mksection("FORCE", "")) if pkg.force: data.append(_mksection("FORCE", "")) if pkg.csize: @@ -295,30 +290,6 @@ class pmdb: 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) - # install if self.treename == "local": empty = 1 @@ -331,30 +302,22 @@ class pmdb: pkg.checksum["install"] = getmd5sum(filename) pkg.mtime["install"] = getmtime(filename) - 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): """ diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 1d55175e..9ce09783 100755 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -48,9 +48,9 @@ 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.force = 0 + self.epoch = 0 self.depends = [] self.optdepends = [] self.conflicts = [] @@ -69,13 +69,11 @@ class pmpkg: } self.checksum = { "desc": "", - "depends": "", "files": "", "install": "" } self.mtime = { "desc": (0, 0, 0), - "depends": (0, 0, 0), "files": (0, 0, 0), "install": (0, 0, 0) } @@ -84,7 +82,6 @@ class pmpkg: 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) diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index e7c9c44f..89ae3f49 100755 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -29,7 +29,9 @@ 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): """ @@ -76,6 +78,9 @@ class pmrule: 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 @@ -153,7 +158,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..c70e41ae 100755 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -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 = [] @@ -152,9 +152,11 @@ class pmtest: 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)) + vprint("\t" + value.treename) + value.gensync() + serverpath = os.path.join(syncdir, value.treename) + mkdir(serverpath) + shutil.copy(value.dbfile, serverpath) # Filesystem vprint(" Populating file system") @@ -200,7 +202,7 @@ class pmtest: 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), @@ -258,11 +260,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/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/ignore007.py b/test/pacman/tests/ignore007.py new file mode 100644 index 00000000..e4be40a1 --- /dev/null +++ b/test/pacman/tests/ignore007.py @@ -0,0 +1,23 @@ +self.description = "Sync group with ignored packages" + +pkg1 = pmpkg("package1") +pkg1.groups = ["grp"] +self.addpkg2db("sync", pkg1) + +pkg2 = pmpkg("package2") +pkg2.groups = ["grp"] +self.addpkg2db("sync", pkg2) + +pkg3 = pmpkg("package3") +pkg3.groups = ["grp"] +self.addpkg2db("sync", pkg3) + +self.option["IgnorePkg"] = ["package1"] +self.args = "--ask=1 -S grp" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=%s" % pkg1.name) +self.addrule("PKG_EXIST=%s" % pkg2.name) +self.addrule("PACMAN_OUTPUT=IgnorePkg") + +self.expectfailure = True 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/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/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/sync140.py b/test/pacman/tests/sync140.py new file mode 100644 index 00000000..b7ec9fcf --- /dev/null +++ b/test/pacman/tests/sync140.py @@ -0,0 +1,13 @@ +self.description = "Sysupgrade with a sync package having higher epoch" + +sp = pmpkg("dummy", "1.0-1") +sp.epoch = 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.0-1") diff --git a/test/pacman/tests/sync141.py b/test/pacman/tests/sync141.py new file mode 100644 index 00000000..dac81f76 --- /dev/null +++ b/test/pacman/tests/sync141.py @@ -0,0 +1,13 @@ +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.0-2") +sp.epoch = 1 +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/sync142.py b/test/pacman/tests/sync142.py new file mode 100644 index 00000000..83766bb8 --- /dev/null +++ b/test/pacman/tests/sync142.py @@ -0,0 +1,14 @@ +self.description = "Sysupgrade with an epoch package overriding a force package" + +sp = pmpkg("dummy", "1.4-1") +sp.epoch = 2 +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "2.0-1") +lp.force = 1 +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.4-1") diff --git a/test/pacman/tests/sync143.py b/test/pacman/tests/sync143.py new file mode 100644 index 00000000..37353a84 --- /dev/null +++ b/test/pacman/tests/sync143.py @@ -0,0 +1,18 @@ +self.description = "Sysupgrade with same version, different epochs" + +sp = pmpkg("dummy", "2.0-1") +sp.files = ["bin/dummynew"] +sp.epoch = 2 +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "2.0-1") +lp.files = ["bin/dummyold"] +lp.force = 1 +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|2.0-1") +self.addrule("FILE_EXIST=bin/dummynew") +self.addrule("!FILE_EXIST=bin/dummyold") diff --git a/test/pacman/util.py b/test/pacman/util.py index e01a3b8f..0044f21b 100755 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -25,10 +25,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" @@ -154,6 +154,10 @@ def mkdescfile(filename, pkg): data.append("provides = %s" % i) for i in pkg.backup: data.append("backup = %s" % i) + if pkg.epoch: + data.append("epoch = %d" % pkg.epoch) + if not pkg.force: + data.append("force = 1") if pkg.force: data.append("force = 1") |