]> git.decadent.org.uk Git - dak.git/blob - neve
m68k added to list of archs
[dak.git] / neve
1 #!/usr/bin/env python
2
3 # Populate the DB
4 # Copyright (C) 2000, 2001, 2002  James Troup <james@nocrew.org>
5 # $Id: neve,v 1.13 2002-06-09 17:33:46 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 # 04:36|<aj> elmo: you're making me waste 5 seconds per architecture!!!!!! YOU BASTARD!!!!!
24
25 ###############################################################################
26
27 # This code is a horrible mess for two reasons:
28
29 #   (o) For Debian's usage, it's doing something like 160k INSERTs,
30 #   even on auric, that makes the program unusable unless we get
31 #   involed in sorts of silly optimization games (local dicts to avoid
32 #   redundant SELECTS, using COPY FROM rather than INSERTS etc.)
33
34 #   (o) It's very site specific, because I don't expect to use this
35 #   script again in a hurry, and I don't want to spend any more time
36 #   on it than absolutely necessary.
37
38 ###############################################################################
39
40 import commands, os, pg, re, select, string, tempfile, time;
41 import apt_pkg;
42 import db_access, utils;
43
44 ###############################################################################
45
46 re_arch_from_filename = re.compile(r"binary-[^/]+")
47
48 ###############################################################################
49
50 Cnf = None;
51 projectB = None;
52 files_id_cache = {};
53 source_cache = {};
54 arch_all_cache = {};
55 binary_cache = {};
56 #
57 files_id_serial = 0;
58 source_id_serial = 0;
59 src_associations_id_serial = 0;
60 dsc_files_id_serial = 0;
61 files_query_cache = None;
62 source_query_cache = None;
63 src_associations_query_cache = None;
64 dsc_files_query_cache = None;
65 orig_tar_gz_cache = {};
66 #
67 binaries_id_serial = 0;
68 binaries_query_cache = None;
69 bin_associations_id_serial = 0;
70 bin_associations_query_cache = None;
71 #
72 source_cache_for_binaries = {};
73 reject_message = "";
74
75 ###############################################################################
76
77 # Our very own version of commands.getouputstatus(), hacked to support
78 # gpgv's status fd.
79 def get_status_output(cmd, status_read, status_write):
80     cmd = ['/bin/sh', '-c', cmd];
81     p2cread, p2cwrite = os.pipe();
82     c2pread, c2pwrite = os.pipe();
83     errout, errin = os.pipe();
84     pid = os.fork();
85     if pid == 0:
86         # Child
87         os.close(0);
88         os.close(1);
89         os.dup(p2cread);
90         os.dup(c2pwrite);
91         os.close(2);
92         os.dup(errin);
93         for i in range(3, 256):
94             if i != status_write:
95                 try:
96                     os.close(i);
97                 except:
98                     pass;
99         try:
100             os.execvp(cmd[0], cmd);
101         finally:
102             os._exit(1);
103
104     # parent
105     os.close(p2cread)
106     os.dup2(c2pread, c2pwrite);
107     os.dup2(errout, errin);
108
109     output = status = "";
110     while 1:
111         i, o, e = select.select([c2pwrite, errin, status_read], [], []);
112         more_data = [];
113         for fd in i:
114             r = os.read(fd, 8196);
115             if len(r) > 0:
116                 more_data.append(fd);
117                 if fd == c2pwrite or fd == errin:
118                     output = output + r;
119                 elif fd == status_read:
120                     status = status + r;
121                 else:
122                     utils.fubar("Unexpected file descriptor [%s] returned from select\n" % (fd));
123         if not more_data:
124             pid, exit_status = os.waitpid(pid, 0)
125             try:
126                 os.close(status_write);
127                 os.close(status_read);
128                 os.close(c2pwrite);
129                 os.close(p2cwrite);
130                 os.close(errin);
131             except:
132                 pass;
133             break;
134
135     return output, status, exit_status;
136
137 ###############################################################################
138
139 def Dict(**dict): return dict
140
141 def reject (str, prefix="Rejected: "):
142     global reject_message;
143     if str:
144         reject_message = reject_message + prefix + str + "\n";
145
146 ###############################################################################
147
148 def check_signature (filename):
149     if not utils.re_taint_free.match(os.path.basename(filename)):
150         reject("!!WARNING!! tainted filename: '%s'." % (filename));
151         return None;
152
153     status_read, status_write = os.pipe();
154     cmd = "gpgv --status-fd %s --keyring %s --keyring %s %s" \
155           % (status_write, Cnf["Dinstall::PGPKeyring"], Cnf["Dinstall::GPGKeyring"], filename);
156     (output, status, exit_status) = get_status_output(cmd, status_read, status_write);
157
158     # Process the status-fd output
159     keywords = {};
160     bad = internal_error = "";
161     for line in string.split(status, '\n'):
162         line = string.strip(line);
163         if line == "":
164             continue;
165         split = string.split(line);
166         if len(split) < 2:
167             internal_error = internal_error + "gpgv status line is malformed (< 2 atoms) ['%s'].\n" % (line);
168             continue;
169         (gnupg, keyword) = split[:2];
170         if gnupg != "[GNUPG:]":
171             internal_error = internal_error + "gpgv status line is malformed (incorrect prefix '%s').\n" % (gnupg);
172             continue;
173         args = split[2:];
174         if keywords.has_key(keyword) and keyword != "NODATA" and keyword != "SIGEXPIRED":
175             internal_error = internal_error + "found duplicate status token ('%s')." % (keyword);
176             continue;
177         else:
178             keywords[keyword] = args;
179
180     # If we failed to parse the status-fd output, let's just whine and bail now
181     if internal_error:
182         reject("internal error while performing signature check on %s." % (filename));
183         reject(internal_error, "");
184         reject("Please report the above errors to the Archive maintainers by replying to this mail.", "");
185         return None;
186
187     # Now check for obviously bad things in the processed output
188     if keywords.has_key("SIGEXPIRED"):
189         utils.warn("%s: signing key has expired." % (filename));
190     if keywords.has_key("KEYREVOKED"):
191         reject("key used to sign %s has been revoked." % (filename));
192         bad = 1;
193     if keywords.has_key("BADSIG"):
194         reject("bad signature on %s." % (filename));
195         bad = 1;
196     if keywords.has_key("ERRSIG") and not keywords.has_key("NO_PUBKEY"):
197         reject("failed to check signature on %s." % (filename));
198         bad = 1;
199     if keywords.has_key("NO_PUBKEY"):
200         args = keywords["NO_PUBKEY"];
201         if len(args) < 1:
202             reject("internal error while checking signature on %s." % (filename));
203             bad = 1;
204         else:
205             fingerprint = args[0];
206     if keywords.has_key("BADARMOR"):
207         reject("ascii armour of signature was corrupt in %s." % (filename));
208         bad = 1;
209     if keywords.has_key("NODATA"):
210         utils.warn("no signature found for %s." % (filename));
211         return "NOSIG";
212         #reject("no signature found in %s." % (filename));
213         #bad = 1;
214
215     if bad:
216         return None;
217
218     # Next check gpgv exited with a zero return code
219     if exit_status and not keywords.has_key("NO_PUBKEY"):
220         reject("gpgv failed while checking %s." % (filename));
221         if string.strip(status):
222             reject(utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "");
223         else:
224             reject(utils.prefix_multi_line_string(output, " [GPG output:] "), "");
225         return None;
226
227     # Sanity check the good stuff we expect
228     if not keywords.has_key("VALIDSIG"):
229         if not keywords.has_key("NO_PUBKEY"):
230             reject("signature on %s does not appear to be valid [No VALIDSIG]." % (filename));
231             bad = 1;
232     else:
233         args = keywords["VALIDSIG"];
234         if len(args) < 1:
235             reject("internal error while checking signature on %s." % (filename));
236             bad = 1;
237         else:
238             fingerprint = args[0];
239     if not keywords.has_key("GOODSIG") and not keywords.has_key("NO_PUBKEY"):
240         reject("signature on %s does not appear to be valid [No GOODSIG]." % (filename));
241         bad = 1;
242     if not keywords.has_key("SIG_ID") and not keywords.has_key("NO_PUBKEY"):
243         reject("signature on %s does not appear to be valid [No SIG_ID]." % (filename));
244         bad = 1;
245
246     # Finally ensure there's not something we don't recognise
247     known_keywords = Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="",
248                           SIGEXPIRED="",KEYREVOKED="",NO_PUBKEY="",BADARMOR="",
249                           NODATA="");
250
251     for keyword in keywords.keys():
252         if not known_keywords.has_key(keyword):
253             reject("found unknown status token '%s' from gpgv with args '%s' in %s." % (keyword, repr(keywords[keyword]), filename));
254             bad = 1;
255
256     if bad:
257         return None;
258     else:
259         return fingerprint;
260
261 #########################################################################################
262
263 # Prepares a filename or directory (s) to be file.filename by stripping any part of the location (sub) from it.
264 def poolify (s, sub):
265     for i in xrange(len(sub)):
266         if sub[i:] == s[0:len(sub)-i]:
267             return s[len(sub)-i:];
268     return s;
269
270 def update_archives ():
271     projectB.query("DELETE FROM archive")
272     for archive in Cnf.SubTree("Archive").List():
273         SubSec = Cnf.SubTree("Archive::%s" % (archive));
274         projectB.query("INSERT INTO archive (name, origin_server, description) VALUES ('%s', '%s', '%s')"
275                        % (archive, SubSec["OriginServer"], SubSec["Description"]));
276
277 def update_components ():
278     projectB.query("DELETE FROM component")
279     for component in Cnf.SubTree("Component").List():
280         SubSec = Cnf.SubTree("Component::%s" % (component));
281         projectB.query("INSERT INTO component (name, description, meets_dfsg) VALUES ('%s', '%s', '%s')" %
282                        (component, SubSec["Description"], SubSec["MeetsDFSG"]));
283
284 def update_locations ():
285     projectB.query("DELETE FROM location")
286     for location in Cnf.SubTree("Location").List():
287         SubSec = Cnf.SubTree("Location::%s" % (location));
288         archive_id = db_access.get_archive_id(SubSec["archive"]);
289         type = SubSec.Find("type");
290         if type == "legacy-mixed":
291             projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, SubSec["type"]));
292         else:
293             for component in Cnf.SubTree("Component").List():
294                 component_id = db_access.get_component_id(component);
295                 projectB.query("INSERT INTO location (path, component, archive, type) VALUES ('%s', %d, %d, '%s')" %
296                                (location, component_id, archive_id, SubSec["type"]));
297
298 def update_architectures ():
299     projectB.query("DELETE FROM architecture")
300     for arch in Cnf.SubTree("Architectures").List():
301         projectB.query("INSERT INTO architecture (arch_string, description) VALUES ('%s', '%s')" % (arch, Cnf["Architectures::%s" % (arch)]))
302
303 def update_suites ():
304     projectB.query("DELETE FROM suite")
305     for suite in Cnf.SubTree("Suite").List():
306         SubSec = Cnf.SubTree("Suite::%s" %(suite))
307         projectB.query("INSERT INTO suite (suite_name) VALUES ('%s')" % string.lower(suite));
308         for i in ("Version", "Origin", "Description"):
309             if SubSec.has_key(i):
310                 projectB.query("UPDATE suite SET %s = '%s' WHERE suite_name = '%s'" % (string.lower(i), SubSec[i], string.lower(suite)))
311         for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)):
312             architecture_id = db_access.get_architecture_id (architecture);
313             projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id));
314
315 def update_override_type():
316     projectB.query("DELETE FROM override_type");
317     for type in Cnf.ValueList("OverrideType"):
318         projectB.query("INSERT INTO override_type (type) VALUES ('%s')" % (type));
319
320 def update_priority():
321     projectB.query("DELETE FROM priority");
322     for priority in Cnf.SubTree("Priority").List():
323         projectB.query("INSERT INTO priority (priority, level) VALUES ('%s', %s)" % (priority, Cnf["Priority::%s" % (priority)]));
324
325 ###############################################################################
326
327 def get_or_set_files_id (filename, size, md5sum, location_id):
328     global files_id_cache, files_id_serial, files_query_cache;
329
330     cache_key = string.join((filename, size, md5sum, repr(location_id)), '~')
331     if not files_id_cache.has_key(cache_key):
332         files_id_serial = files_id_serial + 1
333         files_query_cache.write("%d\t%s\t%s\t%s\t%d\n" % (files_id_serial, filename, size, md5sum, location_id));
334         files_id_cache[cache_key] = files_id_serial
335
336     return files_id_cache[cache_key]
337
338 ###############################################################################
339
340 def process_sources (location, filename, suite, component, archive, dsc_dir):
341     global source_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, source_id_serial, src_associations_id_serial, dsc_files_id_serial, source_cache_for_binaries, orig_tar_gz_cache, reject_message;
342
343     suite = string.lower(suite);
344     suite_id = db_access.get_suite_id(suite);
345     try:
346         file = utils.open_file (filename);
347     except utils.cant_open_exc:
348         print "WARNING: can't open '%s'" % (filename);
349         return;
350     Scanner = apt_pkg.ParseTagFile(file);
351     while Scanner.Step() != 0:
352         package = Scanner.Section["package"];
353         version = Scanner.Section["version"];
354         dsc_file = os.path.join(dsc_dir, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)));
355         install_date = time.strftime("%Y-%m-%d", time.localtime(os.path.getmtime(dsc_file)));
356         fingerprint = check_signature(dsc_file);
357         fingerprint_id = db_access.get_or_set_fingerprint_id(fingerprint);
358         if reject_message:
359             utils.fubar("%s: %s" % (dsc_file, reject_message));
360         maintainer = Scanner.Section["maintainer"]
361         maintainer = string.replace(maintainer, "'", "\\'");
362         maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
363         directory = Scanner.Section["directory"];
364         location_id = db_access.get_location_id (location, component, archive);
365         if directory[-1:] != "/":
366             directory = directory + '/';
367         directory = poolify (directory, location);
368         if directory != "" and directory[-1:] != "/":
369             directory = directory + '/';
370         no_epoch_version = utils.re_no_epoch.sub('', version);
371         # Add all files referenced by the .dsc to the files table
372         ids = [];
373         for line in string.split(Scanner.Section["files"],'\n'):
374             id = None;
375             (md5sum, size, filename) = string.split(string.strip(line));
376             # Don't duplicate .orig.tar.gz's
377             if filename[-12:] == ".orig.tar.gz":
378                 cache_key = "%s~%s~%s" % (filename, size, md5sum);
379                 if orig_tar_gz_cache.has_key(cache_key):
380                     id = orig_tar_gz_cache[cache_key];
381                 else:
382                     id = get_or_set_files_id (directory + filename, size, md5sum, location_id);
383                     orig_tar_gz_cache[cache_key] = id;
384             else:
385                 id = get_or_set_files_id (directory + filename, size, md5sum, location_id);
386             ids.append(id);
387             # If this is the .dsc itself; save the ID for later.
388             if filename[-4:] == ".dsc":
389                 files_id = id;
390         filename = directory + package + '_' + no_epoch_version + '.dsc'
391         cache_key = "%s~%s" % (package, version);
392         if not source_cache.has_key(cache_key):
393             nasty_key = "%s~%s" % (package, version)
394             source_id_serial = source_id_serial + 1;
395             if not source_cache_for_binaries.has_key(nasty_key):
396                 source_cache_for_binaries[nasty_key] = source_id_serial;
397             tmp_source_id = source_id_serial;
398             source_cache[cache_key] = source_id_serial;
399             source_query_cache.write("%d\t%s\t%s\t%d\t%d\t%s\t%s\n" % (source_id_serial, package, version, maintainer_id, files_id, install_date, fingerprint_id))
400             for id in ids:
401                 dsc_files_id_serial = dsc_files_id_serial + 1;
402                 dsc_files_query_cache.write("%d\t%d\t%d\n" % (dsc_files_id_serial, tmp_source_id,id));
403         else:
404             tmp_source_id = source_cache[cache_key];
405
406         src_associations_id_serial = src_associations_id_serial + 1;
407         src_associations_query_cache.write("%d\t%d\t%d\n" % (src_associations_id_serial, suite_id, tmp_source_id))
408
409     file.close();
410
411 ###############################################################################
412
413 def process_packages (location, filename, suite, component, archive):
414     global arch_all_cache, binary_cache, binaries_id_serial, binaries_query_cache, bin_associations_id_serial, bin_associations_query_cache, reject_message;
415
416     count_total = 0;
417     count_bad = 0;
418     suite = string.lower(suite);
419     suite_id = db_access.get_suite_id(suite);
420     try:
421         file = utils.open_file (filename);
422     except utils.cant_open_exc:
423         print "WARNING: can't open '%s'" % (filename);
424         return;
425     Scanner = apt_pkg.ParseTagFile(file);
426     while Scanner.Step() != 0:
427         package = Scanner.Section["package"]
428         version = Scanner.Section["version"]
429         maintainer = Scanner.Section["maintainer"]
430         maintainer = string.replace(maintainer, "'", "\\'")
431         maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
432         architecture = Scanner.Section["architecture"]
433         architecture_id = db_access.get_architecture_id (architecture);
434         fingerprint = "NOSIG";
435         fingerprint_id = db_access.get_or_set_fingerprint_id(fingerprint);
436         if not Scanner.Section.has_key("source"):
437             source = package
438         else:
439             source = Scanner.Section["source"]
440         source_version = ""
441         if string.find(source, "(") != -1:
442             m = utils.re_extract_src_version.match(source)
443             source = m.group(1)
444             source_version = m.group(2)
445         if not source_version:
446             source_version = version
447         filename = Scanner.Section["filename"]
448         location_id = db_access.get_location_id (location, component, archive)
449         filename = poolify (filename, location)
450         if architecture == "all":
451             filename = re_arch_from_filename.sub("binary-all", filename);
452         cache_key = "%s~%s" % (source, source_version);
453         source_id = source_cache_for_binaries.get(cache_key, None);
454         size = Scanner.Section["size"];
455         md5sum = Scanner.Section["md5sum"];
456         files_id = get_or_set_files_id (filename, size, md5sum, location_id);
457         type = "deb"; # FIXME
458         cache_key = "%s~%s~%s~%d~%d~%d" % (package, version, repr(source_id), architecture_id, location_id, files_id);
459         if not arch_all_cache.has_key(cache_key):
460             arch_all_cache[cache_key] = 1;
461             cache_key = "%s~%s~%s~%d" % (package, version, repr(source_id), architecture_id);
462             if not binary_cache.has_key(cache_key):
463                 if not source_id:
464                     source_id = "\N";
465                     count_bad = count_bad + 1;
466                 else:
467                     source_id = repr(source_id);
468                 binaries_id_serial = binaries_id_serial + 1;
469                 binaries_query_cache.write("%d\t%s\t%s\t%d\t%s\t%d\t%d\t%s\t%s\n" % (binaries_id_serial, package, version, maintainer_id, source_id, architecture_id, files_id, type, fingerprint_id));
470                 binary_cache[cache_key] = binaries_id_serial;
471                 tmp_binaries_id = binaries_id_serial;
472             else:
473                 tmp_binaries_id = binary_cache[cache_key];
474
475             bin_associations_id_serial = bin_associations_id_serial + 1;
476             bin_associations_query_cache.write("%d\t%d\t%d\n" % (bin_associations_id_serial, suite_id, tmp_binaries_id));
477             count_total = count_total +1;
478
479     file.close();
480     if count_bad != 0:
481         print "%d binary packages processed; %d with no source match which is %.2f%%" % (count_total, count_bad, (float(count_bad)/count_total)*100);
482     else:
483         print "%d binary packages processed; 0 with no source match which is 0%%" % (count_total);
484
485 ###############################################################################
486
487 def do_sources(location, prefix, suite, component, server):
488     temp_filename = tempfile.mktemp();
489     fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
490     os.close(fd);
491     sources = location + prefix + 'Sources.gz';
492     (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename));
493     if (result != 0):
494         utils.fubar("Gunzip invocation failed!\n%s" % (output), result);
495     print 'Processing '+sources+'...';
496     process_sources (location, temp_filename, suite, component, server, os.path.dirname(sources));
497     os.unlink(temp_filename);
498
499 ###############################################################################
500
501 def main ():
502     global Cnf, projectB, query_cache, files_query_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, bin_associations_query_cache, binaries_query_cache;
503
504     Cnf = utils.get_conf();
505
506     print "Re-Creating DB..."
507     (result, output) = commands.getstatusoutput("psql -f init_pool.sql template1");
508     if (result != 0):
509         utils.fubar("psql invocation failed!\n", result);
510     print output;
511
512     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
513
514     db_access.init (Cnf, projectB);
515
516     print "Adding static tables from conf file..."
517     projectB.query("BEGIN WORK");
518     update_architectures();
519     update_components();
520     update_archives();
521     update_locations();
522     update_suites();
523     update_override_type();
524     update_priority();
525     projectB.query("COMMIT WORK");
526
527     files_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"files","w");
528     source_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"source","w");
529     src_associations_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"src_associations","w");
530     dsc_files_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"dsc_files","w");
531     binaries_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"binaries","w");
532     bin_associations_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"bin_associations","w");
533
534     projectB.query("BEGIN WORK");
535     # Process Sources files to popoulate `source' and friends
536     for location in Cnf.SubTree("Location").List():
537         SubSec = Cnf.SubTree("Location::%s" % (location));
538         server = SubSec["Archive"];
539         type = Cnf.Find("Location::%s::Type" % (location));
540         if type == "legacy-mixed":
541             prefix = ''
542             suite = Cnf.Find("Location::%s::Suite" % (location));
543             do_sources(location, prefix, suite, "",  server);
544         elif type == "legacy":
545             for suite in Cnf.ValueList("Location::%s::Suites" % (location)):
546                 for component in Cnf.SubTree("Component").List():
547                     prefix = Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/source/'
548                     do_sources(location, prefix, suite, component, server);
549         elif type == "pool":
550             continue;
551 #            for component in Cnf.SubTree("Component").List():
552 #                prefix = component + '/'
553 #                do_sources(location, prefix);
554         else:
555             utils.fubar("Unknown location type ('%s')." % (type));
556
557     # Process Packages files to populate `binaries' and friends
558
559     for location in Cnf.SubTree("Location").List():
560         SubSec = Cnf.SubTree("Location::%s" % (location));
561         server = SubSec["Archive"];
562         type = Cnf.Find("Location::%s::Type" % (location));
563         if type == "legacy-mixed":
564             packages = location + 'Packages';
565             suite = Cnf.Find("Location::%s::Suite" % (location));
566             print 'Processing '+location+'...';
567             process_packages (location, packages, suite, "", server);
568         elif type == "legacy":
569             for suite in Cnf.ValueList("Location::%s::Suites" % (location)):
570                 for component in Cnf.SubTree("Component").List():
571                     architectures = filter(utils.real_arch,
572                                            Cnf.ValueList("Suite::%s::Architectures" % (suite)));
573                     for architecture in architectures:
574                         packages = location + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/binary-' + architecture + '/Packages'
575                         print 'Processing '+packages+'...';
576                         process_packages (location, packages, suite, component, server);
577         elif type == "pool":
578             continue;
579
580     files_query_cache.close();
581     source_query_cache.close();
582     src_associations_query_cache.close();
583     dsc_files_query_cache.close();
584     binaries_query_cache.close();
585     bin_associations_query_cache.close();
586     print "Writing data to `files' table...";
587     projectB.query("COPY files FROM '%s'" % (Cnf["Neve::ExportDir"]+"files"));
588     print "Writing data to `source' table...";
589     projectB.query("COPY source FROM '%s'" % (Cnf["Neve::ExportDir"]+"source"));
590     print "Writing data to `src_associations' table...";
591     projectB.query("COPY src_associations FROM '%s'" % (Cnf["Neve::ExportDir"]+"src_associations"));
592     print "Writing data to `dsc_files' table...";
593     projectB.query("COPY dsc_files FROM '%s'" % (Cnf["Neve::ExportDir"]+"dsc_files"));
594     print "Writing data to `binaries' table...";
595     projectB.query("COPY binaries FROM '%s'" % (Cnf["Neve::ExportDir"]+"binaries"));
596     print "Writing data to `bin_associations' table...";
597     projectB.query("COPY bin_associations FROM '%s'" % (Cnf["Neve::ExportDir"]+"bin_associations"));
598     print "Committing...";
599     projectB.query("COMMIT WORK");
600
601     # Add the constraints and otherwise generally clean up the database.
602     # See add_constraints.sql for more details...
603
604     print "Running add_constraints.sql...";
605     (result, output) = commands.getstatusoutput("psql %s < add_constraints.sql" % (Cnf["DB::Name"]));
606     print output
607     if (result != 0):
608         utils.fubar("psql invocation failed!\n%s" % (output), result);
609
610     return;
611
612 if __name__ == '__main__':
613     main();