diff options
author | Olav Vitters <olav@vitters.nl> | 2020-04-23 14:30:36 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-04-23 14:30:36 +0200 |
commit | 207e05016128f9cf1f13748a24e56c2cd6506de2 (patch) | |
tree | 409943e0f717f9f0da5dc6c08ae39e3775b9311f | |
parent | e0cc826936a732481293bd2b70fc7ee5bb9534a1 (diff) | |
download | mgagnome-207e05016128f9cf1f13748a24e56c2cd6506de2.tar mgagnome-207e05016128f9cf1f13748a24e56c2cd6506de2.tar.gz mgagnome-207e05016128f9cf1f13748a24e56c2cd6506de2.tar.bz2 mgagnome-207e05016128f9cf1f13748a24e56c2cd6506de2.tar.xz mgagnome-207e05016128f9cf1f13748a24e56c2cd6506de2.zip |
Encourage changing python3-devel into pkgconfig(python3) over pkgconfig(python2)
At the same time, add ability to convert pythonegg(3) into python3dist
-rwxr-xr-x | mgagnome | 44 |
1 files changed, 34 insertions, 10 deletions
@@ -247,6 +247,14 @@ def line_input (file): else: yield line +def distinct(iterable, keyfunc=None): + seen = set() + for item in iterable: + key = item if keyfunc is None else keyfunc(item) + if key not in seen: + seen.add(key) + yield item + def call_editor(filename): """Return a sequence of possible editor binaries for the current platform""" @@ -353,7 +361,7 @@ class SpecFile(object): try: srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \ else spec.sources() - except ValueError as exc + except ValueError as exc: # Reraise this into a more specific exception raise SpecFileError from exc finally: @@ -563,7 +571,7 @@ class SpecFile(object): ts = rpm.ts() try: spec = ts.parseSpec(self.path) - except ValueError as exc + except ValueError as exc: # Reraise this into a more specific exception raise SpecFileError from exc finally: @@ -1168,7 +1176,8 @@ class Downstream(object): for key in provide_has_single: - if '(' in key: continue + # XXX - optimize memory usage somewhat + if '(' in key and not ')(' in key: continue for pkgname in _provide_to_pkg[key]: for pkgprovide in _pkg_to_provide[pkgname]: @@ -1552,8 +1561,8 @@ def cmd_clean_spec_multi(args): 'desc': 'convert -devel buildrequires into pkgconfig', 'check_br': lambda req: req.endswith('-devel'), 'check_provide': lambda prov: prov.startswith('pkgconfig('), - 'basereqs': lambda req: set((req[:-len('-devel')], )), - 'basereq_no_version': lambda basereqs: set([basereq.rstrip('1234567890.') for basereq in basereqs if basereq[-1] in '1234567890'] ), + 'basereqs': lambda req: [ req[:-len('-devel')] ], + 'basereq_no_version': lambda basereqs: [ basereq.rstrip('1234567890.') for basereq in basereqs if basereq[-1] in '1234567890' ], 'versions_from_basereq': lambda basereqs: set([basereq[len(basereq.rstrip('01234567890.')):] for basereq in basereqs if basereq[-1] in '1234567890'] ), 'versions_basereq_extra': lambda versions: set( [ "%s.0" % version for version in versions if '.' not in version] ), 'extra': lambda basereq, versions: \ @@ -1565,7 +1574,7 @@ def cmd_clean_spec_multi(args): 'desc': 'convert perl- buildrequires into perl()', 'check_br': lambda req: req.startswith('perl-'), 'check_provide': lambda prov: prov.startswith('perl('), - 'basereqs': lambda req: set((req[len('perl-'):], )), + 'basereqs': lambda req: [ req[len('perl-'):] ], 'extra': lambda basereqs, versions: ['perl(%s)' % basereq.replace('-', '::') for basereq in basereqs], }, # PySolFC.spec:BuildRequires: python3-setuptools @@ -1576,16 +1585,26 @@ def cmd_clean_spec_multi(args): # There's also provides such as: # python3.8dist(setuptools) # pythonegg(3)(setuptools) - 'python': { + 'python-pkg': { + 'disabled': True, 'desc': 'convert python buildrequires into python3dist()', 'check_br': lambda req: req.startswith('python3-'), 'check_provide': lambda prov: prov.startswith('python3dist('), - 'basereqs': lambda req: set((req[len('python3-'):], )), + 'basereqs': lambda req: [ req[len('python3-'):] ], + 'extra': lambda basereqs, versions: ['python3dist(%s)' % basereq for basereq in basereqs], + }, + 'python-egg': { + 'desc': 'convert pythonegg(3) into python3dist()', + 'check_br': lambda req: req.startswith('pythonegg(3)(') and req.endswith(')'), + 'check_provide': lambda prov: prov.startswith('python3dist('), + 'basereqs': lambda req: [ req[len('pythonegg(3)('):-1] ], 'extra': lambda basereqs, versions: ['python3dist(%s)' % basereq for basereq in basereqs], - } + }, } for convert_br, keys in convert_brs.items(): + if 'disabled' in keys and keys['disabled']: continue + keys['changes'] = {} br_old = [r for r in list(br.keys()) if keys['check_br'](r)] if options.debug: @@ -1608,7 +1627,12 @@ def cmd_clean_spec_multi(args): # Determine if the basereq has a version at the end (e.g. gtk+3.0 --> 3.0) versions.update(keys['versions_from_basereq'](basereqs)) if len(versions) and 'basereq_no_version' in keys: - basereqs.update(keys['basereq_no_version'](basereqs)) + basereqs.extend(keys['basereq_no_version'](basereqs)) + # Make it unique again, but keep the order + # + # This is done so that e.g. python3-devel changes to pkgconfig(python3), + # even if pkgconfig(python) might be available + basereqs = list(distinct(basereqs)) if 'versions_basereq_extra' in keys: versions.update(keys['versions_basereq_extra'](versions)) |