diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2017-05-26 00:57:47 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2017-11-09 18:20:34 +0300 |
commit | 22e09da2afaf70a4ce2294250b621ecc8075783e (patch) | |
tree | 153bffa504ed97d7e07ac059b199bbe6b6b3bf0a | |
parent | 828b91be6190a1707b8e89a157487419e36bcac7 (diff) |
Add obsoletes: handling
Validate that the obsoleted packages exist (unless disabled with okmissing)
No validation is done on any version relation which might be specified, but
it's not clear how we can do that...
-rwxr-xr-x | calm/hint.py | 6 | ||||
-rwxr-xr-x | calm/mksetupini.py | 2 | ||||
-rwxr-xr-x | calm/package.py | 56 |
3 files changed, 42 insertions, 22 deletions
diff --git a/calm/hint.py b/calm/hint.py index bcdda95..71f5096 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -80,6 +80,7 @@ hintkeys[pvr] = merge_dicts(commonkeys, { # (depends could be an alias for requires in this kind of hint file) 'depends': 'optval', 'build-depends': 'optval', + 'obsoletes': 'optval', # mark the package as a test version 'test': 'noval', }) @@ -296,10 +297,13 @@ def hint_file_parse(fn, kind): if len(hints['sdesc']) > 2 * len(hints['ldesc']): warnings.append('sdesc is much longer than ldesc') - # sort requires: as differences in ordering are uninteresting + # sort these hints, as differences in ordering are uninteresting if 'requires' in hints: hints['requires'] = ' '.join(sorted(hints['requires'].split())) + if 'obsoletes' in hints: + hints['obsoletes'] = ','.join(sorted(hints['obsoletes'].split(','))) + except UnicodeDecodeError: errors.append('invalid UTF-8') diff --git a/calm/mksetupini.py b/calm/mksetupini.py index e7337fe..57de569 100755 --- a/calm/mksetupini.py +++ b/calm/mksetupini.py @@ -100,7 +100,7 @@ def main(): parser = argparse.ArgumentParser(description='Make setup.ini') parser.add_argument('--arch', action='store', required=True, choices=common_constants.ARCHES) parser.add_argument('--inifile', '-u', action='store', help='output filename', required=True) - parser.add_argument('--okmissing', action='append', help='missing things which are ok', choices=['curr', 'required-package']) + parser.add_argument('--okmissing', action='append', help='missing things which are ok', choices=['curr', 'obsoleted-package', 'required-package']) parser.add_argument('--pkglist', action='store', nargs='?', metavar='FILE', help="package maintainer list (default: " + pkglist_default + ")", const=pkglist_default) parser.add_argument('--release', action='store', help='value for setup-release key (default: cygwin)', default='cygwin') parser.add_argument('--releasearea', action='store', metavar='DIR', help="release directory (default: " + relarea_default + ")", default=relarea_default, dest='rel_area') diff --git a/calm/package.py b/calm/package.py index 5371e92..a613b73 100755 --- a/calm/package.py +++ b/calm/package.py @@ -393,27 +393,40 @@ def validate_packages(args, packages): has_requires = False for (v, hints) in packages[p].version_hints.items(): - if 'requires' in hints: - for r in hints['requires'].split(): - has_requires = True - - # a package should not appear in it's own requires - if r == p: - lvl = logging.WARNING if p not in past_mistakes.self_requires else logging.DEBUG - logging.log(lvl, "package '%s' version '%s' requires itself" % (p, v)) - - # all packages listed in requires must exist (unless - # okmissing says that's ok) - if r not in packages: - if 'required-package' not in getattr(args, 'okmissing', []): - logging.error("package '%s' version '%s' requires nonexistent package '%s'" % (p, v, r)) + for (c, okmissing, splitchar) in [ + ('requires', 'required-package', None), + ('obsoletes', 'obsoleted-package', ',') + ]: + if c in hints: + for r in hints[c].split(splitchar): + if c == 'requires': + has_requires = True + + # remove any extraneous whitespace + r = r.strip() + + # strip off any version relation enclosed in '()' + # following the package name + if splitchar: + r = re.sub(r'(.*) +\(.*\)', r'\1', r) + + # a package should not appear in it's own hint + if r == p: + lvl = logging.WARNING if p not in past_mistakes.self_requires else logging.DEBUG + logging.log(lvl, "package '%s' version '%s' %s itself" % (p, v, c)) + + # all packages listed in a hint must exist (unless + # okmissing says that's ok) + if r not in packages: + if okmissing not in getattr(args, 'okmissing', []): + logging.error("package '%s' version '%s' %s nonexistent package '%s'" % (p, v, c, r)) + error = True + continue + + # hint referencing a source-only package makes no sense + if packages[r].skip: + logging.error("package '%s' version '%s' %s source-only package '%s'" % (p, v, c, r)) error = True - continue - - # requiring a source-only package makes no sense - if packages[r].skip: - logging.error("package '%s' version '%s' requires source-only package '%s'" % (p, v, r)) - error = True # if external-source is used, the package must exist if 'external-source' in hints: @@ -868,6 +881,9 @@ def write_setup_ini(args, packages, arch): else: logging.warning("package '%s' version '%s' has no source in external-source '%s'" % (p, version, s)) + if 'obsoletes' in packages[p].version_hints[version]: + print("obsoletes: %s" % packages[p].version_hints[version]['obsoletes'], file=f) + # helper function to output details for a particular tar file def tar_line(category, p, t, f): |