diff options
-rwxr-xr-x | mgagnome | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -341,7 +341,7 @@ class SpecFile(object): re_update_release = re.compile(r'^(?P<pre>Release:\s*)(?P<release>%mkrel \d+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) re_update_patch = re.compile(r'^(?P<pre>Patch)(?P<nr>[0-9]*)(?P<pre2>:\s*)(?P<patch>.+)(?P<post>\s*)\n', re.MULTILINE + re.IGNORECASE) - re_br_part = re.compile(r'(?P<br>[^\s%{},<>=][^\s%{},<>=]*)\b(?P<post>\s*(?:(?P<operator>=|>=|<=|>|<)\s*(?P<version>[^\s%{},]+|\%\{[^\s{%}]+\}|\%[^\s%{},]+)\b)?)') + re_br_part = re.compile(r'(?P<br>[^\s%{},<>=][^\s%{},<>=]*)\b(?P<post>\s*(?:(?P<operator>=|>=|<=|=<|=>|>|<)\s*(?P<version>[^\s%{},]+|\%\{[^\s{%}]+\}|\%[^\s%{},]+)\b)?)') #re_update_br = re.compile(r'^(?P<pre>BuildRequires:\s*)(?P<br>[^\s%{},]+?)(?P<post>\s*(?:(?:[<>]=?|=)\s+[^\s%{},]+?)?\s*\n)', re.MULTILINE + re.IGNORECASE) 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) @@ -385,8 +385,9 @@ class SpecFile(object): # remove %defattr ('remove defattr', re.compile(r'(?P<keeppre>^\%files(?:[ \t]+[^\n]*)?\n(?:^\%doc [^\n]+\n)?)^\%defattr\s*\(- *, *root *, *root *(?:, *-)?\)\s*\n', re.MULTILINE + re.IGNORECASE)), ('remove cleaning buildroot in install', re.compile(r'(?P<keeppre>^\%install(?:[ \t]+[^\n]*)?\n)' + re_rm_buildroot + r'\n?', re.MULTILINE + re.IGNORECASE)), - ('remove clean section', re.compile(r'^\%clean[ \t]*\n(?:' + re_rm_buildroot + r')?\s*(?P<keeppost>^(?:\%files|\%post|\%pre|\%trigger|\%install|\%package|\%check|\%_font_pkg|$(?!.|\n)))', re.MULTILINE + re.IGNORECASE)), + ('remove clean section', re.compile(r'^\%clean[ \t]*\n(?:' + re_rm_buildroot + r')?\s*(?P<keeppost>(?:^#[^%\n]+\n)*^(?:\%files|\%post|\%pre|\%trigger|\%install|\%package|\%check|\%_font_pkg|$(?!.|\n)))', re.MULTILINE + re.IGNORECASE)), ('remove buildroot definition', re.compile(r'^BuildRoot:[^\n]+\n', re.MULTILINE + re.IGNORECASE)), + ('remove unneeded setup option', re.compile(r'^(?P<keeppre>\%setup -q )-n (?:\%name|\%\{name\})-(?:\%version|\%\{version\})(?P<keeppost>\n)', re.MULTILINE + re.IGNORECASE)), ] re_convert_br = [ ('remove py_requires', ('python',), re.compile(r'^\%(?:py_requires|\{py_requires\})[ \t]*\n', re.MULTILINE)), @@ -451,6 +452,12 @@ class SpecFile(object): data = data.lstrip() self._changes.append('SILENT remove variable definition(s) %s' % ", ".join(converted_defines)) + # Make use of %apply_patches + patches = self.patches + if patches and not self.uses_apply_patches: + print "WARNING: Patches, no %%apply_patches for %s" % self.module + print self.module, patches + # Overwrite file with new version number if made_changes: write_file(self.path, data) @@ -584,6 +591,7 @@ class SpecFile(object): print >>sys.stderr, "ERROR: Problem in %prep phase" return False finally: + # bm command doesn't cleanup after itself and the option it has to do that removes spec file + sources! buildpath = os.path.join(self.cwd, '..', 'BUILD', '%s-%s' % (self.module, self.version)) if os.path.exists(buildpath): shutil.rmtree(buildpath, ignore_errors=True) @@ -596,23 +604,25 @@ class SpecFile(object): # XXX - doesn't handle buildrequires with version numbers :-( made_changes = False + re_patch = re.compile(r'^\%patch(?P<nr>[0-9]*)(?:[ \t]+-p(P<strip>[0-9]+))?(?:[ \t]+-b[ \t]+\S+)?\n', re.MULTILINE) + with open(self.path, "rw") as f: data = f.read() data_before=data - # Change =< and => operators into <= and >= - # XXX - pretty ugly - 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) + # 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 fix operator in buildrequires') + self._changes.append('SILENT one line per buildrequirement') 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) + # Change =< and => operators into <= and >= + # XXX - pretty ugly + 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 one line per buildrequirement') + self._changes.append('SILENT fix operator in buildrequires') data_before = data # Now update buildrequires if any |