+ # arch: any dominates
+ delete_packages(arch_all_versions, pkg, "any", suite,
+ highest_arch_any_version, delete_table, delete_col,
+ packages);
+
+#####################################################
+
+# Per-suite&pkg&arch: resolve duplicate versions
+def remove_duplicate_versions(versions, packages):
+ # Sort versions into descending order
+ versions.sort(version_cmp);
+ dominant_versions = versions[0];
+ dominated_versions = versions[1:];
+ (dominant_version, dominant_unqiue_id) = dominant_versions;
+ pkg = packages[dominant_unqiue_id]["pkg"];
+ arch = packages[dominant_unqiue_id]["arch"];
+ suite = packages[dominant_unqiue_id]["suite"];
+ if arch == "source":
+ delete_table = "src_associations";
+ delete_col = "source";
+ else: # !source
+ delete_table = "bin_associations";
+ delete_col = "bin";
+ # Remove all but the highest
+ delete_packages(dominated_versions, pkg, arch, suite,
+ dominant_version, delete_table, delete_col, packages);
+ return [dominant_versions];
+
+################################################################################
+
+def cleanup(packages):
+ # Build up the index used by the clean up functions
+ d = {};
+ for unique_id in packages.keys():
+ suite = packages[unique_id]["suite"];
+ pkg = packages[unique_id]["pkg"];
+ arch = packages[unique_id]["arch"];
+ version = packages[unique_id]["version"];
+ d.setdefault(suite, {});
+ d[suite].setdefault(pkg, {});
+ d[suite][pkg].setdefault(arch, []);
+ d[suite][pkg][arch].append([version, unique_id]);
+ # Clean up old versions
+ for suite in d.keys():
+ for pkg in d[suite].keys():
+ for arch in d[suite][pkg].keys():
+ versions = d[suite][pkg][arch];
+ if len(versions) > 1:
+ d[suite][pkg][arch] = remove_duplicate_versions(versions, packages);
+
+ # Arch: all -> any and vice versa
+ for suite in d.keys():
+ for pkg in d[suite].keys():
+ arches = d[suite][pkg];
+ # If we don't have any arch: all; we've nothing to do
+ if not arches.has_key("all"):
+ continue;
+ # Check to see if we have arch: all and arch: !all (ignoring source)
+ num_arches = len(arches.keys());
+ if arches.has_key("source"):
+ num_arches -= 1;
+ # If we do, remove the duplicates
+ if num_arches > 1:
+ versions = [];
+ for arch in arches.keys():
+ if arch != "source":
+ versions.extend(d[suite][pkg][arch]);
+ resolve_arch_all_vs_any(versions, packages);
+
+################################################################################
+
+def write_legacy_mixed_filelist(suite, list, packages, dislocated_files):
+ # Work out the filename
+ filename = os.path.join(Cnf["Dir::Lists"], "%s_-_all.list" % (suite));
+ output = utils.open_file(filename, "w");
+ # Generate the final list of files
+ files = {};
+ for id in list:
+ path = packages[id]["path"];
+ filename = packages[id]["filename"];
+ file_id = packages[id]["file_id"];
+ if suite == "stable" and dislocated_files.has_key(file_id):