diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2018-01-23 16:33:39 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2018-01-23 19:15:44 +0300 |
commit | 730c7eebef23c43e30542da192b9616f1062a0c5 (patch) | |
tree | 8c3152654f861af99f4ceafa74a48554e80894de | |
parent | c7933435cc2da9e6ac9cc6f10cc0ca7ed48949ed (diff) |
Add a replace-versions: key in override.hint to list versions which should always be replaced
This is intended for (temporarily) dealing with anomalous versions e.g.
those which have been removed (or relabelled as test), without a
superseding higher version existing, and indicates to setup that the named
versions(s), if installed, should be replaced with different version.
Also warn if this key pointlessly lists versions which will be replaced by
the current version anyhow.
-rwxr-xr-x | calm/hint.py | 4 | ||||
-rwxr-xr-x | calm/package.py | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/calm/hint.py b/calm/hint.py index 7e30913..98386ef 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -68,6 +68,7 @@ overridekeys = { 'keep-count': 'val', 'keep-days': 'val', 'disable-check': 'val', + 'replace-versions': 'val', } hintkeys = {} @@ -319,6 +320,9 @@ def hint_file_parse(fn, kind): if 'obsoletes' in hints: hints['obsoletes'] = split_trim_sort_join(hints['obsoletes'], ',') + if 'replace-versions' in hints: + hints['replace-versions'] = split_trim_sort_join(hints['replace-versions'], None, ' ') + except UnicodeDecodeError: errors.append('invalid UTF-8') diff --git a/calm/package.py b/calm/package.py index a727d3e..bd6768d 100755 --- a/calm/package.py +++ b/calm/package.py @@ -641,6 +641,15 @@ def validate_packages(args, packages): packages[p].best_version = None error = True + # warn if replace-versions lists a version which is less than the + # current version (which is pointless as the current version will + # replace it anyhow) + if 'replace-versions' in packages[p].override_hints: + if packages[p].best_version: + for rv in packages[p].override_hints['replace-versions'].split(): + if SetupVersion(rv) < SetupVersion(packages[p].best_version): + logging.warning("package '%s' replace-versions: lists version '%s' which is less than current version" % (p, rv)) + # If the install tarball is empty and there is no source tarball, we # should probably be marked obsolete if not packages[p].skip: @@ -854,6 +863,9 @@ def write_setup_ini(args, packages, arch): if 'message' in packages[p].version_hints[bv]: print("message: %s" % packages[p].version_hints[bv]['message'], file=f) + if 'replace-versions' in packages[p].override_hints: + print("replace-versions: %s" % packages[p].override_hints['replace-versions'], file=f) + # make a list of version sections # # (they are put in a particular order to ensure certain behaviour |