+ output.write(packages[package]+'\n')
+
+#########################################################################################
+
+##########
+# <elmo> I'm doing it in python btw.. nothing against your monster
+# SQL, but the python wins in terms of speed and readiblity
+# <aj> bah
+# <aj> you suck!!!!!
+# <elmo> sorry :(
+# <aj> you are not!!!
+# <aj> you mock my SQL!!!!
+# <elmo> you want have contest of skillz??????
+# <aj> all your skillz are belong to my sql!!!!
+# <elmo> yo momma are belong to my python!!!!
+# <aj> yo momma was SQLin' like a pig last night!
+##########
+
+# If something has gone from arch:all to arch:any or vice-versa,
+# clean out the old versions here. The rest of jenna won't do this
+# because it's lame. I have no idea. </aj>
+
+def clean_duplicate_packages(suite):
+ Logger.log(["Cleaning duplicate packages", suite]);
+
+ suite_id = db_access.get_suite_id(suite)
+ q = projectB.query("""
+SELECT b1.package,
+ b1.id, b1.version, a1.arch_string,
+ b2.id, b2.version, a2.arch_string
+ FROM bin_associations ba1, binaries b1, architecture a1,
+ bin_associations ba2, binaries b2, architecture a2
+ WHERE ba1.suite = ba2.suite AND ba1.suite = %s
+ AND ba1.bin = b1.id AND b1.architecture = a1.id
+ AND ba2.bin = b2.id AND b2.architecture = a2.id
+ AND b1.package = b2.package
+ AND (a1.id = a2.id OR a1.arch_string = 'all' OR a2.arch_string = 'all')
+ AND b1.id != b2.id
+ AND versioncmp(b1.version, b2.version) <= 0
+ORDER BY b1.package, b1.version, a1.arch_string;""" % (suite_id))
+
+ ql = q.getresult()
+ seen = {}
+ for i in ql:
+ (package, oldid, oldver, oldarch, newid, newver, newarch) = i
+ if not seen.has_key(oldid):
+ seen[oldid] = newid
+ Logger.log(["Removing", package, oldver, oldarch, newver, newarch]);
+ projectB.query("DELETE FROM bin_associations WHERE suite = %s AND bin = %s" % (suite_id, oldid))
+ else:
+ Logger.log(["Superceded", package, oldver, oldarch, newver, newarch]);
+
+# If something has moved from one component to another we need to
+# clean out the old versions here. The rest of jenna won't do this
+# because it works on a per-component level for flexibility.
+
+def clean_suite (suite):
+ Logger.log(["Cleaning out packages", suite]);
+
+ suite_id = db_access.get_suite_id(suite)
+ q = projectB.query("""
+SELECT b.id, b.package, a.arch_string, b.version, l.path, f.filename, c.name
+ FROM binaries b, bin_associations ba, files f, location l, architecture a, component c
+ WHERE ba.suite = %s AND ba.bin = b.id AND b.file = f.id AND
+ f.location = l.id AND l.component = c.id AND b.architecture = a.id
+UNION
+SELECT s.id, s.source, 'source', s.version, l.path, f.filename, c.name
+ FROM source s, src_associations sa, files f, location l, component c
+ WHERE sa.suite = %s AND sa.source = s.id AND s.file = f.id AND
+ f.location = l.id AND l.component = c.id;""" % (suite_id, suite_id));
+ ql = q.getresult();
+ d = {};
+ for i in ql:
+ (id, package, architecture, version, path, filename, component) = i;
+ filename = path + filename;
+ if architecture == "source":
+ delete_table = "src_associations";
+ delete_col = "source";
+ else:
+ delete_table = "bin_associations";
+ delete_col = "bin";
+ key = "%s~%s" % (package, architecture);
+ if os.path.exists(filename):
+ if d.has_key(key):
+ (other_version, other_component, other_id) = d[key];
+ if apt_pkg.VersionCompare(version, other_version) != 1:
+ (keep_version, keep_component) = (other_version, other_component)
+ (delete_id, delete_version, delete_component) = (id, version, component)
+ else:
+ (keep_version, keep_component) = (version, component)
+ (delete_id, delete_version, delete_component) = (other_id, other_version, other_component)
+ d[key] = (version, component, id);
+ if not Cnf.Find("Suite::%s::Untouchable" % (suite)):
+ Logger.log(["deleting", package, architecture, delete_version, delete_component, keep_version, keep_component]);
+ projectB.query("DELETE FROM %s WHERE suite = %s AND %s = %s" % (delete_table, suite_id, delete_col, delete_id));
+ else:
+ Logger.log(["[untouchable]", package, architecture, delete_version, delete_component, keep_version, keep_component]);
+ else:
+ d[key] = (version, component, id);
+ else:
+ utils.warn("%s is in %s but doesn't appear to exist?" % (filename, suite));
+
+#########################################################################################