]> git.decadent.org.uk Git - dak.git/blob - andrea
Fix database name to be a config option. Fix debian/rules typo. [Ryan Murray]
[dak.git] / andrea
1 #!/usr/bin/env python
2
3 # Check for fixable discrepancies between stable and unstable
4 # Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
5 # $Id: andrea,v 1.3 2001-03-20 00:28:11 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
24 import pg, string, sys;
25 import utils, db_access;
26 import apt_pkg;
27
28 ################################################################################
29
30 Cnf = None;
31 projectB = None;
32
33 ################################################################################
34
35 def main ():
36     global Cnf, projectB;
37
38     apt_pkg.init();
39     
40     Cnf = apt_pkg.newConfiguration();
41     apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
42
43     Arguments = [('D',"debug","Catherine::Options::Debug", "IntVal"),
44                  ('h',"help","Catherine::Options::Help"),
45                  ('V',"version","Catherine::Options::Version")]
46
47     apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
48
49     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
50     db_access.init(Cnf, projectB);
51
52     src_suite = "stable";
53     dst_suite = "unstable";
54
55     src_suite_id = db_access.get_suite_id(src_suite);
56     dst_suite_id = db_access.get_suite_id(dst_suite);
57     arch_all_id = db_access.get_architecture_id("all");
58     dsc_type_id = db_access.get_override_type_id("dsc");
59
60     for arch in Cnf.SubTree("Suite::%s::Architectures" % (src_suite)).List():
61         if arch == "source":
62             continue;
63
64         # Arch: all doesn't work; consider packages which go from
65         # arch: all to arch: any, e.g. debconf... needs more checks
66         # and thought later.
67
68         if arch == "all":
69             continue;
70         arch_id = db_access.get_architecture_id(arch);
71         q = projectB.query("""
72 SELECT b_src.package, b_src.version, a.arch_string
73   FROM binaries b_src, bin_associations ba, override o, architecture a
74   WHERE ba.bin = b_src.id AND ba.suite = %s AND b_src.architecture = %s
75         AND a.id = b_src.architecture AND o.package = b_src.package
76         AND o.suite = %s AND o.type != %s AND NOT EXISTS 
77     (SELECT b_dst.id FROM bin_associations ba2, binaries b_dst 
78        WHERE ba2.bin = b_dst.id AND b_dst.package = b_src.package 
79              AND (b_dst.architecture = %s OR b_dst.architecture = %s) 
80              AND ba2.suite = %s AND EXISTS 
81                (SELECT b2.id FROM bin_associations ba3, binaries b2 
82                   WHERE ba3.bin = b2.id AND ba3.suite = %s AND b2.package = b_dst.package))
83 ORDER BY b_src.package;"""
84                            % (src_suite_id, arch_id, dst_suite_id, dsc_type_id, arch_id, arch_all_id, dst_suite_id, dst_suite_id));
85         for i in q.getresult():
86             print string.join(i, ' ');
87
88 #######################################################################################
89
90 if __name__ == '__main__':
91     main()
92