3 # Generate Maintainers file used by e.g. the Debian Bug Tracking System
4 # Copyright (C) 2000 James Troup <james@nocrew.org>
5 # $Id: charisma,v 1.1 2000-11-24 00:20:11 troup Exp $
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # ``As opposed to "Linux sucks. Respect my academic authoritah, damn
22 # you!" or whatever all this hot air amounts to.''
23 # -- ajt@ in _that_ thread on debian-devel@
25 ####################################################################################################################################
27 import os, pg, re, string, sys
31 ####################################################################################################################################
36 maintainer_from_source_cache = {}
38 fixed_maintainer_cache = {}
40 re_split = re.compile(r"(\S+)\s+(\S+.*)")
42 ####################################################################################################################################
44 def fix_maintainer (maintainer):
45 global fixed_maintainer_cache;
47 if not fixed_maintainer_cache.has_key(maintainer):
48 fixed_maintainer_cache[maintainer] = utils.fix_maintainer(maintainer)[0]
50 return fixed_maintainer_cache[maintainer]
52 def get_maintainer_from_source (source_id):
53 global maintainer_from_source_cache
55 if not maintainer_from_source_cache.has_key(source_id):
56 q = projectB.query("SELECT name FROM maintainer WHERE id IN (SELECT maintainer FROM source WHERE id = %s)" % (source_id));
57 maintainer = q.getresult()[0][0]
58 maintainer_from_source_cache[source_id] = fix_maintainer(maintainer)
60 return maintainer_from_source_cache[source_id]
62 def get_maintainer (maintainer_id):
63 global maintainer_cache
65 if not maintainer_cache.has_key(maintainer_id):
66 q = projectB.query("SELECT name FROM maintainer WHERE id = %s" % (maintainer_id));
67 maintainer = q.getresult()[0][0]
68 maintainer_cache[maintainer_id] = fix_maintainer(maintainer)
70 return maintainer_cache[maintainer_id]
72 ####################################################################################################################################
77 projectB = pg.connect('projectb', 'localhost');
81 Cnf = apt_pkg.newConfiguration();
82 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
84 extra_files = apt_pkg.ParseCommandLine(Cnf,[],sys.argv);
86 for suite in Cnf.SubTree("Suite").List():
87 suite = string.lower(suite);
88 suite_priority = int(Cnf["Suite::%s::Priority" % (suite)])
90 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));
91 binaries = q.getresult();
92 for binary in binaries:
95 # Use the source maintainer first; falling back on the binary maintainer as a last resort only
97 maintainer = get_maintainer_from_source(source_id)
99 maintainer = get_maintainer(binary[2])
100 if packages.has_key(package):
101 if packages[package]["priority"] < suite_priority:
102 packages[package] = { "maintainer": maintainer, "priority": suite_priority }
104 packages[package] = { "maintainer": maintainer, "priority": suite_priority }
107 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))
108 sources = q.getresult();
109 for source in sources:
111 maintainer = fix_maintainer(source[1])
112 if packages.has_key(package):
113 if packages[package]["priority"] < suite_priority:
114 packages[package] = { "maintainer": maintainer, "priority": suite_priority }
116 packages[package] = { "maintainer": maintainer, "priority": suite_priority }
118 # Process any additional Maintainer files (e.g. from non-US or pseudo packages)
119 for filename in extra_files:
120 file = utils.open_file(filename, 'r')
121 for line in file.readlines():
122 m = re_split.match(line[:-1])
124 maintainer = fix_maintainer(m.group(2))
125 if not packages.has_key(package):
126 packages[package] = { "maintainer": maintainer, "priority": 0 }
129 package_keys = packages.keys()
131 for package in package_keys:
132 print "%-20s %s" % (package, packages[package]["maintainer"])
134 if __name__ == '__main__':