+# Check for packages built on architectures they shouldn't be.
+def do_anais(architecture, binaries_list, source):
+ if architecture == "any" or architecture == "all":
+ return "";
+
+ anais_output = "";
+ architectures = {};
+ for arch in architecture.split():
+ architectures[arch.strip()] = "";
+ for binary in binaries_list:
+ q = projectB.query("SELECT a.arch_string, b.version FROM binaries b, bin_associations ba, architecture a WHERE ba.suite = %s AND ba.bin = b.id AND b.architecture = a.id AND b.package = '%s'" % (suite_id, binary));
+ ql = q.getresult();
+ versions = [];
+ for i in ql:
+ arch = i[0];
+ version = i[1];
+ if architectures.has_key(arch):
+ versions.append(version);
+ versions.sort(apt_pkg.VersionCompare);
+ if versions:
+ latest_version = versions.pop()
+ else:
+ latest_version = None;
+ # Check for 'invalid' architectures
+ versions_d = {}
+ for i in ql:
+ arch = i[0];
+ version = i[1];
+ if not architectures.has_key(arch):
+ versions_d.setdefault(version, [])
+ versions_d[version].append(arch)
+
+ if versions_d != {}:
+ anais_output += "\n (*) %s_%s [%s]: %s\n" % (binary, latest_version, source, architecture);
+ versions = versions_d.keys();
+ versions.sort(apt_pkg.VersionCompare);
+ for version in versions:
+ arches = versions_d[version];
+ arches.sort();
+ anais_output += " o %s: %s\n" % (version, ", ".join(arches));
+ return anais_output;
+
+################################################################################
+
+def do_nviu():
+ experimental_id = db_access.get_suite_id("experimental");
+ if experimental_id == -1:
+ return;
+ # Check for packages in experimental obsoleted by versions in unstable
+ q = projectB.query("""
+SELECT s.source, s.version AS experimental, s2.version AS unstable
+ FROM src_associations sa, source s, source s2, src_associations sa2
+ WHERE sa.suite = %s AND sa2.suite = %d AND sa.source = s.id
+ AND sa2.source = s2.id AND s.source = s2.source
+ AND versioncmp(s.version, s2.version) < 0""" % (experimental_id,
+ db_access.get_suite_id("unstable")));
+ ql = q.getresult();
+ if ql:
+ nviu_to_remove = [];
+ print "Newer version in unstable";
+ print "-------------------------";
+ print ;
+ for i in ql:
+ (source, experimental_version, unstable_version) = i;
+ print " o %s (%s, %s)" % (source, experimental_version, unstable_version);
+ nviu_to_remove.append(source);
+ print
+ print "Suggested command:"
+ print " melanie -m \"[rene] NVIU\" -s experimental %s" % (" ".join(nviu_to_remove));
+ print
+
+################################################################################
+
+def do_nbs(real_nbs):
+ output = "Not Built from Source\n";
+ output += "---------------------\n\n";
+
+ nbs_to_remove = [];
+ nbs_keys = real_nbs.keys();
+ nbs_keys.sort();
+ for source in nbs_keys:
+ output += " * %s_%s builds: %s\n" % (source,
+ source_versions.get(source, "??"),
+ source_binaries.get(source, "(source does not exist)"));
+ output += " but no longer builds:\n"
+ versions = real_nbs[source].keys();
+ versions.sort(apt_pkg.VersionCompare);
+ for version in versions:
+ packages = real_nbs[source][version].keys();
+ packages.sort();
+ for pkg in packages:
+ nbs_to_remove.append(pkg);
+ output += " o %s: %s\n" % (version, ", ".join(packages));
+
+ output += "\n";
+
+ if nbs_to_remove:
+ print output;
+
+ print "Suggested command:"
+ print " melanie -m \"[rene] NBS\" -b %s" % (" ".join(nbs_to_remove));
+ print
+
+################################################################################
+
+def do_dubious_nbs(dubious_nbs):
+ print "Dubious NBS";
+ print "-----------";
+ print ;
+
+ dubious_nbs_keys = dubious_nbs.keys();
+ dubious_nbs_keys.sort();
+ for source in dubious_nbs_keys:
+ print " * %s_%s builds: %s" % (source,
+ source_versions.get(source, "??"),
+ source_binaries.get(source, "(source does not exist)"));
+ print " won't admit to building:"
+ versions = dubious_nbs[source].keys();
+ versions.sort(apt_pkg.VersionCompare);
+ for version in versions:
+ packages = dubious_nbs[source][version].keys();
+ packages.sort();
+ print " o %s: %s" % (version, ", ".join(packages));
+
+ print ;
+
+################################################################################
+
+def do_obsolete_source(duplicate_bins, bin2source):
+ obsolete = {}
+ for key in duplicate_bins.keys():
+ (source_a, source_b) = key.split('~')
+ for source in [ source_a, source_b ]:
+ if not obsolete.has_key(source):
+ if not source_binaries.has_key(source):
+ # Source has already been removed
+ continue;
+ else:
+ obsolete[source] = map(string.strip,
+ source_binaries[source].split(','))
+ for binary in duplicate_bins[key]:
+ if bin2source.has_key(binary) and bin2source[binary]["source"] == source:
+ continue
+ if binary in obsolete[source]:
+ obsolete[source].remove(binary)
+
+ to_remove = []
+ output = "Obsolete source package\n"
+ output += "-----------------------\n\n"
+ obsolete_keys = obsolete.keys()
+ obsolete_keys.sort()
+ for source in obsolete_keys:
+ if not obsolete[source]:
+ to_remove.append(source)
+ output += " * %s (%s)\n" % (source, source_versions[source])
+ for binary in map(string.strip, source_binaries[source].split(',')):
+ if bin2source.has_key(binary):
+ output += " o %s (%s) is built by %s.\n" \
+ % (binary, bin2source[binary]["version"],
+ bin2source[binary]["source"])
+ else:
+ output += " o %s is not built.\n" % binary
+ output += "\n"
+
+ if to_remove:
+ print output;
+
+ print "Suggested command:"
+ print " melanie -S -p -m \"[rene] obsolete source package\" %s" % (" ".join(to_remove));
+ print
+
+################################################################################
+