[pacman-dev] [PATCH 3/3] Update pactest suite for change in db structure

Allan McRae allan at archlinux.org
Sat Oct 30 02:03:45 EDT 2010


Merging desc and depends files in sync and local db.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 test/pacman/pmdb.py  |   62 ++++++++++++++-----------------------------------
 test/pacman/pmpkg.py |    4 ---
 2 files changed, 18 insertions(+), 48 deletions(-)

diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index af5525c..7f79819 100755
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -163,6 +163,14 @@ def db_read(self, name):
             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)
@@ -189,29 +197,6 @@ def db_read(self, name):
         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)
-        fd.close()
-        pkg.checksum["depends"] = getmd5sum(filename)
-        pkg.mtime["depends"] = getmtime(filename)
-
         # install
         filename = os.path.join(path, "install")
         if os.path.isfile(filename):
@@ -233,9 +218,9 @@ def db_write(self, pkg):
         # 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:
@@ -250,6 +235,14 @@ def db_write(self, pkg):
             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))
@@ -297,25 +290,6 @@ def db_write(self, pkg):
             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 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
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index aaee28b..9ce0978 100755
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -51,7 +51,6 @@ def __init__(self, name, version = "1.0-1"):
         self.replaces = []
         self.force = 0
         self.epoch = 0
-        # depends
         self.depends = []
         self.optdepends = []
         self.conflicts = []
@@ -70,13 +69,11 @@ def __init__(self, name, version = "1.0-1"):
         }
         self.checksum = {
             "desc": "",
-            "depends": "",
             "files": "",
             "install": ""
         }
         self.mtime = {
             "desc": (0, 0, 0),
-            "depends": (0, 0, 0),
             "files": (0, 0, 0),
             "install": (0, 0, 0)
         }
@@ -85,7 +82,6 @@ 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)
-- 
1.7.3.2



More information about the pacman-dev mailing list