From: Joerg Jaspert Date: Sat, 30 Jan 2010 14:02:44 +0000 (+0100) Subject: parse_changes X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=3d8f1f7a48b565b6d6a4b36c827e256586558e40;p=dak.git parse_changes as we also parse dsc files here, only do the rejection on missing keywords when we parse a changes file. adjust all calls for dsc files to tell us they are dsc, by default we do the check, caller has to turn it off... Signed-off-by: Joerg Jaspert --- diff --git a/dak/check_archive.py b/dak/check_archive.py index b9837d30..8982ea4e 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -162,7 +162,7 @@ def check_dscs(): for line in list_file.readlines(): f = line[:-1] try: - utils.parse_changes(f, signing_rules=1) + utils.parse_changes(f, signing_rules=1, dsc_file=1) except InvalidDscError, line: utils.warn("syntax error in .dsc file '%s', line %s." % (f, line)) count += 1 @@ -339,7 +339,7 @@ def check_files_in_dsc(): try: # NB: don't enforce .dsc syntax - dsc = utils.parse_changes(filename) + dsc = utils.parse_changes(filename, dsc_file=1) except: utils.fubar("error parsing .dsc file '%s'." % (filename)) @@ -461,7 +461,7 @@ def chk_bd_process_dir (unused, dirname, filenames): if not name.endswith(".dsc"): continue filename = os.path.abspath(dirname+'/'+name) - dsc = utils.parse_changes(filename) + dsc = utils.parse_changes(filename, dsc_file=1) for field_name in [ "build-depends", "build-depends-indep" ]: field = dsc.get(field_name) if field: diff --git a/dak/clean_queues.py b/dak/clean_queues.py index f30d7f12..f6964508 100755 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -143,7 +143,7 @@ def flush_orphans (): for f in files.keys(): if f.endswith(".dsc"): try: - dsc = utils.parse_changes(f) + dsc = utils.parse_changes(f, dsc_file=1) dsc_files = utils.build_file_list(dsc, is_a_dsc=1) except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_type)) diff --git a/dak/examine_package.py b/dak/examine_package.py index ea865ed8..29611114 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -272,7 +272,7 @@ def read_changes_or_dsc (suite, filename): dsc_file = utils.open_file(filename) try: - dsc = utils.parse_changes(filename) + dsc = utils.parse_changes(filename, dsc_file=1) except: return formatted_text("can't parse .dsc control info") dsc_file.close() diff --git a/dak/rm.py b/dak/rm.py index 69b35971..62c5f980 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -399,7 +399,7 @@ def main (): for i in source_packages.keys(): filename = "/".join(source_packages[i]) try: - dsc = utils.parse_changes(filename) + dsc = utils.parse_changes(filename, dsc_file=1) except CantOpenError: utils.warn("couldn't open '%s'." % (filename)) continue diff --git a/daklib/queue.py b/daklib/queue.py index 58a87834..c177602c 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -929,7 +929,7 @@ class Upload(object): # Parse the .dsc file try: - self.pkg.dsc.update(utils.parse_changes(dsc_filename, signing_rules=1)) + self.pkg.dsc.update(utils.parse_changes(dsc_filename, signing_rules=1, dsc_file=1)) except CantOpenError: # if not -n copy_to_holding() will have done this for us... if not action: diff --git a/daklib/utils.py b/daklib/utils.py index 8c96dc06..b1a34c92 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -239,7 +239,7 @@ def parse_deb822(contents, signing_rules=0): ################################################################################ -def parse_changes(filename, signing_rules=0): +def parse_changes(filename, signing_rules=0, dsc_file=0): """ Parses a changes file and returns a dictionary where each field is a key. The mandatory first argument is the filename of the .changes @@ -270,17 +270,19 @@ def parse_changes(filename, signing_rules=0): raise ChangesUnicodeError, "Changes file not proper utf-8" changes = parse_deb822(content, signing_rules) - # Finally ensure that everything needed is there - must_keywords = ('Format', 'Date', 'Source', 'Binary', 'Architecture', 'Version', - 'Distribution', 'Maintainer', 'Description', 'Changes', 'Files') - missingfields=[] - for keyword in must_keywords: - if not changes.has_key(keyword.lower()): - missingfields.append(keyword) + if not dsc_file: + # Finally ensure that everything needed for .changes is there + must_keywords = ('Format', 'Date', 'Source', 'Binary', 'Architecture', 'Version', + 'Distribution', 'Maintainer', 'Description', 'Changes', 'Files') - if len(missingfields): - raise ParseChangesError, "Missing mandantory field(s) in changes file (policy 5.5): %s" % (missingfields) + missingfields=[] + for keyword in must_keywords: + if not changes.has_key(keyword.lower()): + missingfields.append(keyword) + + if len(missingfields): + raise ParseChangesError, "Missing mandantory field(s) in changes file (policy 5.5): %s" % (missingfields) return changes @@ -394,7 +396,7 @@ def check_dsc_files(dsc_filename, dsc=None, dsc_files=None): # Parse the file if needed if dsc is None: - dsc = parse_changes(dsc_filename, signing_rules=1); + dsc = parse_changes(dsc_filename, signing_rules=1, dsc_file=1); if dsc_files is None: dsc_files = build_file_list(dsc, is_a_dsc=1)