]> git.decadent.org.uk Git - dak.git/blobdiff - charisma
Fix database name to be a config option. Fix debian/rules typo. [Ryan Murray]
[dak.git] / charisma
index 1579802709836cae49cbbbb8a2a83c2052c08df1..aeebd81dda4ea8ccf1ca54acf8498362e3521d76 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.6 2001-03-20 00:28:11 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@
@@ -53,7 +55,7 @@ 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)
         
@@ -74,8 +76,6 @@ def get_maintainer (maintainer_id):
 def main():
     global Cnf, projectB;
 
-    projectB = pg.connect('projectb', 'localhost');
-
     apt_pkg.init();
     
     Cnf = apt_pkg.newConfiguration();
@@ -83,37 +83,44 @@ 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"]);
+
     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)
-            else:
-                maintainer = get_maintainer(binary[2])
-            if packages.has_key(package):
-                if packages[package]["priority"] < suite_priority:
-                    packages[package] = { "maintainer": maintainer, "priority": suite_priority }
+                maintainer = get_maintainer_from_source(source_id);
             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: