X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=charisma;h=c88fa52559633e588458cb6c343511300010ba1b;hb=791e932971b92146d3621efdd29facc02b109774;hp=362ed5e59549046522678f28dced4972b61bda4a;hpb=b5ee62da9921f9e14343e880c156ab1bf9896190;p=dak.git diff --git a/charisma b/charisma index 362ed5e5..c88fa525 100755 --- a/charisma +++ b/charisma @@ -2,7 +2,7 @@ # Generate Maintainers file used by e.g. the Debian Bug Tracking System # Copyright (C) 2000, 2001 James Troup -# $Id: charisma,v 1.7 2001-04-03 10:01:27 troup Exp $ +# $Id: charisma,v 1.12 2001-11-18 19:57:58 rmurray 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,19 +18,19 @@ # 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 -#################################################################################################################################### +################################################################################ projectB = None Cnf = None @@ -38,9 +38,17 @@ maintainer_from_source_cache = {} packages = {} fixed_maintainer_cache = {} -re_split = re.compile(r"(\S+)\s+(\S+.*)") +################################################################################ -#################################################################################################################################### +def usage (exit_code=0): + print """Usage: charisma [OPTION] EXTRA_FILE[...] +Generate an index of packages <=> Maintainers. + + -h, --help show this help and exit +""" + sys.exit(exit_code) + +################################################################################ def fix_maintainer (maintainer): global fixed_maintainer_cache; @@ -55,27 +63,32 @@ def 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 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 main(): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() + + Arguments = [('h',"help","Charisma::Options::Help")]; + if not Cnf.has_key("Charisma::Options::Help"): + Cnf["Charisma::Options::Help"] = ""; - extra_files = apt_pkg.ParseCommandLine(Cnf,[],sys.argv); + extra_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Charisma::Options"); - projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, Cnf["DB::ROUser"]); + if Options["Help"]: + usage(); + + projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); for suite in Cnf.SubTree("Suite").List(): @@ -104,7 +117,7 @@ def main(): 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: + if source_id != 0 and source_id != None: maintainer = get_maintainer_from_source(source_id); else: maintainer = get_maintainer(binary[2]); @@ -117,19 +130,34 @@ def main(): # Process any additional Maintainer files (e.g. from non-US or pseudo packages) for filename in extra_files: - file = utils.open_file(filename, 'r') + file = utils.open_file(filename); for line in file.readlines(): - m = re_split.match(line[:-1]) - package = m.group(1) - maintainer = fix_maintainer(m.group(2)) - if not packages.has_key(package): - packages[package] = { "maintainer": maintainer, "priority": 0 } - file.close() - + line = string.strip(utils.re_comments.sub('', line[:-1])) + if line == "": + continue; + split = string.split(line); + lhs = split[0]; + maintainer = fix_maintainer(string.join(split[1:])); + if string.find(lhs,'~') != -1: + lhs_split = string.split(lhs, '~'); + package = lhs_split[0]; + version = lhs_split[1]; + else: + package = lhs; + version = '*'; + # A version of '*' overwhelms all real version numbers + if not packages.has_key(package) or version == '*' \ + or apt_pkg.VersionCompare(packages[package]["version"], version) == -1: + packages[package] = { "maintainer": maintainer, "version": version }; + file.close(); + package_keys = packages.keys() package_keys.sort() for package in package_keys: - print "%-20s %s" % (package, packages[package]["maintainer"]) + lhs = string.join([package, packages[package]["version"]], '~'); + print "%-30s %s" % (lhs, packages[package]["maintainer"]); + +################################################################################ if __name__ == '__main__': main()