+#!/usr/bin/env python
+
+# ???
+# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
+# $Id: hack.5,v 1.1 2001-05-17 01:01:51 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, re
+import utils, db_access
+import apt_pkg;
+
+################################################################################
+
+Cnf = None;
+projectB = None;
+
+re_parse_bin_filename = re.compile(r"(.+?)_(.+?)_(.+?)\.(.+?)")
+re_parse_src_filename = re.compile(r"(.+?)_(.+?)\.dsc")
+
+################################################################################
+
+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")];
+
+ changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
+ projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
+ db_access.init(Cnf, projectB);
+
+ for changes_file in changes_files:
+ #print changes_file
+ changes = utils.parse_changes(changes_file, 0)
+ files = utils.build_file_list(changes, "");
+ for file in files.keys():
+ if file[-4:] == ".deb":
+ m = re_parse_bin_filename.match(file)
+ package = m.group(1);
+ version = m.group(2);
+ architecture = m.group(3);
+ type = m.group(4)
+ 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));
+ ql = q.getresult();
+ if len(ql) == 0:
+ #print "[MISSING] Package: %s, version: %s, architecture: %s" % (package, version, architecture);
+ foo = 0;
+ elif len(ql) == 1:
+ id = ql[0][0];
+ print "DELETE FROM bin_associations WHERE bin = %s AND suite = 3;" % (id);
+ projectB.query("DELETE FROM bin_associations WHERE bin = %s AND suite = 3;" % (id));
+ #print "[%s] Package: %s, version: %s, architecture: %s" % (id, package, version, architecture);
+ else:
+ print "[FUBAR]"
+
+ elif file[-4:] == ".dsc":
+ m = re_parse_src_filename.match(file)
+ package = m.group(1);
+ version = m.group(2);
+ 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));
+ ql = q.getresult();
+ if len(ql) == 0:
+ #print "[MISSING] Package: %s, version: %s, architecture: source" % (package, version);
+ foo = 0;
+ elif len(ql) == 1:
+ id = ql[0][0];
+ print "DELETE FROM src_associations WHERE source = %s AND suite = 3;" % (id);
+ projectB.query("DELETE FROM src_associations WHERE source = %s AND suite = 3;" % (id));
+ #print "[%s] Package: %s, version: %s, architecture: source" % (id, package, version);
+ else:
+ print "[FUBAR]"
+
+#######################################################################################
+
+if __name__ == '__main__':
+ main()
+