+ # Write the list of files out
+ package_keys = packages.keys();
+ package_keys.sort();
+ for package in package_keys:
+ 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):
+ print "Cleaning duplicate packages for %s..." % (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
+ print "Removing %s %s on %s (ifo %s/%s)" % (package, oldver, oldarch, newver, newarch)
+ projectB.query("DELETE FROM bin_associations WHERE suite = %s AND bin = %s" % (suite_id, oldid))
+ else:
+ print "%s %s on %s also superceded by %s/%s" % (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):
+ print "Cleaning out packages for %s..." % (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);