Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/pacman/pmdb.py55
-rwxr-xr-xtest/pacman/pmpkg.py5
-rwxr-xr-xtest/pacman/pmtest.py14
-rw-r--r--test/pacman/tests/ignore001.py2
-rw-r--r--test/pacman/tests/ignore007.py23
-rw-r--r--test/pacman/tests/pacman005.py8
-rw-r--r--test/pacman/tests/sync024.py23
-rw-r--r--test/pacman/tests/sync140.py13
-rw-r--r--test/pacman/tests/sync141.py13
-rw-r--r--test/pacman/tests/sync142.py14
-rw-r--r--test/pacman/tests/sync143.py18
-rwxr-xr-xtest/pacman/util.py6
12 files changed, 151 insertions, 43 deletions
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index 8cb1b832..af5525cf 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,6 +158,8 @@ 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
@@ -202,12 +208,6 @@ class pmdb:
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)
@@ -227,10 +227,7 @@ 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
@@ -266,6 +263,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:
@@ -307,11 +309,6 @@ class pmdb:
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")
@@ -331,30 +328,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..aaee28bc 100755
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -48,8 +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)
+ self.replaces = []
+ self.force = 0
+ self.epoch = 0
# depends
self.depends = []
self.optdepends = []
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index f3026f29..b7af5809 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),
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/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")