- # Enforce mandatory fields
- for i in ("format", "source", "version", "binary", "maintainer", "architecture", "files"):
- if not dsc.has_key(i):
- reject("Missing field `%s' in dsc file." % (i));
-
- # Validate the source and version fields
- if dsc.has_key("source") and not re_valid_pkg_name.match(dsc["source"]):
- reject("%s: invalid source name '%s'." % (file, dsc["source"]));
- if dsc.has_key("version") and not re_valid_version.match(dsc["version"]):
- reject("%s: invalid version number '%s'." % (file, dsc["version"]));
-
- # The dpkg maintainer from hell strikes again! Bumping the
- # version number of the .dsc breaks extraction by stable's
- # dpkg-source.
- if dsc["format"] != "1.0":
- reject("""[dpkg-sucks] source package was produced by a broken version
- of dpkg-dev 1.9.1{3,4}; please rebuild with >= 1.9.15 version
- installed.""");
-
- # Ensure the version number in the .dsc matches the version number in the .changes
- epochless_dsc_version = utils.re_no_epoch.sub('', dsc.get("version"));
- changes_version = files[file]["version"];
- if epochless_dsc_version != files[file]["version"]:
- reject("version ('%s') in .dsc does not match version ('%s') in .changes." % (epochless_dsc_version, changes_version));
-
- # Ensure there is a .tar.gz in the .dsc file
- has_tar = 0;
- for f in dsc_files.keys():
- m = utils.re_issource.match(f);
- if not m:
- reject("%s mentioned in the Files field of %s not recognised as source." % (f, file));
- type = m.group(3);
- if type == "orig.tar.gz" or type == "tar.gz":
- has_tar = 1;
- if not has_tar:
- reject("no .tar.gz or .orig.tar.gz listed in the Files field of %s." % (file));
-
- # Ensure source is newer than existing source in target suites
- reject(Katie.check_source_against_db(file),"");
-
- (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(file);
- reject(reject_msg, "");
- if is_in_incoming:
- if not Options["No-Action"]:
- copy_to_holding(is_in_incoming);
- orig_tar_gz = os.path.basename(is_in_incoming);
- files[orig_tar_gz] = {};
- files[orig_tar_gz]["size"] = os.stat(orig_tar_gz)[stat.ST_SIZE];
- files[orig_tar_gz]["md5sum"] = dsc_files[orig_tar_gz]["md5sum"];
- files[orig_tar_gz]["section"] = files[file]["section"];
- files[orig_tar_gz]["priority"] = files[file]["priority"];
- files[orig_tar_gz]["component"] = files[file]["component"];
- files[orig_tar_gz]["type"] = "orig.tar.gz";
- reprocess = 2;
+ # If there isn't one, we have nothing to do...
+ if not dsc_filename:
+ return;
+
+ # Parse the .dsc file
+ try:
+ dsc.update(utils.parse_changes(dsc_filename, dsc_whitespace_rules=1));
+ except utils.cant_open_exc:
+ # if not -n copy_to_holding() will have done this for us...
+ if Options["No-Action"]:
+ reject("%s: can't read file." % (dsc_filename));
+ except utils.changes_parse_error_exc, line:
+ reject("%s: parse error, can't grok: %s." % (dsc_filename, line));
+ except utils.invalid_dsc_format_exc, line:
+ reject("%s: syntax error on line %s." % (dsc_filename, line));
+ # Build up the file list of files mentioned by the .dsc
+ try:
+ dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1));
+ except utils.no_files_exc:
+ reject("%s: no Files: field." % (dsc_filename));
+ return;
+ except utils.changes_parse_error_exc, line:
+ reject("%s: parse error, can't grok: %s." % (dsc_filename, line));
+ return;
+
+ # Enforce mandatory fields
+ for i in ("format", "source", "version", "binary", "maintainer", "architecture", "files"):
+ if not dsc.has_key(i):
+ reject("%s: missing mandatory field `%s'." % (dsc_filename, i));
+
+ # Validate the source and version fields
+ if dsc.has_key("source") and not re_valid_pkg_name.match(dsc["source"]):
+ reject("%s: invalid source name '%s'." % (dsc_filename, dsc["source"]));
+ if dsc.has_key("version") and not re_valid_version.match(dsc["version"]):
+ reject("%s: invalid version number '%s'." % (dsc_filename, dsc["version"]));
+
+ # Bumping the version number of the .dsc breaks extraction by stable's
+ # dpkg-source. So let's not do that...
+ if dsc["format"] != "1.0":
+ reject("%s: incompatible 'Format' version produced by a broken version of dpkg-dev 1.9.1{3,4}." % (dsc_filename));
+
+ # Validate the build-depends field(s)
+ for field_name in [ "build-depends", "build-depends-indep" ]:
+ field = dsc.get(field_name);
+ if field:
+ # Check for broken dpkg-dev lossage...
+ if field.startswith("ARRAY"):
+ reject("%s: invalid %s field produced by a broken version of dpkg-dev (1.10.11)" % (dsc_filename, field_name.title()));
+
+ # Have apt try to parse them...
+ try:
+ apt_pkg.ParseSrcDepends(field);
+ except:
+ reject("%s: invalid %s field (can not be parsed by apt)." % (dsc_filename, field_name.title()));
+ pass;
+
+ # Ensure the version number in the .dsc matches the version number in the .changes
+ epochless_dsc_version = utils.re_no_epoch.sub('', dsc.get("version"));
+ changes_version = files[dsc_filename]["version"];
+ if epochless_dsc_version != files[dsc_filename]["version"]:
+ reject("version ('%s') in .dsc does not match version ('%s') in .changes." % (epochless_dsc_version, changes_version));
+
+ # Ensure there is a .tar.gz in the .dsc file
+ has_tar = 0;
+ for f in dsc_files.keys():
+ m = utils.re_issource.match(f);
+ if not m:
+ reject("%s: %s in Files field not recognised as source." % (dsc_filename, f));
+ type = m.group(3);
+ if type == "orig.tar.gz" or type == "tar.gz":
+ has_tar = 1;
+ if not has_tar:
+ reject("%s: no .tar.gz or .orig.tar.gz in 'Files' field." % (dsc_filename));
+
+ # Ensure source is newer than existing source in target suites
+ reject(Katie.check_source_against_db(dsc_filename),"");
+
+ (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(dsc_filename);
+ reject(reject_msg, "");
+ if is_in_incoming:
+ if not Options["No-Action"]:
+ copy_to_holding(is_in_incoming);
+ orig_tar_gz = os.path.basename(is_in_incoming);
+ files[orig_tar_gz] = {};
+ files[orig_tar_gz]["size"] = os.stat(orig_tar_gz)[stat.ST_SIZE];
+ files[orig_tar_gz]["md5sum"] = dsc_files[orig_tar_gz]["md5sum"];
+ files[orig_tar_gz]["section"] = files[dsc_filename]["section"];
+ files[orig_tar_gz]["priority"] = files[dsc_filename]["priority"];
+ files[orig_tar_gz]["component"] = files[dsc_filename]["component"];
+ files[orig_tar_gz]["type"] = "orig.tar.gz";
+ reprocess = 2;