summaryrefslogtreecommitdiffstats
path: root/bin/update-db
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2005-09-15 10:11:44 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2005-09-15 10:11:44 +0000
commit337f980d8e801258d8ca74d127aa8188af3679df (patch)
treedc569d699b67dfac8d23e80882f189419c9d56d0 /bin/update-db
parent442da033445af42da75fb4797f54615438a5703c (diff)
Implement bin/update-db, to update the database with a single command.
Most processing is skipped if no input files have been modified. lib/python/security_db.py (SchemaMismatch): New exception. (DB): Handle schema versioning. (DB.initSchema): Add subrelease column to source_packages and binary_packages. Set user_version. Remove stray commit. (DB._parseFile): Return information to the caller if the file is unchanged. (DB.readPackages): Move deletion code to callees. (DB._readSourcePackages, DB._readBinaryPackages): Implement incremental updates. Add subrelease. Need to invoke _clearVersions if any changes are made. (DB.deleteBugs, DB.finishBugs): Moved into readBugs. (DB.insertBugs): Rename ... (DB.readBugs): ... to this one. Implement incremental updates. Invoke _clearVersions if necessary. (DB._clearVersions): Add. (DB._updateVersions): Skip processing if _clearVersions has not been invoked. (DB.getVersion, DB.releaseContainsPackage, DB._synthesizeReleases): Obsolete, remove. (test): Update. lib/python/bugs.py (CANFile, CVEFile): Split into two classes, which handle the differences between the two files. bin/check-syntax: Update accordingly. bin/update-db: New database update script. Implements incremental updates. Makefile: Remove references to bin/update-packages. Simplify drastically. git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@1994 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/update-db')
-rwxr-xr-xbin/update-db64
1 files changed, 64 insertions, 0 deletions
diff --git a/bin/update-db b/bin/update-db
new file mode 100755
index 0000000000..273d9fa7e0
--- /dev/null
+++ b/bin/update-db
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+import os
+import os.path
+import string
+import sys
+
+def setup_paths():
+ check_file = 'lib/python/debian_support.py'
+ path = os.getcwd()
+ while 1:
+ if os.path.exists("%s/%s" % (path, check_file)):
+ sys.path = [path + '/lib/python'] + sys.path
+ return path
+ idx = string.rfind(path, '/')
+ if idx == -1:
+ raise ImportError, "could not setup paths"
+ path = path[0:idx]
+os.chdir(setup_paths())
+
+import bugs
+import debian_support
+import security_db
+
+db_file = 'data/security.db'
+try:
+ db = security_db.DB(db_file, verbose=True)
+except security_db.SchemaMismatch:
+ os.unlink(db_file)
+ db = security_db.DB(db_file, verbose=True)
+
+cursor = db.writeTxn()
+
+# Bug lists (CAN/CVE/DSA/DTSA)
+
+try:
+ warnings = db.readBugs(cursor, 'data')
+except debian_support.ParseError, e:
+ e.printOut(sys.stderr)
+ sys.exit(1)
+except security_db.InsertError, e:
+ for err in e.errors:
+ print err
+ sys.exit(1)
+if warnings:
+ for x in warnings:
+ print x
+ sys.exit(1)
+
+# Packages
+
+db.readPackages(cursor, 'data/packages')
+
+# Calculate vulnerability information.
+
+warnings = db.calculateVulnerabilities(cursor)
+if warnings:
+ for x in warnings:
+ print x
+ sys.exit(1)
+
+# Everything worked well.
+
+db.commit(cursor)

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