3 # Whee! Fix testing fubarity
4 # Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
5 # $Id: hack.4,v 1.1 2001-03-14 20:32:05 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 # Computer games don't affect kids. I mean if Pacman affected our generation as
24 # kids, we'd all run around in a darkened room munching pills and listening to
28 ################################################################################
30 import pg, sys, os, string, stat
31 import utils, db_access
34 ################################################################################
39 ################################################################################
42 global Cnf, projectB, db_files, waste, excluded;
46 Cnf = apt_pkg.newConfiguration();
47 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
49 Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
50 ('h',"help","Christina::Options::Help"),
51 ('v',"version","Christina::Options::Version")];
53 apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
54 projectB = pg.connect('projectb', 'localhost');
55 christina = pg.connect('christina', 'localhost');
56 db_access.init(Cnf, projectB);
58 # Source without dsc_file entries
59 q = projectB.query("SELECT s.id, f.id, l.path, f.filename FROM source s, files f, location l WHERE NOT EXISTS (SELECT df.* FROM dsc_files df WHERE df.source = s.id) and f.id = s.file and l.id = f.location;");
61 projectB.query("BEGIN WORK;")
65 dsc_filename = i[2] + i[3];
66 dsc_dir = os.path.dirname(i[3]);
67 # We get the .dsc for free
68 print "INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, dsc_file_id);
69 projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, dsc_file_id));
70 # Then work out the files.id of the other files
71 dsc = utils.parse_changes(dsc_filename, 0);
72 dsc_files = utils.build_file_list(dsc, 1);
73 for dsc_file in dsc_files.keys():
74 if dsc_file[-4:] != ".dsc":
75 filename = dsc_dir + '/' + dsc_file;
76 x = projectB.query("SELECT id FROM files WHERE filename = '%s'" % (filename));
79 # No? probably s/woody/potato/ BS.. try again with ~ and only the filename
80 x = projectB.query("SELECT id FROM files WHERE filename ~ '%s$'" % (utils.regex_safe(dsc_file)));
86 print "INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, xl[0][0]);
87 projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, xl[0][0]));
89 projectB.query("COMMIT WORK;");
93 #######################################################################################
95 if __name__ == '__main__':
100 # source_version = i[2];
101 # print "SELECT df.file FROM dsc_files df, source s WHERE s.source = '%s' AND s.version = '%s' AND df.source = s.id;" % (source_name, source_version);
102 # x = christina.query("SELECT df.file FROM dsc_files df, source s WHERE s.source = '%s' AND s.version = '%s' AND df.source = s.id;" % (source_name, source_version));
103 # xl = x.getresult();
104 # if len(xl) < 2 or len(xl) > 3:
109 # df_source = source_id;
110 # print "SELECT filename, location FROM files WHERE id = %s;" % (j[0]);
111 # x1 = christina.query("SELECT filename, location FROM files WHERE id = %s;" % (j[0]));
112 # x1l = x1.getresult();
116 # filename = x1l[0][0];
117 # location = x1l[0][1];
118 # print "SELECT id FROM files WHERE filename = '%s' AND location = %s;" % (filename, location);
119 # x2 = projectB.query("SELECT id FROM files WHERE filename = '%s' AND location = %s;" % (filename, location));
120 # x2l = x2.getresult();
124 # df_file = x2l[0][0];
125 # projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s);" % (df_source, df_file));
126 # print "INSERT INTO dsc_files (source, file) VALUES (%s, %s);" % (df_source, df_file);