summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2005-09-22 12:00:31 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2005-09-22 12:00:31 +0000
commit36373fbd871561c532cc683617304e803795c6b8 (patch)
tree2d725176a2e7d10a9728a6970a55ca57849d1df7
parent97f9f5825f66bb03df54584829c4b193c70dee81 (diff)
lib/python/security_db.py (DB.initSchema):
Add removed_packages table. (DB.readRemovedPackages, DB.getUnknownPackages): New. bin/update-db: Read removed packages. data/packages/removed-packages: New file. git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@2088 e39458fd-73e7-0310-bf30-c45bca0a0e42
-rwxr-xr-xbin/update-db4
-rw-r--r--data/packages/removed-packages4
-rw-r--r--lib/python/security_db.py53
3 files changed, 60 insertions, 1 deletions
diff --git a/bin/update-db b/bin/update-db
index 0c732cd4cb..b990ce8430 100755
--- a/bin/update-db
+++ b/bin/update-db
@@ -57,6 +57,10 @@ if new_file:
db.commit(cursor)
cursor = db.writeTxn()
+# Removed packages
+
+db.readRemovedPackages(cursor, 'data/packages/removed-packages')
+
# Calculate vulnerability information.
warnings = db.calculateVulnerabilities(cursor)
diff --git a/data/packages/removed-packages b/data/packages/removed-packages
new file mode 100644
index 0000000000..1b648596bd
--- /dev/null
+++ b/data/packages/removed-packages
@@ -0,0 +1,4 @@
+# This file lists packages which are no longer present in the Debian
+# archive, one per line.
+
+openwebmail
diff --git a/lib/python/security_db.py b/lib/python/security_db.py
index c1ead1321a..7ec83dd348 100644
--- a/lib/python/security_db.py
+++ b/lib/python/security_db.py
@@ -93,7 +93,7 @@ class DB:
self.db = apsw.Connection(name)
self.verbose = verbose
- self.schema_version = 11
+ self.schema_version = 12
self._initFunctions()
c = self.cursor()
@@ -262,6 +262,9 @@ class DB:
ON binary_package_status(package)""")
cursor.execute(
+ "CREATE TABLE removed_packages (name TEXT NOT NULL PRIMARY KEY)")
+
+ cursor.execute(
"""CREATE VIEW testing_status AS
SELECT DISTINCT sp.name AS package, st.bug_name AS bug,
sp.archive AS section, st.urgency AS urgency,
@@ -1362,6 +1365,54 @@ class DB:
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."""
+
+ 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.execute("DELETE FROM removed_packages")
+ cursor.executemany("INSERT 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)."""
+
+ old_package = ''
+ bugs = []
+ for (package, bug_name) in cursor.execute(
+ """SELECT DISTINCT package, bug_name
+ FROM package_notes WHERE package_kind = 'unknown'
+ AND NOT EXISTS (SELECT * FROM removed_packages
+ WHERE name = package)
+ ORDER BY package, bug_name"""):
+ if package <> old_package:
+ if old_package:
+ yield (old_package, bugs)
+ old_package = package
+ bugs = []
+ bugs.append(bug_name)
+ if old_package:
+ yield (old_package, bugs)
+
def check(self, cursor=None):
"""Runs a simple consistency check and prints the results."""

© 2014-2024 Faster IT GmbH | imprint | privacy policy