4 Generate a list of override disparities
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2010 Luca Falavigna <dktrkranz@debian.org>
8 @license: GNU General Public License version 2 or later
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
27 # <adsb> Yay bugzilla *sigh*
29 # <Ganneff> quick, replace the bts with it
30 # * jcristau replaces dak with soyuz
31 # <adsb> and expects Ganneff to look after it?
32 # <jcristau> nah, elmo can do that
35 ################################################################################
42 from daklib.config import Config
43 from daklib.dbconn import *
44 from daklib import utils
46 ################################################################################
48 def usage (exit_code=0):
49 print """Generate a list of override disparities
52 dak override-disparity [ -p <package> ] [ -s <suite> ]
56 -h, --help show this help and exit
57 -p, --package limit check on given package only
58 -s, --suite choose suite to look for (default: unstable)"""
64 Arguments = [('h','help','Override-Disparity::Options::Help'),
65 ('s','suite','Override-Disparity::Options::Suite','HasArg'),
66 ('p','package','Override-Disparity::Options::Package','HasArg')]
68 for i in ['help', 'package']:
69 if not cnf.has_key('Override-Disparity::Options::%s' % (i)):
70 cnf['Override-Disparity::Options::%s' % (i)] = ''
71 if not cnf.has_key('Override-Disparity::Options::Suite'):
72 cnf['Override-Disparity::Options::Suite'] = 'unstable'
74 apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
75 Options = cnf.SubTree('Override-Disparity::Options')
81 session = DBConn().session()
82 suite = Options['suite']
83 components = cnf.ValueList('Suite::%s::Components' % suite)
84 arches = set([x.arch_string for x in get_suite_architectures(suite)])
85 arches -= set(['source', 'all'])
87 for component in components:
88 filename = '%s/dists/%s/%s/binary-%s/Packages.gz' % (cnf['Dir::Root'], suite, component, arch)
89 (fd, temp_filename) = utils.temp_filename()
90 (result, output) = commands.getstatusoutput('gunzip -c %s > %s' % (filename, temp_filename))
92 utils.fubar('Gunzip invocation failed!\n%s\n' % (output), result)
93 filename = '%s/dists/%s/%s/debian-installer/binary-%s/Packages.gz' % (cnf['Dir::Root'], suite, component, arch)
94 if os.path.exists(filename):
95 (result, output) = commands.getstatusoutput('gunzip -c %s >> %s' % (filename, temp_filename))
97 utils.fubar('Gunzip invocation failed!\n%s\n' % (output), result)
98 packages_file = utils.open_file(temp_filename)
99 Packages = apt_pkg.ParseTagFile(packages_file)
100 while Packages.Step():
101 package = Packages.Section.Find('Package')
102 dep_list = Packages.Section.Find('Depends')
103 if Options['package'] and package != Options['package']:
106 for d in apt_pkg.ParseDepends(dep_list):
108 if not depends.has_key(package):
109 depends[package] = set()
110 depends[package].add(i[0])
111 os.unlink(temp_filename)
114 query = """SELECT DISTINCT o.package, p.level, p.priority, m.name
116 JOIN suite s ON s.id = o.suite
117 JOIN priority p ON p.id = o.priority
118 JOIN binaries b ON b.package = o.package
119 JOIN maintainer m ON m.id = b.maintainer
120 JOIN bin_associations ba ON ba.bin = b.id
121 WHERE s.suite_name = '%s'
123 AND p.level <> 0""" % suite
124 packages = session.execute(query)
128 priorities[p[0]] = [p[1], p[2], p[3], True]
129 for d in sorted(depends.keys()):
131 if priorities.has_key(d) and priorities.has_key(p):
132 if priorities[d][0] < priorities[p][0]:
134 print 'Package: ' + d
135 print ' Priority: ' + priorities[d][1]
136 print ' Maintainer: ' + priorities[d][2]
137 priorities[d][3] = False
138 print ' Dependency: ' + p
139 print ' Priority: ' + priorities[p][1]
140 print ' Maintainer: ' + priorities[p][2]
142 if __name__ == '__main__':