]> git.decadent.org.uk Git - dak.git/blobdiff - charisma
added extraoverrides (for Task: fields)
[dak.git] / charisma
index 1579802709836cae49cbbbb8a2a83c2052c08df1..362ed5e59549046522678f28dced4972b61bda4a 100755 (executable)
--- a/charisma
+++ b/charisma
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
 # Generate Maintainers file used by e.g. the Debian Bug Tracking System
-# Copyright (C) 2000  James Troup <james@nocrew.org>
-# $Id: charisma,v 1.1 2000-11-24 00:20:11 troup Exp $
+# Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
+# $Id: charisma,v 1.7 2001-04-03 10:01:27 troup Exp $
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,6 +18,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+####################################################################################################################################
+
 # ``As opposed to "Linux sucks. Respect my academic authoritah, damn
 #   you!" or whatever all this hot air amounts to.''
 #                             -- ajt@ in _that_ thread on debian-devel@
 ####################################################################################################################################
 
 import os, pg, re, string, sys
+import db_access, utils
 import apt_pkg
-import utils
 
 ####################################################################################################################################
 
 projectB = None
 Cnf = None
-maintainer_cache = {}
 maintainer_from_source_cache = {}
 packages = {}
 fixed_maintainer_cache = {}
@@ -49,33 +50,24 @@ def fix_maintainer (maintainer):
 
     return fixed_maintainer_cache[maintainer]
 
+def get_maintainer (maintainer):
+    return fix_maintainer(db_access.get_maintainer(maintainer));
+
 def get_maintainer_from_source (source_id):
     global maintainer_from_source_cache
     
     if not maintainer_from_source_cache.has_key(source_id):
-        q = projectB.query("SELECT name FROM maintainer WHERE id IN (SELECT maintainer FROM source WHERE id = %s)" % (source_id));
+        q = projectB.query("SELECT m.name FROM maintainer m, source s WHERE s.id = %s and s.maintainer = m.id" % (source_id));
         maintainer = q.getresult()[0][0]
         maintainer_from_source_cache[source_id] = fix_maintainer(maintainer)
         
     return maintainer_from_source_cache[source_id]
 
-def get_maintainer (maintainer_id):
-    global maintainer_cache
-    
-    if not maintainer_cache.has_key(maintainer_id):
-        q = projectB.query("SELECT name FROM maintainer WHERE id = %s" % (maintainer_id));
-        maintainer = q.getresult()[0][0]
-        maintainer_cache[maintainer_id] = fix_maintainer(maintainer)
-        
-    return maintainer_cache[maintainer_id]
-
 ####################################################################################################################################
 
 def main():
     global Cnf, projectB;
 
-    projectB = pg.connect('projectb', 'localhost');
-
     apt_pkg.init();
     
     Cnf = apt_pkg.newConfiguration();
@@ -83,37 +75,45 @@ def main():
 
     extra_files = apt_pkg.ParseCommandLine(Cnf,[],sys.argv);
 
+    projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, Cnf["DB::ROUser"]);
+    db_access.init(Cnf, projectB);
+
     for suite in Cnf.SubTree("Suite").List():
         suite = string.lower(suite);
-        suite_priority = int(Cnf["Suite::%s::Priority" % (suite)])
+        suite_priority = int(Cnf["Suite::%s::Priority" % (suite)]);
+
+        # Source packages
+        q = projectB.query("SELECT s.source, s.version, m.name FROM src_associations sa, source s, suite su, maintainer m WHERE su.suite_name = '%s' AND sa.suite = su.id AND sa.source = s.id AND m.id = s.maintainer" % (suite))
+        sources = q.getresult();
+        for source in sources:
+            package = source[0];
+            version = source[1];
+            maintainer = fix_maintainer(source[2]);
+            if packages.has_key(package):
+                if packages[package]["priority"] <= suite_priority:
+                    if apt_pkg.VersionCompare(packages[package]["version"], version) == -1:
+                        packages[package] = { "maintainer": maintainer, "priority": suite_priority, "version": version };
+            else:
+                packages[package] = { "maintainer": maintainer, "priority": suite_priority, "version": version };
+
         # Binary packages
-        q = projectB.query("SELECT b.package, b.source, b.maintainer FROM bin_associations ba, binaries b, suite s WHERE s.suite_name = '%s' AND ba.suite = s.id AND ba.bin = b.id" % (suite));
+        q = projectB.query("SELECT b.package, b.source, b.maintainer, b.version FROM bin_associations ba, binaries b, suite s WHERE s.suite_name = '%s' AND ba.suite = s.id AND ba.bin = b.id" % (suite));
         binaries = q.getresult();
         for binary in binaries:
-            package = binary[0]
-            source_id = binary[1]
+            package = binary[0];
+            source_id = binary[1];
+            version = binary[3];
             # Use the source maintainer first; falling back on the binary maintainer as a last resort only
             if source_id != 0:
-                maintainer = get_maintainer_from_source(source_id)
+                maintainer = get_maintainer_from_source(source_id);
             else:
-                maintainer = get_maintainer(binary[2])
-            if packages.has_key(package):
-                if packages[package]["priority"] < suite_priority:
-                    packages[package] = { "maintainer": maintainer, "priority": suite_priority }
-            else:
-                packages[package] = { "maintainer": maintainer, "priority": suite_priority }
-
-        # Source packages
-        q = projectB.query("SELECT s.source, m.name FROM src_associations sa, source s, suite su, maintainer m WHERE su.suite_name = '%s' AND sa.suite = su.id AND sa.source = s.id AND m.id = s.maintainer" % (suite))
-        sources = q.getresult();
-        for source in sources:
-            package = source[0]
-            maintainer = fix_maintainer(source[1])
+                maintainer = get_maintainer(binary[2]);
             if packages.has_key(package):
-                if packages[package]["priority"] < suite_priority:
-                    packages[package] = { "maintainer": maintainer, "priority": suite_priority }
+                if packages[package]["priority"] <= suite_priority:
+                    if apt_pkg.VersionCompare(packages[package]["version"], version) == -1:
+                        packages[package] = { "maintainer": maintainer, "priority": suite_priority, "version": version };
             else:
-                packages[package] = { "maintainer": maintainer, "priority": suite_priority }
+                packages[package] = { "maintainer": maintainer, "priority": suite_priority, "version": version };
 
     # Process any additional Maintainer files (e.g. from non-US or pseudo packages)
     for filename in extra_files: