5 Adding a trainee field to the process-new notes
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2009 Mike O'Connor <stew@debian.org>
9 @license: GNU General Public License version 2 or later
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ################################################################################
29 ################################################################################
33 from daklib.dak_exceptions import DBUpdateError
35 ################################################################################
39 return a list of suites to operate on
41 if Config().has_key( "%s::%s" %(options_prefix,"Suite")):
42 suites = utils.split_args(Config()[ "%s::%s" %(options_prefix,"Suite")])
44 suites = [ 'unstable', 'testing' ]
45 # suites = Config().SubTree("Suite").List()
49 def arches(cursor, suite):
51 return a list of archs to operate on
54 cursor.execute("EXECUTE arches_q(%d)" % (suite))
60 if r[1] != "source" and r[1] != "all":
61 arch_list.append((r[0], r[1]))
67 Adding contents table as first step to maybe, finally getting rid
75 c.execute("""CREATE TABLE deb_contents (
82 component integer)""" )
84 c.execute("""CREATE TABLE udeb_contents (
90 component integer )""" )
92 c.execute("""ALTER TABLE ONLY deb_contents
93 ADD CONSTRAINT deb_contents_arch_fkey
94 FOREIGN KEY (arch) REFERENCES architecture(id)
95 ON DELETE CASCADE;""")
97 c.execute("""ALTER TABLE ONLY udeb_contents
98 ADD CONSTRAINT udeb_contents_arch_fkey
99 FOREIGN KEY (arch) REFERENCES architecture(id)
100 ON DELETE CASCADE;""")
102 c.execute("""ALTER TABLE ONLY deb_contents
103 ADD CONSTRAINT deb_contents_suite_fkey
104 FOREIGN KEY (suite) REFERENCES suite(id)
105 ON DELETE CASCADE;""")
107 c.execute("""ALTER TABLE ONLY udeb_contents
108 ADD CONSTRAINT udeb_contents_suite_fkey
109 FOREIGN KEY (suite) REFERENCES suite(id)
110 ON DELETE CASCADE;""")
112 c.execute("""ALTER TABLE ONLY deb_contents
113 ADD CONSTRAINT deb_contents_binary_fkey
114 FOREIGN KEY (binary_id) REFERENCES binaries(id)
115 ON DELETE CASCADE;""")
117 c.execute("""ALTER TABLE ONLY udeb_contents
118 ADD CONSTRAINT udeb_contents_binary_fkey
119 FOREIGN KEY (binary_id) REFERENCES binaries(id)
120 ON DELETE CASCADE;""")
122 c.execute("""CREATE INDEX ind_deb_contents_binary ON deb_contents(binary_id);""" )
124 arches_q = """PREPARE arches_q(int) as
125 SELECT s.architecture, a.arch_string
126 FROM suite_architectures s
127 JOIN architecture a ON (s.architecture=a.id)
130 suites = self.suites()
132 for suite in [i.lower() for i in suites]:
133 suite_id = DBConn().get_suite_id(suite)
134 arch_list = arches(c, suite_id)
135 arch_list = arches(c, suite_id)
137 for (arch_id,arch_str) in arch_list:
138 c.execute( "CREATE INDEX ind_deb_contents_%s_%s ON deb_contents (arch,suite) WHERE (arch=2 OR arch=%d) AND suite=$d"%(arch_str,suite,arch_id,suite_id) )
140 for section, sname in [("debian-installer","main"),
141 ("non-free/debian-installer", "nonfree")]:
142 c.execute( "CREATE INDEX ind_udeb_contents_%s_%s ON udeb_contents (section,suite) WHERE section=%s AND suite=$d"%(sname,suite,section,suite_id) )
145 Column | Type | Modifiers
146 ------------+---------+-----------
147 package | text | not null
148 suite | integer | not null
149 component | integer | not null
151 section | integer | not null
152 type | integer | not null
155 c.execute("""CREATE TABLE deb_contents (
162 component integer)""" )
165 CREATE FUNCTION update_contents_for_override() RETURNS trigger AS $update_contents_for_override$
167 UPDATE deb_contents SET section=NEW.section, component=NEW.component
168 WHERE deb_contents.package=OLD.package
172 NEW.last_date := current_timestamp;
173 NEW.last_user := current_user;
176 $update_contents_for_override$ LANGUAGE plpgsql;
181 except psycopg2.ProgrammingError, msg:
183 raise DBUpdateError, "Unable to apply process-new update 14, rollback issued. Error message : %s" % (str(msg))
185 INSERT INTO deb_contents SELECT (p.path||'/'||n.file) AS file,
186 s.section AS section,
187 b.package AS package,
189 b.architecture AS arch,
191 o.component AS componentd,
193 FROM content_associations c
194 JOIN content_file_paths p ON (c.filepath=p.id)
195 JOIN content_file_names n ON (c.filename=n.id)
196 JOIN binaries b ON (b.id=c.binary_pkg)
197 JOIN architecture a ON (b.architecture = a.id)
198 JOIN override o ON (o.package=b.package)
199 JOIN bin_associations ba on ba.suite=o.suite and ba.bin=b.id
200 JOIN section s ON (s.id=o.section)
203 INSERT INTO udeb_contents SELECT (p.path||'/'||n.file) AS file,
204 s.section AS section,
205 b.package AS package,
207 b.architecture AS arch,
209 o.component AS componentd,
211 FROM content_associations c
212 JOIN content_file_paths p ON (c.filepath=p.id)
213 JOIN content_file_names n ON (c.filename=n.id)
214 JOIN binaries b ON (b.id=c.binary_pkg)
215 JOIN architecture a ON (b.architecture = a.id)
216 JOIN override o ON (o.package=b.package)
217 JOIN section s ON (s.id=o.section)
222 CREATE INDEX ind_archid ON contents(arch);
223 CREATE INDEX ind_archid_amd64 ON contents(arch) WHERE arch=16;
224 CREATE INDEX ind_suite ON contents(suite);
225 CREATE INDEX ind_suite_unstable ON contents(suite) WHERE suite=5;
226 CREATE INDEX ind_overridetype ON contents(otype);
227 CREATE INDEX ind_overridetype_deb ON contents(otype) WHERE otype=7;
228 CREATE INDEX ind_packagetype ON contents(packagetype);
229 CREATE INDEX ind_packagetype_deb ON contents(packagetype) WHERE packagetype='deb';
230 CREATE INDEX ind_package ON contents(package);
232 CREATE INDEX ind_suite_otype ON contents(suite, otype) WHERE suite=5 AND otype=7;
233 CREATE INDEX ind_suite_otype_arch ON contents(suite, otype, arch) WHERE suite=5 AND otype=7 AND arch=16;
234 CREATE INDEX ind_suite_otype_package ON contents(suite, otype, packagetype) WHERE suite=5 AND otype=7 AND packagetype='deb';
235 CREATE INDEX ind_suite_otype_package_notdeb ON contents(suite, otype, packagetype) WHERE suite=5 AND otype=7 AND packagetype!='deb';
238 CREATE INDEX ind_deb_contents_binary ON deb_contents(binary_id);
240 CREATE INDEX ind_deb_contents_arch_alpha_unstable ON deb_contents(arch) where (arch=2 or arch=3) AND suite=5 AND otype=7;
241 CREATE INDEX ind_deb_contents_arch_hurd_i386_unstable ON deb_contents(arch) where (arch=2 or arch=4) AND suite=5 AND otype=7;
242 CREATE INDEX ind_deb_contents_arch_hppa_unstable ON deb_contents(arch) where (arch=2 or arch=5) AND suite=5 AND otype=7;
243 CREATE INDEX ind_deb_contents_arch_arm_unstable ON deb_contents(arch) where (arch=2 or arch=6) AND suite=5 AND otype=7;
244 CREATE INDEX ind_deb_contents_arch_i386_unstable ON deb_contents(arch) where (arch=2 or arch=7) AND suite=5 AND otype=7;
245 CREATE INDEX ind_deb_contents_arch_m68k_unstable ON deb_contents(arch) where (arch=2 or arch=8) AND suite=5 AND otype=7;
246 CREATE INDEX ind_deb_contents_arch_mips_unstable ON deb_contents(arch) where (arch=2 or arch=9) AND suite=5 AND otype=7;
247 CREATE INDEX ind_deb_contents_arch_mipsel_unstable ON deb_contents(arch) where (arch=2 or arch=10) AND suite=5 AND otype=7;
248 CREATE INDEX ind_deb_contents_arch_powerpc_unstable ON deb_contents(arch) where (arch=2 or arch=11) AND suite=5 AND otype=7;
249 CREATE INDEX ind_deb_contents_arch_sh_unstable ON deb_contents(arch) where (arch=2 or arch=12) AND suite=5 AND otype=7;
250 CREATE INDEX ind_deb_contents_arch_sparc_unstable ON deb_contents(arch) where (arch=2 or arch=13) AND suite=5 AND otype=7;
251 CREATE INDEX ind_deb_contents_arch_s390_unstable ON deb_contents(arch) where (arch=2 or arch=14) AND suite=5 AND otype=7;
252 CREATE INDEX ind_deb_contents_arch_ia64_unstable ON deb_contents(arch) where (arch=2 or arch=15) AND suite=5 AND otype=7;
253 CREATE INDEX ind_deb_contents_arch_amd64_unstable ON deb_contents(arch) where (arch=2 or arch=16) AND suite=5 AND otype=7;
254 CREATE INDEX ind_deb_contents_arch_armel_unstable ON deb_contents(arch) where (arch=2 or arch=17) AND suite=5 AND otype=7;
255 CREATE INDEX ind_deb_contents_arch_kfreebsd_i386_unstable ON deb_contents(arch) where (arch=2 or arch=25) AND suite=5 AND otype=7;
256 CREATE INDEX ind_deb_contents_arch_kfreebsd_amd64_unstable ON deb_contents(arch) where (arch=2 or arch=26) AND suite=5 AND otype=7;
258 CREATE INDEX ind_deb_contents_arch_alpha_stable ON deb_contents(arch) where (arch=2 or arch=3) AND suite=2 AND otype=7;
259 CREATE INDEX ind_deb_contents_arch_hurd_i386_stable ON deb_contents(arch) where (arch=2 or arch=4) AND suite=2 AND otype=7;
260 CREATE INDEX ind_deb_contents_arch_hppa_stable ON deb_contents(arch) where (arch=2 or arch=5) AND suite=2 AND otype=7;
261 CREATE INDEX ind_deb_contents_arch_arm_stable ON deb_contents(arch) where (arch=2 or arch=6) AND suite=2 AND otype=7;
262 CREATE INDEX ind_deb_contents_arch_i386_stable ON deb_contents(arch) where (arch=2 or arch=7) AND suite=2 AND otype=7;
263 CREATE INDEX ind_deb_contents_arch_m68k_stable ON deb_contents(arch) where (arch=2 or arch=8) AND suite=2 AND otype=7;
264 CREATE INDEX ind_deb_contents_arch_mips_stable ON deb_contents(arch) where (arch=2 or arch=9) AND suite=2 AND otype=7;
265 CREATE INDEX ind_deb_contents_arch_mipsel_stable ON deb_contents(arch) where (arch=2 or arch=10) AND suite=2 AND otype=7;
266 CREATE INDEX ind_deb_contents_arch_powerpc_stable ON deb_contents(arch) where (arch=2 or arch=11) AND suite=2 AND otype=7;
267 CREATE INDEX ind_deb_contents_arch_sh_stable ON deb_contents(arch) where (arch=2 or arch=12) AND suite=2 AND otype=7;
268 CREATE INDEX ind_deb_contents_arch_sparc_stable ON deb_contents(arch) where (arch=2 or arch=13) AND suite=2 AND otype=7;
269 CREATE INDEX ind_deb_contents_arch_s390_stable ON deb_contents(arch) where (arch=2 or arch=14) AND suite=2 AND otype=7;
270 CREATE INDEX ind_deb_contents_arch_ia64_stable ON deb_contents(arch) where (arch=2 or arch=15) AND suite=2 AND otype=7;
271 CREATE INDEX ind_deb_contents_arch_amd64_stable ON deb_contents(arch) where (arch=2 or arch=16) AND suite=2 AND otype=7;
272 CREATE INDEX ind_deb_contents_arch_armel_stable ON deb_contents(arch) where (arch=2 or arch=17) AND suite=2 AND otype=7;
273 CREATE INDEX ind_deb_contents_arch_kfreebsd_i386_stable ON deb_contents(arch) where (arch=2 or arch=25) AND suite=2 AND otype=7;
274 CREATE INDEX ind_deb_contents_arch_kfreebsd_amd64_stable ON deb_contents(arch) where (arch=2 or arch=26) AND suite=2 AND otype=7;
276 CREATE INDEX ind_deb_contents_arch_alpha_testing ON deb_contents(arch) where (arch=2 or arch=3) AND suite=4 AND otype=7;
277 CREATE INDEX ind_deb_contents_arch_hurd_i386_testing ON deb_contents(arch) where (arch=2 or arch=4) AND suite=4 AND otype=7;
278 CREATE INDEX ind_deb_contents_arch_hppa_testing ON deb_contents(arch) where (arch=2 or arch=5) AND suite=4 AND otype=7;
279 CREATE INDEX ind_deb_contents_arch_arm_testing ON deb_contents(arch) where (arch=2 or arch=6) AND suite=4 AND otype=7;
280 CREATE INDEX ind_deb_contents_arch_i386_testing ON deb_contents(arch) where (arch=2 or arch=7) AND suite=4 AND otype=7;
281 CREATE INDEX ind_deb_contents_arch_m68k_testing ON deb_contents(arch) where (arch=2 or arch=8) AND suite=4 AND otype=7;
282 CREATE INDEX ind_deb_contents_arch_mips_testing ON deb_contents(arch) where (arch=2 or arch=9) AND suite=4 AND otype=7;
283 CREATE INDEX ind_deb_contents_arch_mipsel_testing ON deb_contents(arch) where (arch=2 or arch=10) AND suite=4 AND otype=7;
284 CREATE INDEX ind_deb_contents_arch_powerpc_testing ON deb_contents(arch) where (arch=2 or arch=11) AND suite=4 AND otype=7;
285 CREATE INDEX ind_deb_contents_arch_sh_testing ON deb_contents(arch) where (arch=2 or arch=12) AND suite=4 AND otype=7;
286 CREATE INDEX ind_deb_contents_arch_sparc_testing ON deb_contents(arch) where (arch=2 or arch=13) AND suite=4 AND otype=7;
287 CREATE INDEX ind_deb_contents_arch_s390_testing ON deb_contents(arch) where (arch=2 or arch=14) AND suite=4 AND otype=7;
288 CREATE INDEX ind_deb_contents_arch_ia64_testing ON deb_contents(arch) where (arch=2 or arch=15) AND suite=4 AND otype=7;
289 CREATE INDEX ind_deb_contents_arch_amd64_testing ON deb_contents(arch) where (arch=2 or arch=16) AND suite=4 AND otype=7;
290 CREATE INDEX ind_deb_contents_arch_armel_testing ON deb_contents(arch) where (arch=2 or arch=17) AND suite=4 AND otype=7;
291 CREATE INDEX ind_deb_contents_arch_kfreebsd_i386_testing ON deb_contents(arch) where (arch=2 or arch=25) AND suite=4 AND otype=7;
292 CREATE INDEX ind_deb_contents_arch_kfreebsd_amd64_testing ON deb_contents(arch) where (arch=2 or arch=26) AND suite=4 AND otype=7;
294 CREATE INDEX ind_deb_contents_arch_alpha_oldstable ON deb_contents(arch) where (arch=2 or arch=3) AND suite=14 AND otype=7;
295 CREATE INDEX ind_deb_contents_arch_hurd_i386_oldstable ON deb_contents(arch) where (arch=2 or arch=4) AND suite=14 AND otype=7;
296 CREATE INDEX ind_deb_contents_arch_hppa_oldstable ON deb_contents(arch) where (arch=2 or arch=5) AND suite=14 AND otype=7;
297 CREATE INDEX ind_deb_contents_arch_arm_oldstable ON deb_contents(arch) where (arch=2 or arch=6) AND suite=14 AND otype=7;
298 CREATE INDEX ind_deb_contents_arch_i386_oldstable ON deb_contents(arch) where (arch=2 or arch=7) AND suite=14 AND otype=7;
299 CREATE INDEX ind_deb_contents_arch_m68k_oldstable ON deb_contents(arch) where (arch=2 or arch=8) AND suite=14 AND otype=7;
300 CREATE INDEX ind_deb_contents_arch_mips_oldstable ON deb_contents(arch) where (arch=2 or arch=9) AND suite=14 AND otype=7;
301 CREATE INDEX ind_deb_contents_arch_mipsel_oldstable ON deb_contents(arch) where (arch=2 or arch=10) AND suite=14 AND otype=7;
302 CREATE INDEX ind_deb_contents_arch_powerpc_oldstable ON deb_contents(arch) where (arch=2 or arch=11) AND suite=14 AND otype=7;
303 CREATE INDEX ind_deb_contents_arch_sh_oldstable ON deb_contents(arch) where (arch=2 or arch=12) AND suite=14 AND otype=7;
304 CREATE INDEX ind_deb_contents_arch_sparc_oldstable ON deb_contents(arch) where (arch=2 or arch=13) AND suite=14 AND otype=7;
305 CREATE INDEX ind_deb_contents_arch_s390_oldstable ON deb_contents(arch) where (arch=2 or arch=14) AND suite=14 AND otype=7;
306 CREATE INDEX ind_deb_contents_arch_ia64_oldstable ON deb_contents(arch) where (arch=2 or arch=15) AND suite=14 AND otype=7;
307 CREATE INDEX ind_deb_contents_arch_amd64_oldstable ON deb_contents(arch) where (arch=2 or arch=16) AND suite=14 AND otype=7;
308 CREATE INDEX ind_deb_contents_arch_armel_oldstable ON deb_contents(arch) where (arch=2 or arch=17) AND suite=14 AND otype=7;
309 CREATE INDEX ind_deb_contents_arch_kfreebsd_i386_oldstable ON deb_contents(arch) where (arch=2 or arch=25) AND suite=14 AND otype=7;
310 CREATE INDEX ind_deb_contents_arch_kfreebsd_amd64_oldstable ON deb_contents(arch) where (arch=2 or arch=26) AND suite=14 AND otype=7;