summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2014-07-08 01:38:36 +0200
committerOlav Vitters <olav@vitters.nl>2014-07-08 01:38:36 +0200
commit4389ff1be440e5eb3b2086639723f53f8fbce50e (patch)
tree5e2db1e6cc49eba9b230086f8b52c147e38b6033
parentd4871601d0f2699089bcd8c93d17a674493209ba (diff)
downloadmgagnome-4389ff1be440e5eb3b2086639723f53f8fbce50e.tar
mgagnome-4389ff1be440e5eb3b2086639723f53f8fbce50e.tar.gz
mgagnome-4389ff1be440e5eb3b2086639723f53f8fbce50e.tar.bz2
mgagnome-4389ff1be440e5eb3b2086639723f53f8fbce50e.tar.xz
mgagnome-4389ff1be440e5eb3b2086639723f53f8fbce50e.zip
fix => and =< in BRs to >= and <= respectively
-rwxr-xr-xmgagnome12
1 files changed, 12 insertions, 0 deletions
diff --git a/mgagnome b/mgagnome
index f4a69b1..dccd3a2 100755
--- a/mgagnome
+++ b/mgagnome
@@ -347,6 +347,7 @@ class SpecFile(object):
re_update_br = re.compile(r'^(?P<pre>BuildRequires:\s*)(?P<br>[^\s%{},]+?)(?P<post>\s*(?:(?:[<>]=?|=)\s+(?:[^\s%{},]+|\%\{[^\s{%}]+\}|\%[^\s%{},]+))?\s*\n)', re.MULTILINE + re.IGNORECASE)
# re_update_br_unsplit = re.compile(r'^(?P<pre>BuildRequires:\s*)(?P<unsplit>[^\n,]+,[^\n]*)(?P<post>\s*\n)', re.MULTILINE + re.IGNORECASE)
+ re_update_br_fix_operator = re.compile('^(?P<pre>BuildRequires:\s*[^\n]*)(?P<operator>=<|=>)(?P<post>[^\n]+)\n', re.MULTILINE + re.IGNORECASE)
re_update_br_unsplit = re.compile(r'^(?P<pre>BuildRequires:\s*)(?P<unsplit>(?:%s,?(?:[ \t\f\v]+|$)){2,})(?P<unsplitpost>\n)' % (re_br_part.pattern,), re.MULTILINE + re.IGNORECASE)
def __init__(self, path, module=None):
@@ -599,6 +600,15 @@ class SpecFile(object):
data = f.read()
data_before=data
+ # Change =< and => operators into <= and >=
+ # XXX - pretty ugly
+ pprint.pprint(self.re_update_br_fix_operator.findall(data))
+ data, nr = self.re_update_br_fix_operator.subn(lambda mo: mo.group(0).replace('=>', '>=').replace('=<', '<') if self.re_update_br.match(mo.group(0).replace('=>', '>=').replace('=<', '<')) else mo.group(0), data)
+ if data_before != data:
+ made_changes = True
+ self._changes.append('SILENT fix operator in buildrequires')
+ data_before = data
+
# 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:
@@ -1320,6 +1330,8 @@ def cmd_clean_spec_multi(args):
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)
+ else:
+ convert_brs = {}
keys_with_changes = [keys for keys in convert_brs.itervalues() if 'changes' in keys and keys['changes']]
if not keys_with_changes: