diff options
author | Olav Vitters <olav@vitters.nl> | 2020-04-22 11:37:37 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-04-22 11:37:37 +0200 |
commit | 6c86432bebb88131a00f240a2b4f43eea851db5d (patch) | |
tree | 1996b6113f87f0b8c8a47614ce01612c78758421 | |
parent | 24e66a850a63f65b50327ec0e4ed299841d23a8f (diff) | |
download | mgagnome-6c86432bebb88131a00f240a2b4f43eea851db5d.tar mgagnome-6c86432bebb88131a00f240a2b4f43eea851db5d.tar.gz mgagnome-6c86432bebb88131a00f240a2b4f43eea851db5d.tar.bz2 mgagnome-6c86432bebb88131a00f240a2b4f43eea851db5d.tar.xz mgagnome-6c86432bebb88131a00f240a2b4f43eea851db5d.zip |
smarter buildrequires conversion, allows matching gtk+3.0-devel with pkgconfig(gtk+-3.0)
-rwxr-xr-x | mgagnome | 68 |
1 files changed, 47 insertions, 21 deletions
@@ -1531,23 +1531,25 @@ 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('), - 'basereq': lambda req: req[:-len('-devel')], - 'extra': lambda basereq, versions: [ - 'pkgconfig(%s)' % basereq, - 'pkgconfig(%s)' % basereq[len('lib'):] if basereq.startswith('lib') else 'pkgconfig(lib%s)' % basereq - ] + ['pkgconfig(%s-%s)' % (basereq, version) for version in versions] , + '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'] ), + '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: \ + [ 'pkgconfig(%s)' % basereq for basereq in basereqs] + + [ 'pkgconfig(%s)' % basereq[len('lib'):] if basereq.startswith('lib') else 'pkgconfig(lib%s)' % basereq for basereq in basereqs ] + + [ 'pkgconfig(%s-%s)' % (basereq, version) for basereq in basereqs for version in versions], }, 'perl': { 'desc': 'convert perl- buildrequires into perl()', 'check_br': lambda req: req.startswith('perl-'), 'check_provide': lambda prov: prov.startswith('perl('), - 'basereq': lambda req: req[len('perl-'):], - 'extra': lambda basereq, versions: ['perl(%s)' % basereq.replace('-', '::')], + 'basereqs': lambda req: set((req[len('perl-'):], )), + 'extra': lambda basereqs, versions: ['perl(%s)' % basereq.replace('-', '::') for basereq in basereqs], } } if options.debug: - import pprint print(pprint.pprint(convert_brs.items())) for convert_br, keys in convert_brs.items(): @@ -1557,24 +1559,44 @@ def cmd_clean_spec_multi(args): pprint.pprint(br) for req in br_old: provides = Downstream.alternative_provides(req) + # XXX - document what the following line is for + # maybe integrate in alternative_provides function? provides_alt = [clean_pkgconfig_prov(prov) for prov in provides if keys['check_provide'](prov)] change_to = None if len(provides_alt) == 1: change_to = provides_alt[0] elif len(provides_alt) and 'extra' in keys: + # Determine base require (e.g. gtk+3.0-devel --> gtk+3.0) + basereqs = keys['basereqs'](req) + + # Determine version matches versions = set() - for prov in provides_alt: - for mo in re_prov_get_version.finditer(prov): - if options.debug: - print("Found %s %s" % (prov, mo.group('version'))) - versions.add(mo.group('version')) + if 'versions_from_basereq' in keys: + # 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)) + if 'versions_basereq_extra' in keys: + versions.update(keys['versions_basereq_extra'](versions)) + + if not len(versions): + # In case no versions were retrieved from the basereq, + # match with any version found from the alternative + # provides (heuristic matching) + # + # This is only done as a last resort to avoid matching + # e.g. gtk+3.0-devel --> pkgconfig(gtk+2.0) + for prov in provides_alt: + for mo in re_prov_get_version.finditer(prov): + if options.debug: + print("NOTICE: Heuristically adding version %s from provide %s" % (mo.group('version'), provide)) + versions.add(mo.group('version')) + + check_for = keys['extra'](basereqs, versions) if options.debug: pprint.pprint(versions) - basereq = keys['basereq'](req) - check_for = keys['extra'](basereq, versions) - for check in check_for: if check in provides_alt: change_to = check @@ -1591,7 +1613,7 @@ def cmd_clean_spec_multi(args): if len(provides_alt): - if change_to is None: no_change[req] = provides_alt + if change_to is None: no_change[req] = (provides_alt, check_for) else: no_alt.add(req) @@ -1599,11 +1621,11 @@ def cmd_clean_spec_multi(args): keys['changes'][req] = change_to if not options.doit: - import pprint - for keys in list(convert_brs.items()): - if 'changes' in keys and keys['changes']: pprint.pprint(keys['changes']) + if options.debug: + for keys in list(convert_brs.items()): + if 'changes' in keys and keys['changes']: pprint.pprint(keys['changes']) if no_alt: print("WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt))) - if no_change: pprint.pprint(no_change) + if no_change and options.debug: pprint.pprint(no_change) else: convert_brs = {} @@ -2046,6 +2068,10 @@ def main(): if not hasattr(options, 'submit'): options.submit = not options.distro + if options.debug: + # Often used in debugging + import pprint + Downstream.PKGROOT=options.PKGROOT if options.distro: Downstream.PKGROOT = os.path.join(options.PKGROOT, options.distro) |