4 Output override files for apt-ftparchive and indices/
5 @contact: Debian FTP Master <ftpmaster@debian.org>
6 @copyright: 2000, 2001, 2002, 2004, 2006 James Troup <james@nocrew.org>
7 @license: GNU General Public License version 2 or later
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ################################################################################
26 # This is seperate because it's horribly Debian specific and I don't
27 # want that kind of horribleness in the otherwise generic 'dak
28 # make-overrides'. It does duplicate code tho.
30 ################################################################################
35 from daklib import database
36 from daklib import utils
38 ################################################################################
40 Cnf = None #: Configuration, apt_pkg.Configuration
41 projectB = None #: database connection, pgobject
42 override = {} #: override data to write out
44 ################################################################################
46 def usage(exit_code=0):
47 print """Usage: dak make-overrides
48 Outputs the override tables to text files.
50 -h, --help show this help and exit."""
53 ################################################################################
55 def do_list(output_file, suite, component, otype):
57 Fetch override data for suite from the database and dump it.
59 @type output_file: fileobject
60 @param output_file: where to write the overrides to
63 @param suite: The name of the suite
65 @type component: string
66 @param component: The name of the component
69 @param otype: type of override. deb/udeb/dsc
74 suite_id = database.get_suite_id(suite)
76 utils.fubar("Suite '%s' not recognised." % (suite))
78 component_id = database.get_component_id(component)
79 if component_id == -1:
80 utils.fubar("Component '%s' not recognised." % (component))
82 otype_id = database.get_override_type_id(otype)
84 utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype))
86 override.setdefault(suite, {})
87 override[suite].setdefault(component, {})
88 override[suite][component].setdefault(otype, {})
91 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, otype_id))
92 for i in q.getresult():
93 override[suite][component][otype][i[0]] = i
94 output_file.write(utils.result_join(i)+'\n')
96 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, otype_id))
97 for i in q.getresult():
98 i = i[:-1]; # Strip the priority level
99 override[suite][component][otype][i[0]] = i
100 output_file.write(utils.result_join(i)+'\n')
102 ################################################################################
105 global Cnf, projectB, override
107 Cnf = utils.get_conf()
108 Arguments = [('h',"help","Make-Overrides::Options::Help")]
110 if not Cnf.has_key("Make-Overrides::Options::%s" % (i)):
111 Cnf["Make-Overrides::Options::%s" % (i)] = ""
112 apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
113 Options = Cnf.SubTree("Make-Overrides::Options")
117 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
118 database.init(Cnf, projectB)
120 for suite in Cnf.SubTree("Check-Overrides::OverrideSuites").List():
121 if Cnf.has_key("Suite::%s::Untouchable" % suite) and Cnf["Suite::%s::Untouchable" % suite] != 0:
123 suite = suite.lower()
125 sys.stderr.write("Processing %s...\n" % (suite))
126 override_suite = Cnf["Suite::%s::OverrideCodeName" % (suite)]
127 for component in Cnf.SubTree("Component").List():
128 for otype in Cnf.ValueList("OverrideType"):
131 elif otype == "udeb":
132 if component == "contrib":
134 suffix = ".debian-installer"
137 filename = "%s/override.%s.%s%s" % (Cnf["Dir::Override"], override_suite, component, suffix)
138 output_file = utils.open_file(filename, 'w')
139 do_list(output_file, suite, component, otype)
142 ################################################################################
144 if __name__ == '__main__':