- # Parse the .dsc file
- try:
- dsc.update(utils.parse_changes(file, 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("can't read .dsc file '%s'." % (file));
- except utils.changes_parse_error_exc, line:
- reject("error parsing .dsc file '%s', can't grok: %s." % (file, line));
- except utils.invalid_dsc_format_exc, line:
- reject("syntax error in .dsc file '%s', line %s." % (file, line));
- # Build up the file list of files mentioned by the .dsc
+ if dsc_filename:
+ reject("can not process a .changes file with multiple .dsc's.");
+ return 0;
+ else:
+ dsc_filename = file;
+
+ # If there isn't one, we have nothing to do. (We have reject()ed the upload already)
+ if not dsc_filename:
+ reject("source uploads must contain a dsc file");
+ return 0;
+
+ # Parse the .dsc file
+ try:
+ dsc.update(utils.parse_changes(dsc_filename, signing_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 0;
+ except utils.changes_parse_error_exc, line:
+ reject("%s: parse error, can't grok: %s." % (dsc_filename, line));
+ return 0;
+
+ # 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));
+ return 0;
+
+ # Validate the source and version fields
+ if not re_valid_pkg_name.match(dsc["source"]):
+ reject("%s: invalid source name '%s'." % (dsc_filename, dsc["source"]));
+ if 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 Maintainer field
+ try:
+ utils.fix_maintainer (dsc["maintainer"]);
+ except utils.ParseMaintError, msg:
+ reject("%s: Maintainer field ('%s') failed to parse: %s" \
+ % (dsc_filename, dsc["maintainer"], msg));
+
+ # 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...