From 4389ff1be440e5eb3b2086639723f53f8fbce50e Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Tue, 8 Jul 2014 01:38:36 +0200 Subject: fix => and =< in BRs to >= and <= respectively --- mgagnome | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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
BuildRequires:\s*)(?P
[^\s%{},]+?)(?P\s*(?:(?:[<>]=?|=)\s+(?:[^\s%{},]+|\%\{[^\s{%}]+\}|\%[^\s%{},]+))?\s*\n)', re.MULTILINE + re.IGNORECASE) # re_update_br_unsplit = re.compile(r'^(?P
BuildRequires:\s*)(?P[^\n,]+,[^\n]*)(?P\s*\n)', re.MULTILINE + re.IGNORECASE)
 
+    re_update_br_fix_operator = re.compile('^(?P
BuildRequires:\s*[^\n]*)(?P=<|=>)(?P[^\n]+)\n', re.MULTILINE + re.IGNORECASE)
     re_update_br_unsplit = re.compile(r'^(?P
BuildRequires:\s*)(?P(?:%s,?(?:[ \t\f\v]+|$)){2,})(?P\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:
-- 
cgit v1.2.1