]> git.decadent.org.uk Git - dak.git/blob - christina
sync
[dak.git] / christina
1 #!/usr/bin/env python
2
3 # Compares Packages-Arch-Specific (from Quinn-Diff) against the archive
4 # Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
5 # $Id: christina,v 1.2 2001-07-07 03:15:36 troup Exp $
6
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.
11
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.
16
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
20
21 ################################################################################
22
23 # 23:12|<aj> I will not hush!
24 # 23:12|<elmo> :>
25 # 23:12|<aj> Where there is injustice in the world, I shall be there!
26 # 23:13|<aj> I shall not be silenced!
27 # 23:13|<aj> The world shall know!
28 # 23:13|<aj> The world *must* know!
29 # 23:13|<elmo> oh dear, he's gone back to powerpuff girls... ;-)
30 # 23:13|<aj> yay powerpuff girls!!
31 # 23:13|<aj> buttercup's my favourite, who's yours?
32 # 23:14|<aj> you're backing away from the keyboard right now aren't you?
33 # 23:14|<aj> *AREN'T YOU*?!
34 # 23:15|<aj> I will not be treated like this.
35 # 23:15|<aj> I shall have my revenge.
36 # 23:15|<aj> I SHALL!!!
37
38 ################################################################################
39
40 import pg, sys, os, string
41 import utils, db_access
42 import apt_pkg;
43
44 ################################################################################
45
46 Cnf = None;
47 projectB = None;
48
49 ################################################################################
50
51 def rev_cmp_by_suite (a, b):
52     ai = Cnf["Suite::%s::Priority" % (a)];
53     bi = Cnf["Suite::%s::Priority" % (b)];
54
55     if a < b:
56         return 1;
57     elif a > b:
58         return -1;
59
60     return 0;
61
62 def sort_dict (d):
63     sys.stderr.write("Sorting... ");
64     for i in d.keys():
65         suites = d[i];
66         suites.sort(rev_cmp_by_suite);
67         d[i] = suites[0];
68     sys.stderr.write("done.\n");
69
70 def add_to_dict (q):
71     d = {};
72     ql = q.getresult();
73     for i in ql:
74         package = i[0];
75         suite = i[1];
76         if not d.has_key(package):
77             d[package] = [];
78         d[package].append(suite);
79     return d;
80
81 def get_binaries ():
82     sys.stderr.write("Binaries query... ");
83     q = projectB.query("SELECT DISTINCT b.package, su.suite_name FROM binaries b, bin_associations ba, suite su WHERE b.id = ba.bin AND su.id = ba.suite");
84     sys.stderr.write("done.\n");
85     binaries = add_to_dict (q);
86     sort_dict(binaries);
87     return binaries;
88
89 def get_source ():
90     sys.stderr.write("Source query... ");
91     q = projectB.query("SELECT DISTINCT s.source, su.suite_name FROM source s, src_associations sa, suite su WHERE s.id = sa.source AND su.id = sa.suite");
92     sys.stderr.write("done.\n");
93     source = add_to_dict (q);
94     sort_dict(source);
95     return source;
96
97 def main ():
98     global Cnf, projectB;
99
100     apt_pkg.init();
101     
102     Cnf = apt_pkg.newConfiguration();
103     apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
104
105     Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
106                  ('h',"help","Christina::Options::Help"),
107                  ('v',"version","Christina::Options::Version")];
108
109     apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
110     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
111     db_access.init(Cnf, projectB);
112
113     # Get a list of binaries and source with their latest suite
114     binaries = get_binaries();
115     source = get_source();
116
117     as_binaries = {};
118     as_source = {};
119
120     filename = "/org/buildd.debian.org/web/quinn-diff/Packages-arch-specific";
121     file = utils.open_file(filename, 'r');
122     line_count = 0;
123     for line in file.readlines():
124         line = string.strip(utils.re_comments.sub("", line));
125         line_count = line_count + 1;
126         if line == "":
127             continue;
128         sline = string.split(line, ':');
129         if len(sline) != 2:
130             utils.warn("parse error on line %s; skipping" % (line_count));
131             continue;
132         (package, architectures) = map(string.strip, sline);
133         # Binary
134         if package[0] != '%':
135             if not binaries.has_key(package):
136                 if source.has_key(package):
137                     print "SHOULD BE SOURCE: %s ==> %s" % (package, architectures);
138                 else:
139                     print "MISSING: %s ==> %s" % (package, architectures);
140             else:
141                 if binaries[package] == "unstable":
142                     as_binaries[package] = architectures;
143             
144         # Source
145         else:
146             package = package[1:]
147             if not source.has_key(package):
148                 if binaries.has_key(package):
149                     print "SHOULD BE BINARY: %s ==> %s" % (package, architectures);
150                 else:
151                     print "[source] MISSING: %s ==> %s" % (package, architectures);
152             else:
153                 if source[package] == "unstable":
154                     as_source[package] = architectures;
155
156     suite_id = db_access.get_suite_id("unstable");
157     for package in as_binaries.keys():
158         as_architectures = string.split(as_binaries[package]);
159         arches_arch_specific = {};
160         for i in as_architectures:
161             arches_arch_specific[i] = "";
162
163         q = projectB.query("SELECT a.arch_string FROM bin_associations ba, binaries b, architecture a WHERE a.id = b.architecture AND b.package = '%s' AND ba.suite = %s AND ba.bin = b.id" % (package, suite_id));
164         ql = q.getresult();
165
166         print "%s: %s vs. %s" % (package, ql, as_architectures);
167         
168         arches_in_archive = {};
169         for i in ql:
170             arches_in_archive[i[0]] = "";
171
172         for arch in as_architectures:
173             if arch[0] == "!":
174                 arch = arch[1:];
175                 if arches_in_archive.has_key(arch):
176                     utils.warn("%s is excluded from %s but is in the archive for %s.[1]" % (package, arch, arch));
177             else:
178                 if not arches_in_archive.has_key(arch):
179                     utils.warn("%s is listed as buildable on %s but isn't in the archive for %s." % (package, arch, arch));
180
181         for arch in arches_in_archive.keys():
182             if not arches_arch_specific.has_key(arch):
183                 utils.warn("%s is excluded from %s but is in the archive for %s.[2]" % (package, arch, arch));
184         
185 # HO HUM; maybe have control words in the comments like "<STABLE>" ? bit icky
186 # see if package exists at all
187 # see if package exists for excluded arch
188 # see if package in specific suite
189 # compare against source package's .dsc!
190 # ??
191
192 #######################################################################################
193
194 if __name__ == '__main__':
195     main()
196