+def check_distributions():
+ "Check and map the Distribution field of a .changes file."
+
+ # Handle suite mappings
+ for map in Cnf.ValueList("SuiteMappings"):
+ args = map.split();
+ type = args[0];
+ if type == "map" or type == "silent-map":
+ (source, dest) = args[1:3];
+ if changes["distribution"].has_key(source):
+ del changes["distribution"][source]
+ changes["distribution"][dest] = 1;
+ if type != "silent-map":
+ reject("Mapping %s to %s." % (source, dest),"");
+ if changes.has_key("distribution-version"):
+ if changes["distribution-version"].has_key(source):
+ changes["distribution-version"][source]=dest
+ elif type == "map-unreleased":
+ (source, dest) = args[1:3];
+ if changes["distribution"].has_key(source):
+ for arch in changes["architecture"].keys():
+ if arch not in Cnf.ValueList("Suite::%s::Architectures" % (source)):
+ reject("Mapping %s to %s for unreleased architecture %s." % (source, dest, arch),"");
+ del changes["distribution"][source];
+ changes["distribution"][dest] = 1;
+ break;
+ elif type == "ignore":
+ suite = args[1];
+ if changes["distribution"].has_key(suite):
+ del changes["distribution"][suite];
+ reject("Ignoring %s as a target suite." % (suite), "Warning: ");
+ elif type == "reject":
+ suite = args[1];
+ if changes["distribution"].has_key(suite):
+ reject("Uploads to %s are not accepted." % (suite));
+ elif type == "propup-version":
+ # give these as "uploaded-to(non-mapped) suites-to-add-when-upload-obsoletes"
+ #
+ # changes["distribution-version"] looks like: {'testing': 'testing-proposed-updates'}
+ if changes["distribution"].has_key(args[1]):
+ changes.setdefault("distribution-version", {})
+ for suite in args[2:]: changes["distribution-version"][suite]=suite
+
+ # Ensure there is (still) a target distribution
+ if changes["distribution"].keys() == []:
+ reject("no valid distribution.");
+
+ # Ensure target distributions exist
+ for suite in changes["distribution"].keys():
+ if not Cnf.has_key("Suite::%s" % (suite)):
+ reject("Unknown distribution `%s'." % (suite));
+
+################################################################################
+
+def check_deb_ar(filename, control):
+ """Sanity check the ar of a .deb, i.e. that there is:
+
+ o debian-binary
+ o control.tar.gz
+ o data.tar.gz or data.tar.bz2
+
+in that order, and nothing else. If the third member is a
+data.tar.bz2, an additional check is performed for the required
+Pre-Depends on dpkg (>= 1.10.24)."""
+ cmd = "ar t %s" % (filename)
+ (result, output) = commands.getstatusoutput(cmd)
+ if result != 0:
+ reject("%s: 'ar t' invocation failed." % (filename))
+ reject(utils.prefix_multi_line_string(output, " [ar output:] "), "")
+ chunks = output.split('\n')
+ if len(chunks) != 3:
+ reject("%s: found %d chunks, expected 3." % (filename, len(chunks)))
+ if chunks[0] != "debian-binary":
+ reject("%s: first chunk is '%s', expected 'debian-binary'." % (filename, chunks[0]))
+ if chunks[1] != "control.tar.gz":
+ reject("%s: second chunk is '%s', expected 'control.tar.gz'." % (filename, chunks[1]))
+ if chunks[2] == "data.tar.bz2":
+ # Packages using bzip2 compression must have a Pre-Depends on dpkg >= 1.10.24.
+ found_needed_predep = 0
+ for parsed_dep in apt_pkg.ParseDepends(control.Find("Pre-Depends", "")):
+ for atom in parsed_dep:
+ (dep, version, constraint) = atom
+ if dep != "dpkg" or (constraint != ">=" and constraint != ">>") or \
+ len(parsed_dep) > 1: # or'ed deps don't count
+ continue
+ if (constraint == ">=" and apt_pkg.VersionCompare(version, "1.10.24") < 0) or \
+ (constraint == ">>" and apt_pkg.VersionCompare(version, "1.10.23") < 0):
+ continue
+ found_needed_predep = 1
+ if not found_needed_predep:
+ reject("%s: uses bzip2 compression, but doesn't Pre-Depend on dpkg (>= 1.10.24)" % (filename))
+ elif chunks[2] != "data.tar.gz":
+ reject("%s: third chunk is '%s', expected 'data.tar.gz' or 'data.tar.bz2'." % (filename, chunks[2]))
+
+################################################################################
+