diff options
-rwxr-xr-x | calm/hint.py | 5 | ||||
-rwxr-xr-x | calm/package.py | 39 | ||||
-rw-r--r-- | test/testdata/hints/noarch/release/test-c/test-c-1.0-1.expected | 2 | ||||
-rw-r--r-- | test/testdata/hints/x86/release/libtextcat/libtextcat-devel/libtextcat-devel-2.2-2.expected | 2 | ||||
-rw-r--r-- | test/testdata/htdocs.expected/summary/test-c.html | 2 | ||||
-rw-r--r-- | test/testdata/inifile/setup.ini.expected | 2 | ||||
-rw-r--r-- | test/testdata/process_arch/setup.ini.expected | 2 | ||||
-rwxr-xr-x | test/testdata/relarea/noarch/release/test-c/test-c-1.0-1.hint | 2 |
8 files changed, 45 insertions, 11 deletions
diff --git a/calm/hint.py b/calm/hint.py index e76e9e2..b151317 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -350,9 +350,6 @@ def hint_file_parse(fn, kind, strict=False): warnings.append('sdesc is much longer than ldesc') # sort these hints, as differences in ordering are uninteresting - if 'requires' in hints: - hints['requires'] = split_trim_sort_join(hints['requires'], None, ' ') - if 'build-depends' in hints: if ',' in hints['build-depends']: hints['build-depends'] = split_trim_sort_join(hints['build-depends'], ',') @@ -425,7 +422,7 @@ def main(args): for fn in args.files: hints = hint_file_parse(fn, spvr if fn.endswith('src.hint') else pvr) - if args.verbose > 1: + if args.verbose >= 1: print(hints) if 'parse-warnings' in hints: diff --git a/calm/package.py b/calm/package.py index ce88768..2b5bc85 100755 --- a/calm/package.py +++ b/calm/package.py @@ -152,6 +152,41 @@ def sha512_file(fn, block_size=256 * 128): return sha512.hexdigest() +# process a list of package version-constraints +def process_package_constraint_list(pcl): + # split, keeping optional version-relation, trim and sort + deplist = {} + + if ',' in pcl: + # already comma separated is simple + for r in pcl.split(','): + r = r.strip() + item = re.sub(r'(.*)\s+\(.*?\)', r'\1', r) + deplist[item] = r + else: + # otherwise, split into a sequence of package names, version-relation + # constraints and white-space, and group package name with any following + # constraint + item = None + for r in re.split(r'(\(.*?\)|\s+)', pcl): + r = r.strip() + if not r: + continue + if r.startswith('('): + if not item: + logging.warning("constraint '%s' before any package" % (r)) + elif '(' in deplist[item]: + logging.warning("multiple constraints after package %s" % (item)) + else: + deplist[item] = item + ' ' + r + else: + item = r + deplist[item] = item + + # return a sorted list of package names with an optional version constraint. + return sorted(deplist.values()) + + # helper function to read hints def read_hints(p, fn, kind, strict=False): hints = hint.hint_file_parse(fn, kind, strict) @@ -167,7 +202,9 @@ def read_hints(p, fn, kind, strict=False): logging.info("package '%s': %s" % (p, l)) # generate depends: from requires: - hints['depends'] = ', '.join(hints.get('requires', '').split()) + # XXX: store this as a list, rather than splitting it into one everywhere we + # use it + hints['depends'] = ', '.join(process_package_constraint_list(hints.get('requires', ''))) # erase requires:, to ensure there is nothing using it hints.pop('requires', None) diff --git a/test/testdata/hints/noarch/release/test-c/test-c-1.0-1.expected b/test/testdata/hints/noarch/release/test-c/test-c-1.0-1.expected index ab6b117..d5a43b4 100644 --- a/test/testdata/hints/noarch/release/test-c/test-c-1.0-1.expected +++ b/test/testdata/hints/noarch/release/test-c/test-c-1.0-1.expected @@ -1,4 +1,4 @@ {'category': 'Devel', 'sdesc': '"test package C"', 'obsoletes': 'obs-a, obs-b', - 'requires': 'test-d test-e'} + 'requires': 'test-d (>= 1.0), test-e'} diff --git a/test/testdata/hints/x86/release/libtextcat/libtextcat-devel/libtextcat-devel-2.2-2.expected b/test/testdata/hints/x86/release/libtextcat/libtextcat-devel/libtextcat-devel-2.2-2.expected index aca0db6..f60d34d 100644 --- a/test/testdata/hints/x86/release/libtextcat/libtextcat-devel/libtextcat-devel-2.2-2.expected +++ b/test/testdata/hints/x86/release/libtextcat/libtextcat-devel/libtextcat-devel-2.2-2.expected @@ -7,6 +7,6 @@ 'BSD License.\n' 'http://software.wise-guys.nl/libtextcat/"', 'category': 'Devel Text', - 'requires': 'libtextcat libtextcat0', + 'requires': 'libtextcat0 libtextcat', 'external-source': 'libtextcat', 'parse-errors': ['embedded quote at line 7']} diff --git a/test/testdata/htdocs.expected/summary/test-c.html b/test/testdata/htdocs.expected/summary/test-c.html index 63c827a..200bd7b 100644 --- a/test/testdata/htdocs.expected/summary/test-c.html +++ b/test/testdata/htdocs.expected/summary/test-c.html @@ -13,7 +13,7 @@ <span class="detail">summary</span>: test package C<br><br> <span class="detail">description</span>: test package C<br><br> <span class="detail">categories</span>: Devel<br><br> -<span class="detail">depends</span>: <a href="test-d.html">test-d</a>, <a href="test-e.html">test-e</a><br><br> +<span class="detail">depends</span>: <a href="test-d.html">test-d (>= 1.0)</a>, <a href="test-e.html">test-e</a><br><br> <span class="detail">obsoletes</span>: <a href="obs-a.html">obs-a</a>, <a href="obs-b.html">obs-b</a><br><br> <span class="detail">source package</span>: <a href="test-c-src.html">test-c</a><br><br> <span class="detail">maintainer(s)</span>: ORPHANED diff --git a/test/testdata/inifile/setup.ini.expected b/test/testdata/inifile/setup.ini.expected index 19a18a0..7c19723 100644 --- a/test/testdata/inifile/setup.ini.expected +++ b/test/testdata/inifile/setup.ini.expected @@ -336,7 +336,7 @@ 'ef15790d8dc8163ed15dfca37565558203ed8b7569d586e0bc949f25282f44a1c059a60a7502863312b41cda649e3a9e2516d354eec9d54829e3ac1a3547097c\n' 'source: noarch/release/test-c/test-c-1.0-1-src.tar.xz 256 ' 'ef15790d8dc8163ed15dfca37565558203ed8b7569d586e0bc949f25282f44a1c059a60a7502863312b41cda649e3a9e2516d354eec9d54829e3ac1a3547097c\n' - 'depends2: test-d, test-e\n' + 'depends2: test-d (>= 1.0), test-e\n' 'obsoletes: obs-a, obs-b\n' '\n' '@ test-d\n' diff --git a/test/testdata/process_arch/setup.ini.expected b/test/testdata/process_arch/setup.ini.expected index c2d2cfc..c83b566 100644 --- a/test/testdata/process_arch/setup.ini.expected +++ b/test/testdata/process_arch/setup.ini.expected @@ -325,7 +325,7 @@ 'ef15790d8dc8163ed15dfca37565558203ed8b7569d586e0bc949f25282f44a1c059a60a7502863312b41cda649e3a9e2516d354eec9d54829e3ac1a3547097c\n' 'source: noarch/release/test-c/test-c-1.0-1-src.tar.xz 256 ' 'ef15790d8dc8163ed15dfca37565558203ed8b7569d586e0bc949f25282f44a1c059a60a7502863312b41cda649e3a9e2516d354eec9d54829e3ac1a3547097c\n' - 'depends2: test-d, test-e\n' + 'depends2: test-d (>= 1.0), test-e\n' 'obsoletes: obs-a, obs-b\n' '\n' '@ test-d\n' diff --git a/test/testdata/relarea/noarch/release/test-c/test-c-1.0-1.hint b/test/testdata/relarea/noarch/release/test-c/test-c-1.0-1.hint index af5eb4b..5ab7f54 100755 --- a/test/testdata/relarea/noarch/release/test-c/test-c-1.0-1.hint +++ b/test/testdata/relarea/noarch/release/test-c/test-c-1.0-1.hint @@ -1,4 +1,4 @@ category: Devel sdesc: "test package C" obsoletes: obs-a obs-b -requires: test-d test-e +requires: test-d (>= 1.0), test-e |