summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2014-07-06 12:38:58 +0200
committerOlav Vitters <olav@vitters.nl>2014-07-06 12:38:58 +0200
commit4e44d91f49cfbcb5819f499119d6c6d6341b3d8a (patch)
tree720bae63132d191f99b57d1ce402a9c34afec08b
parent369ce7a7935f3870f55e3df331ce7b5b30974a78 (diff)
downloadmgagnome-4e44d91f49cfbcb5819f499119d6c6d6341b3d8a.tar
mgagnome-4e44d91f49cfbcb5819f499119d6c6d6341b3d8a.tar.gz
mgagnome-4e44d91f49cfbcb5819f499119d6c6d6341b3d8a.tar.bz2
mgagnome-4e44d91f49cfbcb5819f499119d6c6d6341b3d8a.tar.xz
mgagnome-4e44d91f49cfbcb5819f499119d6c6d6341b3d8a.zip
add removal of buildroot and make converting -devel BRs into pkgconfig optional
-rwxr-xr-xmgagnome81
1 files changed, 44 insertions, 37 deletions
diff --git a/mgagnome b/mgagnome
index 560891d..77819a9 100755
--- a/mgagnome
+++ b/mgagnome
@@ -386,7 +386,8 @@ class SpecFile(object):
# remove %defattr
('remove defattr', re.compile(r'(?P<keeppre>^\%files[^\n]*\n)^\%defattr\(-, *root, *root(?:, *-)?\)\s*\n', re.MULTILINE + re.IGNORECASE)),
('remove cleaning buildroot in install', re.compile(r'(?P<keeppre>^\%install[^\n]*\n)' + re_rm_buildroot + r'\n?', re.MULTILINE + re.IGNORECASE)),
- ('remove clean section', re.compile(r'^\%clean[^\n]*\n' + re_rm_buildroot + r'\n*(?P<keeppost>^(?:\%files|\%post|\%preun))', re.MULTILINE + re.IGNORECASE))
+ ('remove clean section', re.compile(r'^\%clean[^\n]*\n' + re_rm_buildroot + r'\n*(?P<keeppost>^(?:\%files|\%post|\%preun))', re.MULTILINE + re.IGNORECASE)),
+ ('remove buildroot definition', re.compile(r'^BuildRoot:[^\n]+\n', re.MULTILINE + re.IGNORECASE)),
]
made_changes = False
@@ -540,7 +541,7 @@ class SpecFile(object):
return True
- def update_br(self, changes, force=False):
+ def update_br(self, changes, force=False, change_description='update buildrequirements'):
"""Update buildrequirement"""
# XXX - doesn't handle buildrequires with version numbers :-(
@@ -552,6 +553,10 @@ class SpecFile(object):
# Change any "," in buildrequires into multiple lines
data, nr = self.re_update_br_unsplit.subn(lambda mo: ''.join((''.join((mo.group('pre'), mo2.group(0), mo.group('unsplitpost'))) for mo2 in self.re_br_part.finditer(mo.group('unsplit')) if mo.group(0).strip() != '')), data)
+ if data_before != data:
+ made_changes = True
+ self._changes.append('SILENT clean buildrequirements')
+ data_before = data
# Now update buildrequires if any
data, nr = self.re_update_br.subn(lambda mo: ''.join((mo.group('pre'), changes[mo.group('br')], mo.group('post'))) if mo.group('br') in changes else mo.group(0), data)
@@ -559,6 +564,7 @@ class SpecFile(object):
# XXX - very hacky because of multiple changes, could miss out on a change
if data_before != data:
made_changes = True
+ self._changes.append('SILENT %s' % change_description)
elif len(changes) != 0:
print >>sys.stderr, "ERROR: Could not update buildrequires!"
return False
@@ -566,8 +572,6 @@ class SpecFile(object):
# Overwrite file with new version number
write_file(self.path, data)
- if made_changes:
- self._changes.append('SILENT clean buildrequirements')
return made_changes
@@ -1200,44 +1204,46 @@ def cmd_clean_spec(options, parser):
# for match in s.re_br_part.findall(mo.group('unsplit')):
# print "d", match
- # Convert -devel requires into pkgconfig requires
- br = s.buildrequires
- br_old = [r for r in br.keys() if r.endswith('-devel')]
changes = {}
- no_alt = set()
- no_change = {}
- for req in br_old:
- provides = Downstream.alternative_provides(req)
- provides_alt = [clean_pkgconfig_prov(prov) for prov in provides if prov.startswith('pkgconfig(')]
- change_to = None
- if len(provides_alt) == 1:
- change_to = provides_alt[0]
- elif len(provides_alt):
- basereq = req[:-len('-devel')]
- check_for = ['pkgconfig(%s)' % basereq]
- if basereq.startswith('lib'):
- check_for.append('pkgconfig(%s)' % basereq[len('lib'):])
- else:
- check_for.append('pkgconfig(lib%s)' % basereq)
- for check in check_for:
- if check in provides_alt:
- change_to = check
- break
+ # Convert -devel requires into pkgconfig requires
+ if options.pkgconfig:
+ br = s.buildrequires
+ br_old = [r for r in br.keys() if r.endswith('-devel')]
+ no_alt = set()
+ no_change = {}
+ for req in br_old:
+ provides = Downstream.alternative_provides(req)
+ provides_alt = [clean_pkgconfig_prov(prov) for prov in provides if prov.startswith('pkgconfig(')]
+ change_to = None
+ if len(provides_alt) == 1:
+ change_to = provides_alt[0]
+ elif len(provides_alt):
+ basereq = req[:-len('-devel')]
+ check_for = ['pkgconfig(%s)' % basereq]
+ if basereq.startswith('lib'):
+ check_for.append('pkgconfig(%s)' % basereq[len('lib'):])
+ else:
+ check_for.append('pkgconfig(lib%s)' % basereq)
+ for check in check_for:
+ if check in provides_alt:
+ change_to = check
+ break
- if len(provides_alt):
- if change_to is None: no_change[req] = provides_alt
- else:
- no_alt.add(req)
- if change_to is not None: changes[req] = change_to
+ if len(provides_alt):
+ if change_to is None: no_change[req] = provides_alt
+ else:
+ no_alt.add(req)
+
+ if change_to is not None: changes[req] = change_to
- if not options.doit:
- if changes: pprint.pprint(changes)
- if no_alt: print "WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt))
- if no_change: pprint.pprint(no_change)
+ if not options.doit:
+ if changes: pprint.pprint(changes)
+ if no_alt: print "WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt))
+ if no_change: pprint.pprint(no_change)
- if s.update_br(changes): made_changes=True
+ if s.update_br(changes, change_description='convert -devel buildrequires into pkgconfig'): made_changes=True
if s.clean_spec(): made_changes=True
# If we made it this far, checkin the changes
@@ -1436,8 +1442,9 @@ def main():
subparser = subparsers.add_parser('clean-spec', help='clean specfile')
subparser.add_argument("package", help="Package name", nargs='*')
subparser.add_argument("-d", action="store_true", dest="doit")
+ subparser.add_argument("--no-convert-devel", action="store_false", dest="pkgconfig")
subparser.set_defaults(
- func=cmd_clean_spec, doit=False
+ func=cmd_clean_spec, doit=False, pkgconfig=True
)
subparser = subparsers.add_parser('check-version', help='check if spec version and downstream version match')