diff options
-rwxr-xr-x | mgagnome | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -464,14 +464,20 @@ class SpecFile(object): return made_changes def _clean_spec_patches(self, f, made_changes, data): + re_autopatch = re.compile(r'^[ \t]*\%autopatch(?:[ \t]+-p(?P<strip>[0-9]+))?$', re.MULTILINE) + re_patch_header = re.compile('^\Patch(?P<nr>[0-9]*):[ \t]*(?P<filename>[^\n]+)\n', re.MULTILINE + re.IGNORECASE) re_patch_any = re.compile(r'^[ \t]*\%patch(?P<nr>[0-9]*)', re.MULTILINE) - re_patch_valid = re.compile(r'^[ \t+]*\%patch(?P<nr>[0-9]*)(?:[ \t]+-p(?P<strip>[0-9]+))?(?:[ \t]+-b[ \t]+\S+)$\n?', re.MULTILINE) - re_prep_patches = re.compile(r'^\%setup[^\n]+$(?:' + re_patch_valid.pattern + r'|^#[^%\n]+\n|\s)+\n\%build', re.MULTILINE) + re_patch_valid = re.compile(r'^[ \t+]*\%patch(?P<nr>[0-9]*)(?:[ \t]+-p(?P<strip>[0-9]+))?(?:[ \t]+-b[ \t]+\S+)?$\n?', re.MULTILINE) + re_prep_patches = re.compile(r'^\%setup[^\n]+$(?:' + re_patch_valid.pattern + r'|^#[^%\n]+\n|^[ \t]*(?:%{_bindir}/|%_bindir)?autoreconf[ \t][^\n]+$|\s)+\n\%build', re.MULTILINE) give_patchnr = lambda mo: (mo.group('nr') if len(mo.group('nr')) == 1 else mo.group('nr').lstrip('0')) if mo.group('nr') else "0" # Make use of %apply_patches + + if re_autopatch.search(data): + return made_changes, data + patches = self.patches if not patches: return made_changes, data @@ -494,7 +500,7 @@ class SpecFile(object): return made_changes, data if not (patch_nrs_header == patch_nrs_any == patch_nrs_valid): - print >>sys.stderr, "NOTICE: Unable to automatically convert patches into %autopatch" + print >>sys.stderr, "NOTICE: Unable to automatically convert %s patches into %%autopatch (header/patch/valid: %s, %s, %s)" % (self.module, len(patch_nrs_header), len(patch_nrs_any), len(patch_nrs_valid)) return made_changes, data patch_flags = set([mo.group('strip') for mo in re_patch_valid.finditer(mo2.group(0))]) |