3 # Fix for bug in katie where dsc_files was initialized from changes and not dsc
4 # Copyright (C) 2000 James Troup <james@nocrew.org>
5 # $Id: fix.9,v 1.2 2000-12-18 07:11:25 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 # "Look around... leaves are brown... and the sky is hazy shade of winter,
22 # Look around... leaves are brown... there's a patch of snow on the ground."
23 # -- Simon & Garfunkel / 'A Hazy Shade'
25 ################################################################################
27 import pg, sys, os, string, stat
28 import utils, db_access
31 ################################################################################
36 ################################################################################
43 Cnf = apt_pkg.newConfiguration();
44 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
46 Arguments = [('d',"debug","Claire::Options::Debug", "IntVal"),
47 ('h',"help","Claire::Options::Help"),
48 ('v',"version","Claire::Options::Version")];
50 apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
52 projectB = pg.connect('projectb', 'localhost');
54 db_access.init(Cnf, projectB);
56 for dsc_file in sys.stdin.readlines():
57 dsc_file = dsc_file[:-1];
58 base_dsc_file = os.path.basename(dsc_file);
60 dsc = utils.parse_changes(dsc_file);
61 dsc_files = utils.build_file_list(dsc, 1);
62 q = projectB.query("SELECT s.id, l.id, l.path FROM source s, location l, files f WHERE s.source = '%s' AND s.version = '%s' AND f.id = s.file AND f.location = l.id" % (dsc["source"], dsc["version"]));
64 if ql == [] or len(ql) > 1:
65 print " EEEEEEEEEEEEEEK!!!"
66 print " ",base_dsc_file
68 location_id = ql[0][1];
70 dsc_files[base_dsc_file] = {};
71 dsc_files[base_dsc_file]["size"] = os.stat(dsc_file)[stat.ST_SIZE];
72 dsc_files[base_dsc_file]["md5sum"] = apt_pkg.md5sum(utils.open_file(dsc_file,"r"));
73 q = projectB.query("SELECT f.filename FROM dsc_files df, source s, files f WHERE s.id = '%s' AND df.source = s.id AND f.id = df.file" % (source_id));
74 for i in q.getresult():
75 file = os.path.basename(i[0]);
76 if not dsc_files.has_key(file):
77 if file != base_dsc_file:
78 print " MWAAAP! MWAAP! Can't find %s!" % (file)
81 for i in dsc_files.keys():
82 filename = os.path.dirname(dsc_file) + '/' + i;
83 if not os.path.exists(filename):
84 print " MWAAP!!!!!!!!!!!!!"
86 filename = string.replace(filename, location, '');
87 #print " filename: ",filename
88 #print " size: ", dsc_files[i]["size"]
89 #print " md5sum: ",dsc_files[i]["md5sum"]
90 #print " location_id: ", location_id
91 files_id = db_access.get_files_id(filename, dsc_files[i]["size"], dsc_files[i]["md5sum"], location_id);
92 if files_id < 0 or files_id == None:
93 print " BORK!!!!!!!!!!!!"
97 #print "INSERT INTO dsc_files (source, file) VALUES ('%s', '%s')" % (source_id, files_id);
98 projectB.query("INSERT INTO dsc_files (source, file) VALUES ('%s', '%s')" % (source_id, files_id));
101 #######################################################################################
103 if __name__ == '__main__':