X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=b1a34c92c9f26ba23f0415abf0f3633253cb6395;hb=3d8f1f7a48b565b6d6a4b36c827e256586558e40;hp=6642622f9410938753e802cb77c40e3dbb6c378c;hpb=54a1e63df2a81a8f5e6f3148d59afcfeaa7b3495;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py old mode 100644 new mode 100755 index 6642622f..b1a34c92 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -36,7 +36,6 @@ import stat import apt_pkg import time import re -import string import email as modemail import subprocess @@ -240,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 @@ -269,7 +268,23 @@ def parse_changes(filename, signing_rules=0): unicode(content, 'utf-8') except UnicodeError: raise ChangesUnicodeError, "Changes file not proper utf-8" - return parse_deb822(content, signing_rules) + changes = parse_deb822(content, signing_rules) + + + 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') + + 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 ################################################################################ @@ -381,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)