summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-04-21 21:13:07 +0200
committerOlav Vitters <olav@vitters.nl>2020-04-21 21:13:07 +0200
commit24e66a850a63f65b50327ec0e4ed299841d23a8f (patch)
tree9005bb33727e5a3a55dc9c9f19dbf94267897ab5
parent53c85def533fd854dfca29f07cc8f084c5008406 (diff)
downloadmgagnome-24e66a850a63f65b50327ec0e4ed299841d23a8f.tar
mgagnome-24e66a850a63f65b50327ec0e4ed299841d23a8f.tar.gz
mgagnome-24e66a850a63f65b50327ec0e4ed299841d23a8f.tar.bz2
mgagnome-24e66a850a63f65b50327ec0e4ed299841d23a8f.tar.xz
mgagnome-24e66a850a63f65b50327ec0e4ed299841d23a8f.zip
further improve pkgconfig alternatives: match against versions, match against 1 pkgconfig without a version
-rwxr-xr-xmgagnome35
1 files changed, 30 insertions, 5 deletions
diff --git a/mgagnome b/mgagnome
index 29253c0..352049a 100755
--- a/mgagnome
+++ b/mgagnome
@@ -1522,6 +1522,7 @@ def cmd_clean_spec_multi(args):
# Convert perl- and -devel buildrequires into perl() and pkgconfig() requires
if options.convert_br:
+ re_prov_get_version = re.compile(r'^[^(]+\([^)]+-(?P<version>[0-9]+\.[0-9][0-9.]*)\)$')
br = s.buildrequires
no_alt = set()
no_change = {}
@@ -1531,23 +1532,24 @@ def cmd_clean_spec_multi(args):
'check_br': lambda req: req.endswith('-devel'),
'check_provide': lambda prov: prov.startswith('pkgconfig('),
'basereq': lambda req: req[:-len('-devel')],
- 'extra': lambda basereq: [
+ '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] ,
},
'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: ['perl(%s)' % basereq.replace('-', '::')],
+ 'extra': lambda basereq, versions: ['perl(%s)' % basereq.replace('-', '::')],
}
}
if options.debug:
import pprint
print(pprint.pprint(convert_brs.items()))
+
for convert_br, keys in convert_brs.items():
keys['changes'] = {}
br_old = [r for r in list(br.keys()) if keys['check_br'](r)]
@@ -1560,14 +1562,34 @@ def cmd_clean_spec_multi(args):
if len(provides_alt) == 1:
change_to = provides_alt[0]
elif len(provides_alt) and 'extra' in keys:
+ 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 options.debug:
+ pprint.pprint(versions)
+
basereq = keys['basereq'](req)
- check_for = keys['extra'](basereq)
+ check_for = keys['extra'](basereq, versions)
for check in check_for:
if check in provides_alt:
change_to = check
break
+ if change_to is None and len(provides_alt):
+ provides_alt_no_versions = []
+ for prov in provides_alt:
+ if re_prov_get_version.fullmatch(prov) is None:
+ provides_alt_no_versions.append(prov)
+
+ if len(provides_alt_no_versions) == 1:
+ change_to = provides_alt_no_versions[0]
+
+
if len(provides_alt):
if change_to is None: no_change[req] = provides_alt
else:
@@ -1877,6 +1899,9 @@ def main():
help="Distribution release")
parser.add_argument("--debug", action="store_true", dest="debug",
help="Use for debugging")
+ parser.set_defaults(
+ debug=False, PKGROOT="~/pkgs"
+ )
# SUBPARSERS
subparsers = parser.add_subparsers(title='subcommands')
@@ -1884,7 +1909,7 @@ def main():
subparser.add_argument("-s", "--submit", action="store_true", dest="submit",
help="Increase version for stable upgrades and submit")
subparser.set_defaults(
- func=cmd_check_latest, submit=False, debug=False, PKGROOT="~/pkgs"
+ func=cmd_check_latest, submit=False
)
subparser = subparsers.add_parser('check-prep', help='check prep phase')