3 # Output override files for apt-ftparchive and indices/
4 # Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
5 # $Id: denise,v 1.12 2002-06-05 00:18:53 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 # This is seperate because it's horribly Debian specific and I don't
24 # want that kind of horribleness in the otherwise generic natalie. It
25 # does duplicate code tho.
27 ################################################################################
29 import pg, sys, string
30 import utils, db_access
33 ################################################################################
39 ################################################################################
41 def list(file, suite, component, type):
44 suite_id = db_access.get_suite_id(suite);
46 utils.fubar("Suite '%s' not recognised." % (suite));
48 component_id = db_access.get_component_id(component);
49 if component_id == -1:
50 utils.fubar("Component '%s' not recognised." % (component));
52 type_id = db_access.get_override_type_id(type);
54 utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type));
56 if not override.has_key(suite):
58 if not override[suite].has_key(component):
59 override[suite][component] = {};
60 if not override[suite][component].has_key(type):
61 override[suite][component][type] = {};
64 q = projectB.query("SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite_id, component_id, type_id));
65 for i in q.getresult():
66 override[suite][component][type][i[0]] = i;
67 file.write(utils.result_join(i)+'\n');
69 q = projectB.query("SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite_id, component_id, type_id));
70 for i in q.getresult():
71 i = i[:-1]; # Strip the priority level
72 override[suite][component][type][i[0]] = i;
73 file.write(utils.result_join(i)+'\n');
75 ################################################################################
78 global Cnf, projectB, override;
80 Cnf = utils.get_conf()
81 Arguments = [('D',"debug","Denise::Options::Debug", "IntVal"),
82 ('h',"help","Denise::Options::Help"),
83 ('V',"version","Denise::Options::Version")];
84 apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
86 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
87 db_access.init(Cnf, projectB);
89 for suite in [ "stable", "unstable" ]:
90 sys.stderr.write("Processing %s...\n" % (suite));
91 override_suite = Cnf["Suite::%s::OverrideCodeName" % (suite)];
92 for component in Cnf.SubTree("Component").List():
93 if component == "mixed":
95 for type in Cnf.ValueList("OverrideType"):
99 if suite != "unstable" or component != "main":
101 override_type = ".debian-installer";
103 override_type = ".src";
104 filename = "%s/override.%s.%s%s" % (Cnf["Dir::Override"], override_suite, string.replace(component, "non-US/", ""), override_type);
105 file = utils.open_file(filename, 'w');
106 list(file, suite, component, type);
109 # Munge the override file for testing by using unstable's where
110 # possible and falling back on stable's where it's not.
112 sys.stderr.write("Processing testing...\n");
114 suite_id = db_access.get_suite_id(suite);
115 override_suite = Cnf["Suite::%s::OverrideCodeName" % (suite)];
116 for component in Cnf.SubTree("Component").List():
117 if component == "mixed":
119 component_id = db_access.get_component_id(component);
120 for type in Cnf.ValueList("OverrideType"):
123 q = projectB.query("SELECT DISTINCT b.package FROM bin_associations ba, binaries b, files f, location l WHERE ba.suite = %s AND l.component = %s AND ba.bin = b.id AND b.file = f.id AND f.location = l.id" % (suite_id, component_id));
125 q = projectB.query("SELECT DISTINCT s.source FROM src_associations sa, source s, files f, location l WHERE sa.suite = %s AND l.component = %s AND sa.source = s.id AND s.file = f.id AND f.location = l.id" % (suite_id, component_id));
126 override_type = ".src";
129 filename = "override.%s.%s%s" % (override_suite, string.replace(component, "non-US/", ""), override_type);
130 file = utils.open_file(filename, 'w');
131 for i in q.getresult():
133 if override["unstable"][component][type].has_key(package):
134 file.write(utils.result_join(override["unstable"][component][type][package])+'\n');
135 elif override["stable"][component][type].has_key(package):
136 file.write(utils.result_join(override["stable"][component][type][package])+'\n');
138 if type == "dsc" and (override["unstable"][component]["deb"].has_key(package) or override["stable"][component]["deb"].has_key(package)):
139 continue; # source falls back on binary; so accept silently
140 utils.warn("Can't find override entry for testing package '%s' (component %s, type %s)." % (package, component, type));
143 #######################################################################################
145 if __name__ == '__main__':