--- SpecCheck.py +++ SpecCheck.py @@ -24,8 +24,8 @@ DEFAULT_HARDCODED_LIB_PATH_EXCEPTIONS = '/lib/(modules|cpp|perl5|rpm|hotplug|firmware)($|[\s/,])' patch_regex = re.compile("^Patch(\d*)\s*:\s*([^\s]+)", re.IGNORECASE) -# TODO: http://rpmlint.zarb.org/cgi-bin/trac.cgi/ticket/59 -applied_patch_regex = re.compile("^%patch.*-P\s+(\d+)|^%patch(\d*)\s") +applied_patch_regex = re.compile("^\s*%patch(\d*)") +applied_patch_p_regex = re.compile("-P\s*([\d]*)") source_dir_regex = re.compile("^[^#]*(\$RPM_SOURCE_DIR|%{?_sourcedir}?)") obsolete_tags_regex = re.compile("^(Copyright|Serial)\s*:\s*([^\s]+)") buildroot_regex = re.compile('Buildroot\s*:\s*([^\s]+)', re.IGNORECASE) @@ -147,8 +147,8 @@ def check_spec(self, pkg, spec_lines): patches = {} - applied_patches = [] - applied_patches_ifarch = [] + applied_patches = set() + applied_patches_ifarch = set() source_dir = None buildroot = 0 configure = 0 @@ -230,10 +230,11 @@ else: res = applied_patch_regex.search(line) if res: - pnum = int(res.group(1) or res.group(2) or 0) - applied_patches.append(pnum) - if ifarch_depth > 0: - applied_patches_ifarch.append(pnum) + for tmp in applied_patch_p_regex.findall(line) or [res.group(1)]: + pnum=int(tmp or 0) + applied_patches.add(pnum) + if ifarch_depth > 0: + applied_patches_ifarch.add(pnum) elif not source_dir: res = source_dir_regex.search(line) if res: