4 Generate Maintainers file used by e.g. the Debian Bug Tracking System
5 @contact: Debian FTP Master <ftpmaster@debian.org>
6 @copyright: 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
7 @copyright: 2011 Torsten Werner <twerner@debian.org>
8 @license: GNU General Public License version 2 or later
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ################################################################################
28 # ``As opposed to "Linux sucks. Respect my academic authoritah, damn
29 # you!" or whatever all this hot air amounts to.''
30 # -- ajt@ in _that_ thread on debian-devel@
32 ################################################################################
34 def usage (exit_code=0):
35 print """Usage: dak make-maintainers [OPTION] EXTRA_FILE[...]
36 Generate an index of packages <=> Maintainers / Uploaders.
38 -h, --help show this help and exit
42 ################################################################################
44 def format(package, person):
45 '''Return a string nicely formatted for writing to the output file.'''
46 return '%-20s %s\n' % (package, person)
48 ################################################################################
50 def uploader_list(source):
51 '''Return a sorted list of uploader names for source package.'''
52 return sorted([uploader.name for uploader in source.uploaders])
54 ################################################################################
59 Arguments = [('h',"help","Make-Maintainers::Options::Help")]
60 if not cnf.has_key("Make-Maintainers::Options::Help"):
61 cnf["Make-Maintainers::Options::Help"] = ""
63 extra_files = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
64 Options = cnf.SubTree("Make-Maintainers::Options")
69 session = DBConn().session()
71 # dictionary packages to maintainer names
73 # dictionary packages to list of uploader names
76 source_query = session.query(DBSource).from_statement('''
77 select distinct on (source) * from source
78 order by source, version desc''')
80 binary_query = session.query(DBBinary).from_statement('''
81 select distinct on (package) * from binaries
82 order by package, version desc''')
84 for source in source_query:
85 maintainers[source.source] = source.maintainer.name
86 uploaders[source.source] = uploader_list(source)
88 for binary in binary_query:
89 if binary.package not in maintainers:
90 maintainers[binary.package] = binary.maintainer.name
91 uploaders[binary.package] = uploader_list(binary.source)
93 maintainer_file = open('Maintainers', 'w')
94 uploader_file = open('Uploaders', 'w')
95 for package in sorted(uploaders):
96 maintainer_file.write(format(package, maintainers[package]))
97 for uploader in uploaders[package]:
98 uploader_file.write(format(package, uploader))
100 maintainer_file.close()
102 ################################################################################
104 if __name__ == '__main__':