--- /dev/null
+#!/usr/bin/env python
+
+# Whee! Fix testing fubarity
+# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
+# $Id: hack.4,v 1.1 2001-03-14 20:32:05 troup Exp $
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+################################################################################
+
+# Computer games don't affect kids. I mean if Pacman affected our generation as
+# kids, we'd all run around in a darkened room munching pills and listening to
+# repetitive music.
+# -- Unknown
+
+################################################################################
+
+import pg, sys, os, string, stat
+import utils, db_access
+import apt_pkg;
+
+################################################################################
+
+Cnf = None;
+projectB = None;
+
+################################################################################
+
+def main ():
+ global Cnf, projectB, db_files, waste, excluded;
+
+ apt_pkg.init();
+
+ Cnf = apt_pkg.newConfiguration();
+ apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
+
+ Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
+ ('h',"help","Christina::Options::Help"),
+ ('v',"version","Christina::Options::Version")];
+
+ apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
+ projectB = pg.connect('projectb', 'localhost');
+ christina = pg.connect('christina', 'localhost');
+ db_access.init(Cnf, projectB);
+
+ # Source without dsc_file entries
+ 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;");
+ ql = q.getresult();
+ projectB.query("BEGIN WORK;")
+ for i in ql:
+ source_id = i[0];
+ dsc_file_id = i[1];
+ dsc_filename = i[2] + i[3];
+ dsc_dir = os.path.dirname(i[3]);
+ # We get the .dsc for free
+ print "INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, dsc_file_id);
+ projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, dsc_file_id));
+ # Then work out the files.id of the other files
+ dsc = utils.parse_changes(dsc_filename, 0);
+ dsc_files = utils.build_file_list(dsc, 1);
+ for dsc_file in dsc_files.keys():
+ if dsc_file[-4:] != ".dsc":
+ filename = dsc_dir + '/' + dsc_file;
+ x = projectB.query("SELECT id FROM files WHERE filename = '%s'" % (filename));
+ xl = x.getresult();
+ if len(xl) != 1:
+ # No? probably s/woody/potato/ BS.. try again with ~ and only the filename
+ x = projectB.query("SELECT id FROM files WHERE filename ~ '%s$'" % (utils.regex_safe(dsc_file)));
+ xl = x.getresult();
+ if len(xl) != 1:
+ print filename
+ print xl
+ sys.exit(9);
+ print "INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, xl[0][0]);
+ projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s)" % (source_id, xl[0][0]));
+
+ projectB.query("COMMIT WORK;");
+
+ sys.exit(0);
+
+#######################################################################################
+
+if __name__ == '__main__':
+ main()
+
+# source_id = i[0];
+# source_name = i[1];
+# source_version = i[2];
+# 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);
+# 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));
+# xl = x.getresult();
+# if len(xl) < 2 or len(xl) > 3:
+# print xl
+# continue;
+# #sys.exit(9);
+# for j in xl:
+# df_source = source_id;
+# print "SELECT filename, location FROM files WHERE id = %s;" % (j[0]);
+# x1 = christina.query("SELECT filename, location FROM files WHERE id = %s;" % (j[0]));
+# x1l = x1.getresult();
+# if len(x1l) != 1:
+# print x1l
+# sys.exit(9);
+# filename = x1l[0][0];
+# location = x1l[0][1];
+# print "SELECT id FROM files WHERE filename = '%s' AND location = %s;" % (filename, location);
+# x2 = projectB.query("SELECT id FROM files WHERE filename = '%s' AND location = %s;" % (filename, location));
+# x2l = x2.getresult();
+# if len(x2l) != 1:
+# print x2l
+# sys.exit(9);
+# df_file = x2l[0][0];
+# projectB.query("INSERT INTO dsc_files (source, file) VALUES (%s, %s);" % (df_source, df_file));
+# print "INSERT INTO dsc_files (source, file) VALUES (%s, %s);" % (df_source, df_file);