2000-10-11 14:03:08 +08:00
|
|
|
#############################################################################
|
2005-11-28 05:49:15 +08:00
|
|
|
# File : SpecCheck.py
|
|
|
|
# Package : rpmlint
|
|
|
|
# Author : Frederic Lepied
|
|
|
|
# Created on : Thu Oct 7 17:06:14 1999
|
|
|
|
# Version : $Id$
|
|
|
|
# Purpose : check the spec file of a source rpm.
|
2000-10-11 14:03:08 +08:00
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
from Filter import *
|
|
|
|
import AbstractCheck
|
2006-01-15 17:59:04 +08:00
|
|
|
from Pkg import is_utf8
|
2000-10-11 14:03:08 +08:00
|
|
|
import re
|
|
|
|
import sys
|
2002-06-01 21:17:28 +08:00
|
|
|
import string
|
2003-05-08 16:03:35 +08:00
|
|
|
import Config
|
|
|
|
|
|
|
|
# Don't check for hardcoded library paths in biarch packages
|
2006-05-12 21:53:43 +08:00
|
|
|
DEFAULT_BIARCH_PACKAGES = '^(gcc|glibc)'
|
2003-05-08 16:03:35 +08:00
|
|
|
|
|
|
|
# Don't check for hardcoded library paths in packages which can have
|
|
|
|
# their noarch files in /usr/lib/<package>/*, or packages that can't
|
|
|
|
# be installed on biarch systems
|
2006-05-12 21:53:43 +08:00
|
|
|
DEFAULT_HARDCODED_LIB_PATH_EXCEPTIONS = '/lib/(modules|cpp|perl5|rpm|hotplug)($|[\s/,])'
|
|
|
|
|
|
|
|
patch_regex = re.compile("^\s*Patch(.*?)\s*:\s*([^\s]+)")
|
|
|
|
applied_patch_regex = re.compile("^\s*%patch.*-P\s*([^\s]*)|^\s*%patch([^\s]*)\s")
|
|
|
|
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)
|
|
|
|
prefix_regex = re.compile('^Prefix\s*:\s*([^\s]+)', re.IGNORECASE)
|
|
|
|
packager_regex = re.compile('^Packager\s*:\s*([^\s]+)', re.IGNORECASE)
|
2006-07-13 04:33:22 +08:00
|
|
|
make_check_regexp = re.compile('(^|\s|%{?__)make}?\s+(check|test)')
|
2006-05-13 17:49:35 +08:00
|
|
|
rm_regex = re.compile('(^|\s)((.*/)?rm|%{?__rm}?) ')
|
2006-09-09 18:57:13 +08:00
|
|
|
rpm_buildroot_regex = re.compile('(\\\*)\${?RPM_BUILD_ROOT}?|(%+){?buildroot}?')
|
2006-05-12 21:53:43 +08:00
|
|
|
configure_start_regex = re.compile('\./configure')
|
|
|
|
configure_libdir_spec_regex = re.compile('ln |\./configure[^#]*--libdir=([^\s]+)[^#]*')
|
|
|
|
lib_package_regex = re.compile('^%package.*\Wlib')
|
|
|
|
mklibname_regex = re.compile('%mklibname')
|
|
|
|
ifarch_regex = re.compile('%ifn?arch')
|
|
|
|
if_regex = re.compile('%if\s+')
|
|
|
|
endif_regex = re.compile('%endif')
|
|
|
|
biarch_package_regex = re.compile(DEFAULT_BIARCH_PACKAGES)
|
|
|
|
hardcoded_lib_path_exceptions_regex = re.compile(Config.getOption('HardcodedLibPathExceptions', DEFAULT_HARDCODED_LIB_PATH_EXCEPTIONS))
|
2006-12-04 06:43:16 +08:00
|
|
|
prereq_regex = re.compile('^PreReq(\(.*\))?:\s*(.+?)\s*$', re.IGNORECASE)
|
2006-05-12 21:53:43 +08:00
|
|
|
buildprereq_regex = re.compile('^BuildPreReq:\s*(.+?)\s*$', re.IGNORECASE)
|
|
|
|
use_utf8 = Config.getOption('UseUTF8', Config.USEUTF8_DEFAULT)
|
2006-06-06 02:57:33 +08:00
|
|
|
macro_regex = re.compile('(%+)[{(]?(\w+)')
|
2003-05-08 16:03:35 +08:00
|
|
|
|
2002-06-01 21:17:28 +08:00
|
|
|
# Only check for /lib, /usr/lib, /usr/X11R6/lib
|
|
|
|
# TODO: better handling of X libraries and modules.
|
2006-05-12 21:53:43 +08:00
|
|
|
hardcoded_library_paths = '(/lib|/usr/lib|/usr/X11R6/lib/(?!([^/]+/)+)[^/]*\\.([oa]|la|so[0-9.]*))'
|
|
|
|
hardcoded_library_path_regex = re.compile('^[^#]*((^|\s+|\.\./\.\.|\${?RPM_BUILD_ROOT}?|%{?buildroot}?|%{?_prefix}?)' + hardcoded_library_paths + '(?=[\s;/])([^\s,;]*))')
|
2000-10-11 14:03:08 +08:00
|
|
|
|
2006-12-04 06:43:16 +08:00
|
|
|
# Requires(pre,post) is broken in some rpm versions, see
|
|
|
|
# https://bugzilla.redhat.com/118780 and bugs linked to that one.
|
|
|
|
scriptlet_requires_regex = re.compile('^(PreReq|Requires)\([^\)]*,', re.IGNORECASE)
|
2006-02-02 23:16:30 +08:00
|
|
|
|
2006-06-16 04:44:26 +08:00
|
|
|
depscript_override_regex = re.compile('(^|\s)%(define|global)\s+__find_(requires|provides)\s')
|
|
|
|
depgen_disable_regex = re.compile('(^|\s)%(define|global)\s+_use_internal_dependency_generator\s+0')
|
|
|
|
|
2006-06-23 00:04:13 +08:00
|
|
|
indent_spaces_regex = re.compile(' {3}.*\S')
|
|
|
|
indent_tabs_regex = re.compile('\t.*\S')
|
|
|
|
|
2006-09-04 02:32:13 +08:00
|
|
|
provides_regex = re.compile('^Provides(?:\([^\)]+\))?:\s*(.*)', re.IGNORECASE)
|
|
|
|
obsoletes_regex = re.compile('^Obsoletes:\s*(.*)', re.IGNORECASE)
|
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
def file2string(file):
|
2006-07-26 06:22:34 +08:00
|
|
|
# TODO: file I/O error handling
|
2006-05-12 21:53:43 +08:00
|
|
|
fd = open(file, "r")
|
|
|
|
content = fd.readlines()
|
2000-10-11 14:03:08 +08:00
|
|
|
fd.close()
|
|
|
|
return content
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-09-04 02:32:13 +08:00
|
|
|
def deptokens(line):
|
|
|
|
'''Parse provides/requires/conflicts/obsoletes line to dep token list.'''
|
|
|
|
prco = []
|
|
|
|
tmp = ''
|
|
|
|
wantmore = 0
|
|
|
|
for tok in re.split('[\s,]+', line.strip()):
|
|
|
|
if len(tmp) == 0:
|
|
|
|
tmp = tok
|
|
|
|
elif wantmore:
|
|
|
|
tmp += ' ' + tok
|
|
|
|
wantmore = 0
|
|
|
|
elif tok[0] in ('=', '<', '>'):
|
|
|
|
tmp += ' ' + tok
|
|
|
|
wantmore = 1
|
|
|
|
else:
|
|
|
|
prco.append(tmp)
|
|
|
|
wantmore = 0
|
|
|
|
tmp = tok
|
|
|
|
if len(tmp) != 0:
|
|
|
|
prco.append(tmp)
|
|
|
|
return prco
|
|
|
|
|
|
|
|
def versioned(toks):
|
|
|
|
'''Return versioned dependency tokens from the given list.'''
|
|
|
|
res = []
|
|
|
|
for tok in toks:
|
|
|
|
if tok.find('=') > 0 or tok.find('<') > 0 or tok.find('>') > 0:
|
|
|
|
res.append(tok)
|
|
|
|
return res
|
|
|
|
|
|
|
|
def unversioned(toks):
|
|
|
|
'''Return unversioned dependency tokens from the given list.'''
|
|
|
|
res = []
|
|
|
|
for tok in toks:
|
|
|
|
if tok.find(' ') < 0:
|
|
|
|
res.append(tok)
|
|
|
|
return res
|
|
|
|
|
2006-09-09 18:57:13 +08:00
|
|
|
def contains_buildroot(line):
|
|
|
|
'''Check if the given line contains use of rpm buildroot.'''
|
|
|
|
res = rpm_buildroot_regex.search(line)
|
|
|
|
if res and \
|
|
|
|
(not res.group(1) or len(res.group(1)) % 2 == 0) and \
|
|
|
|
(not res.group(2) or len(res.group(2)) % 2 != 0):
|
|
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
class SpecCheck(AbstractCheck.AbstractCheck):
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
def __init__(self):
|
2005-11-28 05:49:15 +08:00
|
|
|
AbstractCheck.AbstractCheck.__init__(self, "SpecCheck")
|
2000-10-11 14:03:08 +08:00
|
|
|
|
2001-11-15 00:34:02 +08:00
|
|
|
def check(self, pkg):
|
2000-10-11 14:03:08 +08:00
|
|
|
if not pkg.isSource():
|
|
|
|
return
|
|
|
|
|
|
|
|
# lookup spec file
|
2006-05-12 21:53:43 +08:00
|
|
|
files = pkg.files()
|
|
|
|
spec_file = None
|
2005-11-28 05:49:15 +08:00
|
|
|
for f in files.keys():
|
2006-07-07 00:21:39 +08:00
|
|
|
if f.endswith('.spec'):
|
2006-05-12 21:53:43 +08:00
|
|
|
spec_file = pkg.dirName() + "/" + f
|
2000-10-11 14:03:08 +08:00
|
|
|
break
|
|
|
|
if not spec_file:
|
|
|
|
printError(pkg, "no-spec-file")
|
|
|
|
else:
|
2006-06-16 04:21:19 +08:00
|
|
|
if f != pkg.name + ".spec":
|
2000-10-11 16:41:39 +08:00
|
|
|
printError(pkg, "invalid-spec-name", f)
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# check content of spec file
|
2006-05-12 21:53:43 +08:00
|
|
|
spec = file2string(spec_file)
|
|
|
|
patches = {}
|
|
|
|
applied_patches = []
|
|
|
|
applied_patches_ifarch = []
|
|
|
|
source_dir = None
|
|
|
|
buildroot = 0
|
|
|
|
configure = 0
|
|
|
|
configure_cmdline = ""
|
|
|
|
mklibname = 0
|
|
|
|
lib = 0
|
|
|
|
if_depth = 0
|
|
|
|
ifarch_depth = -1
|
2006-05-12 23:39:04 +08:00
|
|
|
current_section = 'package'
|
2006-05-13 17:16:20 +08:00
|
|
|
buildroot_clean={'clean':0 , 'install':0}
|
2006-06-16 04:44:26 +08:00
|
|
|
depscript_override = 0
|
|
|
|
depgen_disabled = 0
|
2006-06-23 00:04:13 +08:00
|
|
|
indent_spaces = 0
|
|
|
|
indent_tabs = 0
|
2006-06-29 17:47:57 +08:00
|
|
|
section = {}
|
|
|
|
for sec in ['description', 'prep', 'build', 'install', 'clean',
|
|
|
|
'files', 'changelog', 'package', 'check']:
|
|
|
|
section[sec] = {
|
|
|
|
'count': 0,
|
|
|
|
're': re.compile('^%' + sec + '(?:\s|$)'),
|
|
|
|
}
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-01-15 17:59:04 +08:00
|
|
|
if use_utf8 and not is_utf8(spec_file):
|
|
|
|
printError(pkg, "non-utf8-spec-file", f)
|
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# gather info from spec lines
|
2006-06-30 03:50:33 +08:00
|
|
|
|
|
|
|
linenum = 0
|
2000-10-11 14:03:08 +08:00
|
|
|
for line in spec:
|
2006-06-06 03:04:39 +08:00
|
|
|
|
2006-06-30 03:50:33 +08:00
|
|
|
linenum += 1
|
2006-06-06 03:04:39 +08:00
|
|
|
section_marker = 0
|
2006-05-12 23:39:04 +08:00
|
|
|
for i in section.keys():
|
|
|
|
if section[i]['re'].search(line):
|
|
|
|
current_section = i
|
2006-06-06 03:04:39 +08:00
|
|
|
section_marker = 1
|
2006-06-29 17:47:57 +08:00
|
|
|
section[i]['count'] = section[i]['count'] + 1
|
2006-06-06 03:04:39 +08:00
|
|
|
|
|
|
|
if section_marker:
|
|
|
|
continue
|
2003-05-08 16:41:05 +08:00
|
|
|
|
2006-05-13 17:20:36 +08:00
|
|
|
if current_section in ('prep', 'build'):
|
2006-09-09 18:57:13 +08:00
|
|
|
if contains_buildroot(line):
|
|
|
|
printWarning(pkg, 'rpm-buildroot-usage', '%' + current_section, line[:-1].strip())
|
2006-05-13 17:20:36 +08:00
|
|
|
|
2006-07-13 04:33:22 +08:00
|
|
|
if make_check_regexp.search(line) and current_section not in ('check', 'changelog', 'package', 'description'):
|
2006-05-13 17:29:23 +08:00
|
|
|
printWarning(pkg, 'make-check-outside-check-section', line[:-1])
|
2006-05-13 17:20:36 +08:00
|
|
|
|
2006-05-13 17:16:20 +08:00
|
|
|
if current_section in buildroot_clean.keys():
|
2006-09-09 18:57:13 +08:00
|
|
|
if contains_buildroot(line) and rm_regex.search(line):
|
2006-05-13 17:16:20 +08:00
|
|
|
buildroot_clean[current_section] = 1
|
|
|
|
|
2006-05-12 22:00:39 +08:00
|
|
|
if ifarch_regex.search(line):
|
2003-05-08 16:41:05 +08:00
|
|
|
if_depth = if_depth + 1
|
|
|
|
ifarch_depth = if_depth
|
2006-05-12 22:00:39 +08:00
|
|
|
|
|
|
|
if if_regex.search(line):
|
2003-05-08 16:41:05 +08:00
|
|
|
if_depth = if_depth + 1
|
2006-05-12 22:00:39 +08:00
|
|
|
|
2006-07-07 00:21:39 +08:00
|
|
|
if line.startswith('%setup'):
|
2006-05-13 00:28:02 +08:00
|
|
|
if line.find(' -q') < 1:
|
|
|
|
printWarning(pkg, 'setup-not-quiet')
|
|
|
|
|
2006-05-12 22:00:39 +08:00
|
|
|
if endif_regex.search(line):
|
2003-05-08 16:41:05 +08:00
|
|
|
if ifarch_depth == if_depth:
|
|
|
|
ifarch_depth = -1
|
|
|
|
if_depth = if_depth - 1
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
res=patch_regex.search(line)
|
|
|
|
if res:
|
2006-05-12 21:53:43 +08:00
|
|
|
patches[res.group(1)] = res.group(2)
|
2000-10-11 14:03:08 +08:00
|
|
|
else:
|
2006-05-12 21:53:43 +08:00
|
|
|
res = applied_patch_regex.search(line)
|
2000-10-11 14:03:08 +08:00
|
|
|
if res:
|
2003-07-23 03:45:14 +08:00
|
|
|
applied_patches.append(res.group(1) or res.group(2))
|
2003-05-08 16:41:05 +08:00
|
|
|
if ifarch_depth > 0:
|
|
|
|
applied_patches_ifarch.append(res.group(1))
|
2000-10-11 14:12:27 +08:00
|
|
|
elif not source_dir:
|
2006-05-12 21:53:43 +08:00
|
|
|
res = source_dir_regex.search(line)
|
2000-10-11 14:12:27 +08:00
|
|
|
if res:
|
2006-05-12 21:53:43 +08:00
|
|
|
source_dir = 1
|
2000-10-11 14:12:27 +08:00
|
|
|
printError(pkg, "use-of-RPM_SOURCE_DIR")
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2001-06-20 19:33:02 +08:00
|
|
|
res=obsolete_tags_regex.search(line)
|
|
|
|
if res:
|
|
|
|
printWarning(pkg, "obsolete-tag", res.group(1))
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2002-06-01 22:18:31 +08:00
|
|
|
if configure:
|
|
|
|
if configure_cmdline[-1] == "\\":
|
|
|
|
configure_cmdline=configure_cmdline[:-1] + string.strip(line)
|
|
|
|
else:
|
2006-05-12 21:53:43 +08:00
|
|
|
configure = 0
|
|
|
|
res = configure_libdir_spec_regex.search(configure_cmdline)
|
2002-06-01 22:18:31 +08:00
|
|
|
if not res:
|
|
|
|
printError(pkg, "configure-without-libdir-spec")
|
2005-08-10 12:56:11 +08:00
|
|
|
elif res.group(1):
|
2006-05-12 21:53:43 +08:00
|
|
|
res = re.match(hardcoded_library_paths, res.group(1))
|
2002-06-01 22:18:31 +08:00
|
|
|
if res:
|
|
|
|
printError(pkg, "hardcoded-library-path", res.group(1), "in configure options")
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-05-12 23:39:04 +08:00
|
|
|
if current_section != 'changelog' and configure_start_regex.search(line):
|
2006-05-12 21:53:43 +08:00
|
|
|
configure = 1
|
|
|
|
configure_cmdline = string.strip(line)
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-05-12 21:53:43 +08:00
|
|
|
res = hardcoded_library_path_regex.search(line)
|
2006-06-16 04:21:19 +08:00
|
|
|
if current_section != 'changelog' and res and not (biarch_package_regex.match(pkg.name) or hardcoded_lib_path_exceptions_regex.search(string.lstrip(res.group(1)))):
|
2002-06-01 22:18:31 +08:00
|
|
|
printError(pkg, "hardcoded-library-path", "in", string.lstrip(res.group(1)))
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-05-12 21:53:43 +08:00
|
|
|
res = buildroot_regex.search(line)
|
2001-11-14 13:11:24 +08:00
|
|
|
if res:
|
|
|
|
buildroot=1
|
2006-07-07 00:21:39 +08:00
|
|
|
if res.group(1).startswith('/'):
|
2001-11-14 13:11:24 +08:00
|
|
|
printWarning(pkg, 'hardcoded-path-in-buildroot-tag', res.group(1))
|
2002-01-26 05:55:59 +08:00
|
|
|
|
2006-05-12 21:53:43 +08:00
|
|
|
res = packager_regex.search(line)
|
2005-02-11 16:39:04 +08:00
|
|
|
if res:
|
2005-11-28 05:49:15 +08:00
|
|
|
printWarning(pkg, 'hardcoded-packager-tag', res.group(1))
|
|
|
|
res=prefix_regex.search(line)
|
2005-02-11 16:39:04 +08:00
|
|
|
if res:
|
2006-06-06 03:00:16 +08:00
|
|
|
if res.group(1) == '%{_prefix}' or res.group(1) == '%_prefix':
|
2005-02-11 16:39:04 +08:00
|
|
|
printWarning(pkg, 'redundant-prefix-tag')
|
2005-11-28 05:49:15 +08:00
|
|
|
else:
|
2005-02-11 16:39:04 +08:00
|
|
|
printWarning(pkg, 'hardcoded-prefix-tag', res.group(1))
|
|
|
|
|
2003-01-17 06:28:57 +08:00
|
|
|
if mklibname_regex.search(line):
|
2006-05-12 21:53:43 +08:00
|
|
|
mklibname = 1
|
2003-01-17 06:28:57 +08:00
|
|
|
|
|
|
|
if lib_package_regex.search(line):
|
2006-05-12 21:53:43 +08:00
|
|
|
lib = 1
|
2005-08-10 14:10:39 +08:00
|
|
|
|
2006-05-12 21:53:43 +08:00
|
|
|
res = prereq_regex.search(line)
|
2005-08-10 14:10:39 +08:00
|
|
|
if res:
|
2006-12-04 06:43:16 +08:00
|
|
|
printWarning(pkg, 'prereq-use', res.group(2))
|
2006-02-13 00:31:00 +08:00
|
|
|
|
2006-05-12 21:53:43 +08:00
|
|
|
res = buildprereq_regex.search(line)
|
2006-02-13 00:31:00 +08:00
|
|
|
if res:
|
|
|
|
printWarning(pkg, 'buildprereq-use', res.group(1))
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-08-25 00:00:08 +08:00
|
|
|
if scriptlet_requires_regex.search(line) and current_section == 'package':
|
2006-02-02 23:16:30 +08:00
|
|
|
printError(pkg, 'broken-syntax-in-scriptlet-requires', string.strip(line))
|
|
|
|
|
2006-06-06 02:57:33 +08:00
|
|
|
if current_section == 'changelog':
|
|
|
|
res = macro_regex.search(line)
|
|
|
|
if res and len(res.group(1)) % 2:
|
|
|
|
printWarning(pkg, 'macro-in-%changelog', res.group(2))
|
2006-06-16 04:44:26 +08:00
|
|
|
else:
|
|
|
|
if not depscript_override:
|
|
|
|
depscript_override = depscript_override_regex.search(line)
|
|
|
|
if not depgen_disabled:
|
|
|
|
depgen_disabled = depgen_disable_regex.search(line)
|
2006-06-06 02:57:33 +08:00
|
|
|
|
2006-09-04 02:32:13 +08:00
|
|
|
res = provides_regex.search(line)
|
|
|
|
if res:
|
|
|
|
for prov in unversioned(deptokens(res.group(1))):
|
|
|
|
printWarning(pkg, 'unversioned-explicit-provides', prov)
|
|
|
|
|
|
|
|
res = obsoletes_regex.search(line)
|
|
|
|
if res:
|
|
|
|
for obs in unversioned(deptokens(res.group(1))):
|
|
|
|
printWarning(pkg, 'unversioned-explicit-obsoletes', obs)
|
|
|
|
|
2006-06-23 00:04:13 +08:00
|
|
|
if not indent_tabs and indent_tabs_regex.search(line):
|
2006-06-30 03:50:33 +08:00
|
|
|
indent_tabs = linenum
|
2006-06-23 00:04:13 +08:00
|
|
|
if not indent_spaces and indent_spaces_regex.search(line):
|
2006-06-30 03:50:33 +08:00
|
|
|
indent_spaces = linenum
|
2006-06-23 00:04:13 +08:00
|
|
|
|
2006-09-09 18:55:22 +08:00
|
|
|
for sect in buildroot_clean:
|
|
|
|
if not buildroot_clean[sect]:
|
|
|
|
printError(pkg, 'no-cleaning-of-buildroot', '%' + sect)
|
2006-05-13 17:16:20 +08:00
|
|
|
|
2001-11-14 13:11:24 +08:00
|
|
|
if not buildroot:
|
|
|
|
printError(pkg, 'no-buildroot-tag')
|
2002-01-26 05:55:59 +08:00
|
|
|
|
2006-09-24 04:09:38 +08:00
|
|
|
for sec in ('prep', 'build', 'install', 'clean'):
|
2006-06-29 17:47:57 +08:00
|
|
|
if not section[sec]['count']:
|
|
|
|
printWarning(pkg, 'no-%%%s-section' % sec)
|
2006-12-11 06:39:23 +08:00
|
|
|
for sec in ('changelog',):
|
|
|
|
# prep, build, install, clean, check prevented by rpmbuild
|
|
|
|
if section[sec]['count'] > 1:
|
|
|
|
printWarning(pkg, 'more-than-one-%%%s-section' % sec)
|
2003-01-17 06:28:57 +08:00
|
|
|
|
|
|
|
if lib and not mklibname:
|
|
|
|
printError(pkg, 'lib-package-without-%mklibname')
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2006-06-16 04:44:26 +08:00
|
|
|
if depscript_override and not depgen_disabled:
|
|
|
|
printWarning(pkg, 'depscript-without-disabling-depgen')
|
|
|
|
|
2006-06-23 00:04:13 +08:00
|
|
|
if indent_spaces and indent_tabs:
|
2006-06-30 03:50:33 +08:00
|
|
|
printWarning(pkg, 'mixed-use-of-spaces-and-tabs',
|
|
|
|
'(spaces: line %d, tab: line %d)' %
|
|
|
|
(indent_spaces, indent_tabs))
|
2006-06-23 00:04:13 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# process gathered info
|
|
|
|
for p in patches.keys():
|
2003-05-08 16:41:05 +08:00
|
|
|
if p in applied_patches_ifarch:
|
2003-05-09 20:43:19 +08:00
|
|
|
printWarning(pkg, "%ifarch-applied-patch", "Patch" + p + ":", patches[p])
|
2000-10-11 14:03:08 +08:00
|
|
|
if p not in applied_patches:
|
|
|
|
if p == "" and "0" in applied_patches:
|
|
|
|
continue
|
|
|
|
if p == "0" and "" in applied_patches:
|
|
|
|
continue
|
|
|
|
printWarning(pkg, "patch-not-applied", "Patch" + p + ":", patches[p])
|
|
|
|
|
|
|
|
# Create an object to enable the auto registration of the test
|
2006-05-12 21:53:43 +08:00
|
|
|
check = SpecCheck()
|
2000-10-11 14:03:08 +08:00
|
|
|
|
2001-06-20 19:33:02 +08:00
|
|
|
# Add information about checks
|
|
|
|
if Config.info:
|
|
|
|
addDetails(
|
2001-07-04 05:13:22 +08:00
|
|
|
'no-spec-file',
|
2001-07-16 01:01:17 +08:00
|
|
|
'''No spec file was specified in your RPM building. Please specify a valid
|
|
|
|
SPEC file to build a valid RPM package.''',
|
2001-07-04 05:13:22 +08:00
|
|
|
|
|
|
|
'invalid-spec-name',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''Your spec filename must end with '.spec'. If it's not the case, rename your
|
2001-07-16 01:01:17 +08:00
|
|
|
file and rebuild your package.''',
|
2001-07-04 05:13:22 +08:00
|
|
|
|
2006-01-15 17:59:04 +08:00
|
|
|
'non-utf8-spec-file',
|
|
|
|
'''The character encoding of the spec file is not UTF-8. Convert it for
|
|
|
|
example using iconv(1).''',
|
|
|
|
|
2001-07-04 05:13:22 +08:00
|
|
|
'use-of-RPM_SOURCE_DIR',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''You use $RPM_SOURCE_DIR or %{_sourcedir} in your spec file. If you have to
|
|
|
|
use a directory for building, use $RPM_BUILD_ROOT instead.''',
|
2001-07-04 05:13:22 +08:00
|
|
|
|
|
|
|
'patch-not-applied',
|
2001-07-16 01:01:17 +08:00
|
|
|
'''A patch is included in your package but was not applied. Refer to the patches
|
|
|
|
documentation to see what's wrong.''',
|
2001-07-04 05:13:22 +08:00
|
|
|
|
2001-06-20 19:33:02 +08:00
|
|
|
'obsolete-tag',
|
|
|
|
'''The following tags are obsolete: Copyright and Serial. They must
|
|
|
|
be replaced by License and Epoch respectively.''',
|
2001-07-16 01:01:17 +08:00
|
|
|
|
2001-11-14 13:11:24 +08:00
|
|
|
'no-buildroot-tag',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''The BuildRoot tag isn't used in your spec. It must be used in order to
|
|
|
|
allow building the package as non root on some systems.''',
|
2001-11-14 13:11:24 +08:00
|
|
|
|
|
|
|
'hardcoded-path-in-buildroot-tag',
|
|
|
|
'''A path is hardcoded in your Buildroot tag. It should be replaced
|
|
|
|
by something like %{_tmppath}/%name-root.''',
|
|
|
|
|
2005-02-11 16:39:04 +08:00
|
|
|
'hardcoded-packager-tag',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''The Packager tag is hardcoded in your spec file. It should be removed, so
|
|
|
|
as to use rebuilder's own defaults.''',
|
2005-02-11 16:39:04 +08:00
|
|
|
|
|
|
|
'hardcoded-prefix-tag',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''The Prefix tag is hardcoded in your spec file. It should be removed, so as
|
|
|
|
to allow package relocation.''',
|
2005-02-11 16:39:04 +08:00
|
|
|
|
|
|
|
'redundant-prefix-tag',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''The Prefix tag is uselessly defined as %{_prefix} in your spec file. It
|
|
|
|
should be removed, as it is redundant with rpm defaults.''',
|
2005-02-11 16:39:04 +08:00
|
|
|
|
2002-06-01 22:18:31 +08:00
|
|
|
'hardcoded-library-path',
|
2002-06-01 21:17:28 +08:00
|
|
|
'''A library path is hardcoded to one of the following paths: /lib,
|
|
|
|
/usr/lib. It should be replaced by something like /%{_lib} or %{_libdir}.''',
|
|
|
|
|
2002-06-01 22:18:31 +08:00
|
|
|
'configure-without-libdir-spec',
|
2005-11-23 00:36:30 +08:00
|
|
|
'''A configure script is run without specifying the libdir. configure
|
|
|
|
options must be augmented with something like --libdir=%{_libdir}.''',
|
2002-06-01 22:18:31 +08:00
|
|
|
|
2006-06-29 17:47:57 +08:00
|
|
|
'no-%prep-section',
|
|
|
|
'''The spec file does not contain a %prep section. Even if some packages don't
|
|
|
|
directly need it, section markers may be overridden in rpm's configuration
|
|
|
|
to provide additional "under the hood" functionality. Add the section, even
|
|
|
|
if empty.''',
|
|
|
|
|
|
|
|
'no-%build-section',
|
|
|
|
'''The spec file does not contain a %build section. Even if some packages
|
|
|
|
don't directly need it, section markers may be overridden in rpm's
|
|
|
|
configuration to provide additional "under the hood" functionality, such as
|
|
|
|
injection of automatic -debuginfo subpackages. Add the section, even if
|
|
|
|
empty.''',
|
|
|
|
|
|
|
|
'no-%install-section',
|
|
|
|
'''The spec file does not contain an %install section. Even if some packages
|
|
|
|
don't directly need it, section markers may be overridden in rpm's
|
|
|
|
configuration to provide additional "under the hood" functionality. Add the
|
|
|
|
section, even if empty.''',
|
|
|
|
|
2002-01-26 05:55:59 +08:00
|
|
|
'no-%clean-section',
|
|
|
|
'''The spec file doesn't contain a %clean section to remove the files installed
|
|
|
|
by the %install section.''',
|
|
|
|
|
2006-12-11 06:39:23 +08:00
|
|
|
'more-than-one-%changelog-section',
|
|
|
|
'''The spec file unnecessarily contains more than one %changelog section;
|
|
|
|
remove the extra ones.''',
|
|
|
|
|
2003-01-17 06:28:57 +08:00
|
|
|
'lib-package-without-%mklibname',
|
|
|
|
'''The package name must be built using %mklibname to allow lib64 and lib32
|
|
|
|
coexistence.''',
|
|
|
|
|
2003-05-08 16:41:05 +08:00
|
|
|
'%ifarch-applied-patch',
|
|
|
|
'''A patch is applied inside an %ifarch block. Patches must be applied
|
|
|
|
on all architectures and may contain necessary configure and/or code
|
2005-08-10 14:10:39 +08:00
|
|
|
patch to be effective only on a given arch.''',
|
|
|
|
|
|
|
|
'prereq-use',
|
2006-02-13 00:31:00 +08:00
|
|
|
'''The use of PreReq is deprecated. In the majority of cases, a plain Requires
|
|
|
|
is enough and the right thing to do. Sometimes Requires(pre), Requires(post),
|
|
|
|
Requires(preun) and/or Requires(postun) can also be used instead of PreReq.''',
|
|
|
|
|
|
|
|
'buildprereq-use',
|
|
|
|
'''The use of BuildPreReq is deprecated, build dependencies are always required
|
|
|
|
before a package can be built. Use plain BuildRequires instead.''',
|
2003-05-08 16:41:05 +08:00
|
|
|
|
2006-02-02 23:16:30 +08:00
|
|
|
'broken-syntax-in-scriptlet-requires',
|
2006-12-04 06:43:16 +08:00
|
|
|
'''Comma separated context marked dependencies are silently broken in some
|
|
|
|
versions of rpm. One way to work around it is to split them into several ones,
|
|
|
|
eg. replace "Requires(post,preun): foo" with "Requires(post): foo" and
|
|
|
|
"Requires(preun): foo".''',
|
2006-02-02 23:16:30 +08:00
|
|
|
|
2006-05-13 00:28:02 +08:00
|
|
|
'setup-not-quiet',
|
|
|
|
'''You should use -q to have a quiet extraction of the source tarball, as this
|
|
|
|
generate useless lines of log ( for buildbot, for example )''',
|
|
|
|
|
2006-05-13 17:16:20 +08:00
|
|
|
'no-cleaning-of-buildroot',
|
2006-05-13 17:35:12 +08:00
|
|
|
'''You should clean $RPM_BUILD_ROOT in the %clean section and just after the
|
|
|
|
beginning of %install section. Use "rm -Rf $RPM_BUILD_ROOT".''',
|
2006-05-13 17:16:20 +08:00
|
|
|
|
2006-05-13 17:20:36 +08:00
|
|
|
'rpm-buildroot-usage',
|
|
|
|
'''$RPM_BUILD_ROOT should not be touched during %build or %prep stage, as it
|
|
|
|
will break short circuiting.''',
|
|
|
|
|
2006-05-13 17:29:23 +08:00
|
|
|
'make-check-outside-check-section',
|
2006-05-13 17:35:12 +08:00
|
|
|
'''Make check or other automated regression test should be run in %check, as
|
2006-06-06 02:57:33 +08:00
|
|
|
they can be disabled with a rpm macro for short circuiting purposes.''',
|
|
|
|
|
|
|
|
'macro-in-%changelog',
|
|
|
|
'''Macros are expanded in %changelog too, which can in unfortunate cases lead
|
|
|
|
to the package not building at all, or other subtle unexpected conditions that
|
|
|
|
affect the build. Even when that doesn\'t happen, the expansion results in
|
|
|
|
possibly "rewriting history" on subsequent package revisions and generally
|
|
|
|
odd entries eg. in source rpms, which is rarely wanted. Avoid use of macros
|
|
|
|
in %changelog altogether, or use two '%'s to escape them, like '%%foo'.''',
|
2006-06-16 04:44:26 +08:00
|
|
|
|
|
|
|
'depscript-without-disabling-depgen',
|
|
|
|
'''In some common rpm configurations/versions, defining __find_provides and/or
|
|
|
|
__find_requires has no effect if rpm's internal dependency generator has not
|
|
|
|
been disabled for the build. %define _use_internal_dependency_generator to 0
|
|
|
|
to disable it in the specfile, or don't define __find_provides/requires.''',
|
2006-06-23 00:04:13 +08:00
|
|
|
|
|
|
|
'mixed-use-of-spaces-and-tabs',
|
|
|
|
'''The specfile mixes use of spaces and tabs for indentation, which is a
|
|
|
|
cosmetic annoyance. Use either spaces or tabs for indentation, not both.''',
|
2006-09-04 02:32:13 +08:00
|
|
|
|
|
|
|
'unversioned-explicit-provides',
|
|
|
|
'''The specfile contains an unversioned Provides: token, which will match all
|
|
|
|
older, equal, and newer versions of the provided thing. This may cause
|
|
|
|
update problems and will make versioned dependencies, obsoletions and conflicts
|
|
|
|
on the provided thing useless -- make the Provides versioned if possible.''',
|
|
|
|
|
|
|
|
'unversioned-explicit-obsoletes',
|
|
|
|
'''The specfile contains an unversioned Obsoletes: token, which will match all
|
|
|
|
older, equal and newer versions of the obsoleted thing. This may cause update
|
|
|
|
problems, restrict future package/provides naming, and may match something it
|
|
|
|
was originally not inteded to match -- make the Obsoletes versioned if
|
|
|
|
possible.''',
|
2001-06-20 19:33:02 +08:00
|
|
|
)
|
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# SpecCheck.py ends here
|
2006-04-01 16:09:17 +08:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# indent-tabs-mode: nil
|
|
|
|
# py-indent-offset: 4
|
|
|
|
# End:
|
|
|
|
# ex: ts=4 sw=4 et
|