3 # Cruft checker for overrides
4 # Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
5 # $Id: cindy,v 1.10 2002-05-23 09:54:23 troup Exp $
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.
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.
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
21 ################################################################################
23 ######################################################################
24 # NB: cindy is not a good idea with New Incoming as she doesn't take #
25 # into account accepted. You can minimize the impact of this by #
26 # running her immediately after katie but that's still racy because #
27 # lisa doesn't lock with katie. A better long term fix is the evil #
28 # plan for accepted to be in the DB. #
29 ######################################################################
31 ################################################################################
34 import utils, db_access;
37 ################################################################################
43 ################################################################################
45 def process(suite, component, type):
48 suite_id = db_access.get_suite_id(suite);
50 utils.fubar("Suite '%s' not recognised." % (suite));
52 component_id = db_access.get_component_id(component);
53 if component_id == -1:
54 utils.fubar("Component '%s' not recognised." % (component));
56 type_id = db_access.get_override_type_id(type);
58 utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type));
59 dsc_type_id = db_access.get_override_type_id("dsc");
61 if type == "deb" or type == "udeb":
63 q = projectB.query("SELECT DISTINCT b.package FROM binaries b, bin_associations ba WHERE b.id = ba.bin AND ba.suite = %s" % (suite_id));
64 for i in q.getresult():
68 q = projectB.query("SELECT DISTINCT s.source FROM source s, src_associations sa WHERE s.id = sa.source AND sa.suite = %s" % (suite_id));
69 for i in q.getresult():
70 src_packages[i[0]] = "";
72 q = projectB.query("SELECT package, priority, section, maintainer FROM override WHERE suite = %s AND component = %s AND type = %s" % (suite_id, component_id, type_id));
73 projectB.query("BEGIN WORK");
74 for i in q.getresult():
76 if type == "deb" or type == "udeb":
77 if not packages.has_key(package):
78 if not src_packages.has_key(package):
79 print "DELETING: %s" % (package);
80 #projectB.query("DELETE FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s"
81 #% (package, suite_id, component_id, type_id));
83 print "MAKING SOURCE: %s" % (package);
84 #projectB.query("DELETE FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s"
85 #% (package, suite_id, component_id, type_id));
86 # Then if source doesn't already have a copy, insert it into source
87 q = projectB.query("SELECT package FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s" % (package, suite_id, component_id, dsc_type_id));
89 #projectB.query("INSERT INTO override (package, suite, component, priority, section, type, maintainer) VALUES ('%s', %s, %s, %s, %s, %s, '%s')" % (package, suite_id, component_id, i[1], i[2], dsc_type_id, i[3]));
92 if not src_packages.has_key(package):
93 print "DELETING: %s" % (package);
94 #projectB.query("DELETE FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s"
95 #% (package, suite_id, component_id, type_id));
96 projectB.query("COMMIT WORK");
99 ################################################################################
102 global Cnf, projectB, override;
104 Cnf = utils.get_conf()
105 apt_pkg.ParseCommandLine(Cnf,[],sys.argv);
107 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
108 db_access.init(Cnf, projectB);
110 for suite in [ "stable", "unstable" ]:
111 print "Processing %s..." % (suite);
112 for component in Cnf.SubTree("Component").List():
113 if component == "mixed":
115 for type in Cnf.ValueList("OverrideType"):
116 print "Processing %s [%s - %s]..." % (suite, component, type);
117 process(suite, component, type);
119 #######################################################################################
121 if __name__ == '__main__':