[Secure-testing-commits] r5668 - lib/python

Florian Weimer fw at alioth.debian.org
Wed Apr 18 20:00:39 UTC 2007


Author: fw
Date: 2007-04-18 20:00:39 +0000 (Wed, 18 Apr 2007)
New Revision: 5668

Modified:
   lib/python/security_db.py
Log:
Use a separate file, data/packages/removed-packages, to list source
packages which are no longer present in the archive.

* lib/python/security_db.py
  (DB.readBugs.do_parse): Ignore duplicate packages.
  (DB.readBugs): Treat removed-packages as yet another input file.
  (DB.readRemovedPackages): Resurrect method.


Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py	2007-04-18 19:40:15 UTC (rev 5667)
+++ lib/python/security_db.py	2007-04-18 20:00:39 UTC (rev 5668)
@@ -719,7 +719,7 @@
                 raise InsertError(errors)
 
             cursor.executemany(
-                "INSERT OR REPLACE INTO removed_packages (name) VALUES (?)",
+                "INSERT OR IGNORE INTO removed_packages (name) VALUES (?)",
                 map(lambda x: (x,), source.removed_packages.keys()))
 
         def has_changed(filename):
@@ -733,9 +733,11 @@
                     return True
             return True
 
+        source_removed_packages = '/packages/removed-packages'
         sources = ((bugs.CVEFile, '/CVE/list'),
                    (bugs.DSAFile, '/DSA/list'),
-                   (bugs.DTSAFile, '/DTSA/list'))
+                   (bugs.DTSAFile, '/DTSA/list'),
+                   (None, source_removed_packages))
 
         unchanged = True
         for (_, name) in sources:
@@ -759,8 +761,14 @@
                 VALUES (?, ?)""", (current_print, filename))
 
         for (cls, name) in sources:
+            if cls is None:
+                continue
             read_one(cls(path + name))
 
+        if self.verbose:
+            print "  update removed packages"
+        self.readRemovedPackages(cursor, path + source_removed_packages)
+
         errors = []
 
         if self.verbose:
@@ -1861,6 +1869,32 @@
             ORDER BY bug""", (bug, bug, bug, bug)):
             yield bug_name
 
+    def readRemovedPackages(self, cursor, filename):
+        """Reads a file of removed packages and stores it in the database.
+        The original contents of the removed_packages table is preserved."""
+
+        f = file(filename)
+
+        re_package = re.compile(r'^\s*([a-z0-9]\S+)\s*$')
+
+        # Not very good error reporting, but changes to that file are
+        # rare.
+
+        def gen():
+            for line in f:
+                if line == '':
+                    break
+                if line[0] == '#' or line == '\n':
+                    continue
+                match = re_package.match(line)
+                if match:
+                    yield match.groups()
+                else:
+                    raise ValueError, "not a package: " + `line`
+
+        cursor.executemany(
+            "INSERT OR IGNORE INTO removed_packages (name) VALUES (?)", gen())
+
     def getUnknownPackages(self, cursor):
         """Returns a generator for a list of unknown packages.
         Each entry has the form (PACKAGE, BUG-LIST)."""




More information about the Secure-testing-commits mailing list