4 # Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
5 # $Id: hack.5,v 1.1 2001-05-17 01:01:51 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, re
31 import utils, db_access
34 ################################################################################
39 re_parse_bin_filename = re.compile(r"(.+?)_(.+?)_(.+?)\.(.+?)")
40 re_parse_src_filename = re.compile(r"(.+?)_(.+?)\.dsc")
42 ################################################################################
45 global Cnf, projectB, db_files, waste, excluded;
49 Cnf = apt_pkg.newConfiguration();
50 apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
52 Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"),
53 ('h',"help","Christina::Options::Help"),
54 ('v',"version","Christina::Options::Version")];
56 changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
57 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
58 db_access.init(Cnf, projectB);
60 for changes_file in changes_files:
62 changes = utils.parse_changes(changes_file, 0)
63 files = utils.build_file_list(changes, "");
64 for file in files.keys():
65 if file[-4:] == ".deb":
66 m = re_parse_bin_filename.match(file)
69 architecture = m.group(3);
71 q = projectB.query("SELECT b.id FROM binaries b, bin_associations ba, architecture a WHERE b.id = ba.bin AND ba.suite = 3 AND b.package = '%s' AND b.version = '%s' AND a.id = b.architecture AND a.arch_string = '%s'" % (package, version, architecture));
74 #print "[MISSING] Package: %s, version: %s, architecture: %s" % (package, version, architecture);
78 print "DELETE FROM bin_associations WHERE bin = %s AND suite = 3;" % (id);
79 projectB.query("DELETE FROM bin_associations WHERE bin = %s AND suite = 3;" % (id));
80 #print "[%s] Package: %s, version: %s, architecture: %s" % (id, package, version, architecture);
84 elif file[-4:] == ".dsc":
85 m = re_parse_src_filename.match(file)
88 q = projectB.query("SELECT s.id FROM source s, src_associations sa WHERE s.id = sa.source AND sa.suite = 3 AND s.source = '%s' AND s.version = '%s'" % (package, version));
91 #print "[MISSING] Package: %s, version: %s, architecture: source" % (package, version);
95 print "DELETE FROM src_associations WHERE source = %s AND suite = 3;" % (id);
96 projectB.query("DELETE FROM src_associations WHERE source = %s AND suite = 3;" % (id));
97 #print "[%s] Package: %s, version: %s, architecture: source" % (id, package, version);
101 #######################################################################################
103 if __name__ == '__main__':