X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=contrib%2Ffix.6;fp=contrib%2Ffix.6;h=6a3c25fe5adb22e4de4a86755bb6a023436c895c;hb=9ebfa30b056df56376cb0302a28a190e0aaed765;hp=0000000000000000000000000000000000000000;hpb=ef9466093b9ea65c0a14286123615e195b9c99a9;p=dak.git diff --git a/contrib/fix.6 b/contrib/fix.6 new file mode 100755 index 00000000..6a3c25fe --- /dev/null +++ b/contrib/fix.6 @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +import pg, string, os, shutil +import utils +import apt_pkg + +def move(src, dest): + if os.path.exists(dest): + print 'overwrite `'+dest+'\'? ', + yn = utils.our_raw_input() + if yn != 'Y' and yn != 'y': + return + print src + ' -> ' + dest + shutil.copyfile (src, dest) + os.unlink (src) + +def main(): + projectB = pg.connect('projectb', 'localhost') + + apt_pkg.init(); + + suite = "unstable"; + architecture = "i386"; + +# too slow to run every time +# "select b.package from binaries b, architecture a where a.arch_string = 'all' and b.architecture = a.id INTERSECT select b.package from binaries b, architecture a where a.arch_string = 'i386' and b.architecture = a.id;" + + borked = utils.open_file('broken', 'r') + for line in borked.readlines(): + package = string.strip(line[:-1]) + + #print "=========" + #print package + q = projectB.query("SELECT b.version, a.arch_string, l.path, b.filename FROM bin_associations ba, binaries b, architecture a, suite s, location l WHERE b.package = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND s.suite_name = '%s' AND ba.bin = b.id AND ba.suite = s.id AND b.architecture = a.id AND l.id = b .location" % (package, architecture, suite)) + entries = q.getresult() + version = {} + filename = "" + for entry in entries: + version[entry[1]] = entry[0] + if entry[1] == "all": + filename = entry[2] + entry[3] + if not version.has_key(architecture) or not version.has_key("all"): + #print "SKIPPING" + continue + if apt_pkg.VersionCompare(version[architecture], version["all"]) != 1: + #print architecture+" too new... SKIPPING" + continue + #print " "+repr(version) + if os.path.exists(filename): + if os.path.islink(filename): + print "FIXING: unlinking %s" % (filename); + os.unlink(filename); + else: + print "FIXING: moving %s to /home/troup/removed-from-ftp/foad/" % (filename); + move(filename, "/home/troup/removed-from-ftp/foad/%s" % (os.path.basename(filename))); + +if __name__ == '__main__': + main() +