2009-01-24 05:18:08 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
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
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
import re
|
2010-01-21 01:48:00 +08:00
|
|
|
try:
|
|
|
|
from urlparse import urlparse
|
|
|
|
except ImportError: # Python 3
|
|
|
|
from urllib.parse import urlparse
|
|
|
|
|
|
|
|
import rpm
|
2009-01-27 06:54:05 +08:00
|
|
|
|
2009-01-28 06:44:45 +08:00
|
|
|
from Filter import addDetails, printError, printWarning
|
2009-01-22 07:01:18 +08:00
|
|
|
from TagsCheck import VALID_GROUPS
|
2009-01-27 06:54:05 +08:00
|
|
|
import AbstractCheck
|
|
|
|
import Config
|
|
|
|
import Pkg
|
|
|
|
|
2003-05-08 16:03:35 +08:00
|
|
|
|
|
|
|
# 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
|
2007-03-11 07:05:21 +08:00
|
|
|
DEFAULT_HARDCODED_LIB_PATH_EXCEPTIONS = '/lib/(modules|cpp|perl5|rpm|hotplug|firmware)($|[\s/,])'
|
2010-04-01 04:11:20 +08:00
|
|
|
patch_regex = re.compile("^Patch(\d*)\s*:\s*(\S+)", re.IGNORECASE)
|
2009-01-15 01:49:22 +08:00
|
|
|
applied_patch_regex = re.compile("^%patch(\d*)")
|
|
|
|
applied_patch_p_regex = re.compile("\s-P\s+(\d+)\\b")
|
2006-05-12 21:53:43 +08:00
|
|
|
source_dir_regex = re.compile("^[^#]*(\$RPM_SOURCE_DIR|%{?_sourcedir}?)")
|
2010-04-01 04:11:20 +08:00
|
|
|
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)
|
2008-03-25 04:45:35 +08:00
|
|
|
noarch_regex = re.compile('^BuildArch(?:itectures)?\s*:\s*\\bnoarch\\b', re.IGNORECASE)
|
2009-01-24 05:08:09 +08:00
|
|
|
make_check_regex = re.compile('(^|\s|%{?__)make}?\s+(check|test)')
|
2006-05-13 17:49:35 +08:00
|
|
|
rm_regex = re.compile('(^|\s)((.*/)?rm|%{?__rm}?) ')
|
2010-04-01 01:35:51 +08:00
|
|
|
rpm_buildroot_regex = re.compile('^[^#]*(?:(\\\*)\${?RPM_BUILD_ROOT}?|(%+){?buildroot}?)')
|
2010-04-01 04:11:20 +08:00
|
|
|
configure_libdir_spec_regex = re.compile('ln |\./configure[^#]*--libdir=(\S+)[^#]*')
|
2006-05-12 21:53:43 +08:00
|
|
|
lib_package_regex = re.compile('^%package.*\Wlib')
|
2010-04-01 03:58:01 +08:00
|
|
|
ifarch_regex = re.compile('^\s*%ifn?arch\s')
|
|
|
|
if_regex = re.compile('^\s*%if\s')
|
|
|
|
endif_regex = re.compile('^\s*%endif\\b')
|
2006-05-12 21:53:43 +08:00
|
|
|
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)
|
2008-03-25 04:45:35 +08:00
|
|
|
libdir_regex = re.compile('%{?_lib(?:dir)?\}?\\b')
|
2008-04-30 02:45:03 +08:00
|
|
|
comment_or_empty_regex = re.compile('^\s*(#|$)')
|
|
|
|
defattr_regex = re.compile('^\s*%defattr\\b')
|
|
|
|
attr_regex = re.compile('^\s*%attr\\b')
|
2009-01-30 04:15:44 +08:00
|
|
|
section_regexs = dict(
|
|
|
|
([x, re.compile('^%' + x + '(?:\s|$)')]
|
|
|
|
for x in ('build', 'changelog', 'check', 'clean', 'description', 'files',
|
2010-03-14 22:56:41 +08:00
|
|
|
'install', 'package', 'prep', 'pre', 'post', 'preun', 'postun',
|
|
|
|
'trigger', 'triggerin', 'triggerun', 'triggerprein',
|
|
|
|
'triggerpostun', 'pretrans', 'posttrans')))
|
2010-03-14 23:13:32 +08:00
|
|
|
deprecated_grep_regex = re.compile(r'\b[ef]grep\b')
|
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')
|
|
|
|
|
2009-03-20 05:05:02 +08:00
|
|
|
# See https://bugzilla.redhat.com/488146 for details
|
|
|
|
indent_spaces_regex = re.compile('( \t|(^|\t)([^\t]{8})*[^\t]{4}[^\t]?([^\t][^\t.!?]|[^\t]?[.!?] ) )')
|
2006-06-23 00:04:13 +08:00
|
|
|
|
2009-05-20 23:30:55 +08:00
|
|
|
requires_regex = re.compile('^(?:Build)?(?:Pre)?Req(?:uires)?(?:\([^\)]+\))?:\s*(.*)', re.IGNORECASE)
|
2006-09-04 02:32:13 +08:00
|
|
|
provides_regex = re.compile('^Provides(?:\([^\)]+\))?:\s*(.*)', re.IGNORECASE)
|
|
|
|
obsoletes_regex = re.compile('^Obsoletes:\s*(.*)', re.IGNORECASE)
|
2009-05-20 23:30:55 +08:00
|
|
|
conflicts_regex = re.compile('^(?:Build)?Conflicts:\s*(.*)', re.IGNORECASE)
|
|
|
|
|
|
|
|
compop_regex = re.compile('[<>=]')
|
2006-09-04 02:32:13 +08:00
|
|
|
|
2007-02-06 05:26:31 +08:00
|
|
|
setup_q_regex = re.compile(' -[A-Za-z]*q')
|
|
|
|
setup_t_regex = re.compile(' -[A-Za-z]*T')
|
|
|
|
setup_ab_regex = re.compile(' -[A-Za-z]*[ab]')
|
|
|
|
|
2009-02-26 04:41:51 +08:00
|
|
|
filelist_regex = re.compile('\s+-f\s+\S+')
|
|
|
|
pkgname_regex = re.compile('\s+(?:-n\s+)?(\S+)')
|
2010-01-21 02:17:22 +08:00
|
|
|
tarball_regex = re.compile('\.(?:t(?:ar|[glx]z|bz2?)|zip)\\b', re.IGNORECASE)
|
|
|
|
|
2009-02-26 04:41:51 +08:00
|
|
|
|
2010-04-17 02:51:00 +08:00
|
|
|
def unversioned(deps):
|
|
|
|
'''Yield unversioned dependency names from the given list.'''
|
|
|
|
for dep in deps:
|
|
|
|
if not dep[1]:
|
|
|
|
yield dep[0]
|
2006-09-04 02:32:13 +08:00
|
|
|
|
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):
|
2009-06-17 06:13:20 +08:00
|
|
|
return True
|
|
|
|
return False
|
2006-09-09 18:57:13 +08:00
|
|
|
|
2009-01-13 04:24:23 +08:00
|
|
|
|
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")
|
2007-05-15 06:02:01 +08:00
|
|
|
self._spec_file = None
|
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
|
|
|
|
|
2008-02-27 01:24:44 +08:00
|
|
|
wrong_spec = False
|
2009-01-28 05:44:11 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# lookup spec file
|
2009-02-02 05:58:38 +08:00
|
|
|
for fname, pkgfile in pkg.files().items():
|
2009-01-28 05:44:11 +08:00
|
|
|
if fname.endswith('.spec'):
|
2009-02-02 05:58:38 +08:00
|
|
|
self._spec_file = pkgfile.path
|
2009-01-28 05:44:11 +08:00
|
|
|
if fname == pkg.name + ".spec":
|
2010-03-31 04:34:48 +08:00
|
|
|
wrong_spec = False
|
|
|
|
break
|
2008-02-27 01:24:44 +08:00
|
|
|
else:
|
2010-03-31 04:34:48 +08:00
|
|
|
wrong_spec = True
|
2007-05-15 06:02:01 +08:00
|
|
|
if not self._spec_file:
|
2000-10-11 14:03:08 +08:00
|
|
|
printError(pkg, "no-spec-file")
|
|
|
|
else:
|
2008-02-27 01:24:44 +08:00
|
|
|
if wrong_spec:
|
|
|
|
printError(pkg, "invalid-spec-name")
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# check content of spec file
|
2008-07-31 00:36:13 +08:00
|
|
|
self.check_spec(pkg, self._spec_file)
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2010-02-01 05:39:03 +08:00
|
|
|
def check_spec(self, pkg, spec_file, spec_lines=[]):
|
2008-07-31 00:36:13 +08:00
|
|
|
self._spec_file = spec_file
|
2009-01-15 03:18:42 +08:00
|
|
|
spec_only = isinstance(pkg, Pkg.FakePkg)
|
2010-02-01 05:39:03 +08:00
|
|
|
if not spec_lines:
|
|
|
|
spec_lines = Pkg.readlines(spec_file)
|
2007-05-15 06:02:01 +08:00
|
|
|
patches = {}
|
|
|
|
applied_patches = []
|
|
|
|
applied_patches_ifarch = []
|
2009-06-17 06:13:20 +08:00
|
|
|
source_dir = False
|
|
|
|
buildroot = False
|
|
|
|
configure_linenum = None
|
2007-05-15 06:02:01 +08:00
|
|
|
configure_cmdline = ""
|
2009-06-17 06:13:20 +08:00
|
|
|
mklibname = False
|
|
|
|
is_lib_pkg = False
|
2007-05-15 06:02:01 +08:00
|
|
|
if_depth = 0
|
|
|
|
ifarch_depth = -1
|
2008-11-10 03:31:39 +08:00
|
|
|
current_section = 'package'
|
2009-06-17 06:13:20 +08:00
|
|
|
buildroot_clean = {'clean': False, 'install' : False}
|
|
|
|
depscript_override = False
|
|
|
|
depgen_disabled = False
|
2007-05-15 06:02:01 +08:00
|
|
|
indent_spaces = 0
|
|
|
|
indent_tabs = 0
|
2009-06-17 06:13:20 +08:00
|
|
|
files_has_defattr = False
|
2007-05-15 06:02:01 +08:00
|
|
|
section = {}
|
2009-02-26 04:41:51 +08:00
|
|
|
# None == main package
|
|
|
|
current_package = None
|
|
|
|
package_noarch = {}
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2009-06-17 06:13:20 +08:00
|
|
|
is_utf8 = False
|
2008-07-31 00:42:38 +08:00
|
|
|
if self._spec_file and use_utf8:
|
|
|
|
if Pkg.is_utf8(self._spec_file):
|
2009-06-17 06:13:20 +08:00
|
|
|
is_utf8 = True
|
2008-07-31 00:42:38 +08:00
|
|
|
else:
|
2007-05-15 06:02:01 +08:00
|
|
|
printError(pkg, "non-utf8-spec-file", self._spec_file)
|
|
|
|
|
|
|
|
# gather info from spec lines
|
|
|
|
|
|
|
|
pkg.current_linenum = 0
|
2008-08-04 23:45:03 +08:00
|
|
|
|
|
|
|
nbsp = chr(0xA0)
|
|
|
|
if is_utf8:
|
|
|
|
nbsp = unichr(0xA0)
|
2008-11-10 03:31:39 +08:00
|
|
|
|
2007-05-15 06:02:01 +08:00
|
|
|
for line in spec_lines:
|
2008-07-31 00:42:38 +08:00
|
|
|
|
2007-05-15 06:02:01 +08:00
|
|
|
pkg.current_linenum += 1
|
2008-07-31 00:42:38 +08:00
|
|
|
|
|
|
|
if is_utf8:
|
|
|
|
line = unicode(line, "utf-8", "replace")
|
|
|
|
|
2009-09-03 03:36:33 +08:00
|
|
|
char = line.find(nbsp)
|
|
|
|
if char != -1:
|
|
|
|
printWarning(pkg, "non-break-space", "line %s, char %d" %
|
|
|
|
(pkg.current_linenum, char))
|
2008-07-31 00:42:38 +08:00
|
|
|
|
2009-06-17 06:13:20 +08:00
|
|
|
section_marker = False
|
2009-01-30 04:15:44 +08:00
|
|
|
for sec, regex in section_regexs.items():
|
2009-02-26 04:41:51 +08:00
|
|
|
res = regex.search(line)
|
|
|
|
if res:
|
2009-01-30 04:15:44 +08:00
|
|
|
current_section = sec
|
2009-06-17 06:13:20 +08:00
|
|
|
section_marker = True
|
2009-01-30 04:15:44 +08:00
|
|
|
section[sec] = section.get(sec, 0) + 1
|
2009-02-26 04:41:51 +08:00
|
|
|
if sec in ('package', 'files'):
|
|
|
|
rest = filelist_regex.sub('', line[res.end()-1:])
|
|
|
|
res = pkgname_regex.search(rest)
|
|
|
|
if res:
|
|
|
|
current_package = res.group(1)
|
|
|
|
else:
|
|
|
|
current_package = None
|
2009-01-30 04:15:44 +08:00
|
|
|
break
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
if section_marker:
|
2008-09-08 05:45:42 +08:00
|
|
|
|
2008-04-30 02:45:03 +08:00
|
|
|
if current_section == 'files':
|
2009-06-17 06:13:20 +08:00
|
|
|
files_has_defattr = False
|
2008-09-08 05:45:42 +08:00
|
|
|
|
2009-06-17 06:13:20 +08:00
|
|
|
if not is_lib_pkg and lib_package_regex.search(line):
|
|
|
|
is_lib_pkg = True
|
2008-09-08 05:45:42 +08:00
|
|
|
|
2007-05-15 06:02:01 +08:00
|
|
|
continue
|
|
|
|
|
2010-03-31 04:34:48 +08:00
|
|
|
if current_section in ('prep', 'build') and \
|
|
|
|
contains_buildroot(line):
|
|
|
|
printWarning(pkg, 'rpm-buildroot-usage', '%' + current_section,
|
|
|
|
line[:-1].strip())
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2010-02-21 19:28:42 +08:00
|
|
|
if make_check_regex.search(line) and current_section not in \
|
|
|
|
('check', 'changelog', 'package', 'description'):
|
2007-05-15 06:02:01 +08:00
|
|
|
printWarning(pkg, 'make-check-outside-check-section', line[:-1])
|
|
|
|
|
2010-02-21 19:28:42 +08:00
|
|
|
if current_section in buildroot_clean and \
|
2010-03-31 04:34:48 +08:00
|
|
|
not buildroot_clean[current_section] and \
|
|
|
|
contains_buildroot(line) and rm_regex.search(line):
|
|
|
|
buildroot_clean[current_section] = True
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
if ifarch_regex.search(line):
|
|
|
|
if_depth = if_depth + 1
|
|
|
|
ifarch_depth = if_depth
|
|
|
|
|
|
|
|
if if_regex.search(line):
|
|
|
|
if_depth = if_depth + 1
|
|
|
|
|
|
|
|
if line.startswith('%setup'):
|
|
|
|
if not setup_q_regex.search(line):
|
|
|
|
# Don't warn if there's a -T without -a or -b
|
|
|
|
if setup_t_regex.search(line):
|
|
|
|
if setup_ab_regex.search(line):
|
2007-02-06 05:26:31 +08:00
|
|
|
printWarning(pkg, 'setup-not-quiet')
|
2007-05-15 06:02:01 +08:00
|
|
|
else:
|
|
|
|
printWarning(pkg, 'setup-not-quiet')
|
2008-10-30 05:42:47 +08:00
|
|
|
if current_section != 'prep':
|
|
|
|
printWarning(pkg, 'setup-not-in-prep')
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
if endif_regex.search(line):
|
|
|
|
if ifarch_depth == if_depth:
|
|
|
|
ifarch_depth = -1
|
|
|
|
if_depth = if_depth - 1
|
|
|
|
|
2008-09-08 05:41:53 +08:00
|
|
|
res = applied_patch_regex.search(line)
|
2007-05-15 06:02:01 +08:00
|
|
|
if res:
|
2009-01-15 01:49:22 +08:00
|
|
|
pnum = res.group(1) or 0
|
|
|
|
for tmp in applied_patch_p_regex.findall(line) or [pnum]:
|
|
|
|
pnum = int(tmp);
|
|
|
|
applied_patches.append(pnum)
|
|
|
|
if ifarch_depth > 0:
|
|
|
|
applied_patches_ifarch.append(pnum)
|
2008-09-08 05:41:53 +08:00
|
|
|
elif not source_dir:
|
|
|
|
res = source_dir_regex.search(line)
|
2000-10-11 14:03:08 +08:00
|
|
|
if res:
|
2009-06-17 06:13:20 +08:00
|
|
|
source_dir = True
|
2008-09-08 05:41:53 +08:00
|
|
|
printError(pkg, "use-of-RPM_SOURCE_DIR")
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2009-06-17 06:13:20 +08:00
|
|
|
if configure_linenum:
|
2007-05-15 06:02:01 +08:00
|
|
|
if configure_cmdline[-1] == "\\":
|
2008-10-30 07:01:44 +08:00
|
|
|
configure_cmdline = configure_cmdline[:-1] + line.strip()
|
2007-05-15 06:02:01 +08:00
|
|
|
else:
|
|
|
|
res = configure_libdir_spec_regex.search(configure_cmdline)
|
|
|
|
if not res:
|
2008-09-08 05:26:25 +08:00
|
|
|
# Hack to get the correct (start of ./configure) line
|
|
|
|
# number displayed:
|
|
|
|
real_linenum = pkg.current_linenum
|
2009-06-17 06:13:20 +08:00
|
|
|
pkg.current_linenum = configure_linenum
|
2008-02-23 22:15:59 +08:00
|
|
|
printWarning(pkg, "configure-without-libdir-spec")
|
2008-09-08 05:26:25 +08:00
|
|
|
pkg.current_linenum = real_linenum
|
2007-05-15 06:02:01 +08:00
|
|
|
elif res.group(1):
|
|
|
|
res = re.match(hardcoded_library_paths, res.group(1))
|
|
|
|
if res:
|
2010-02-21 19:28:42 +08:00
|
|
|
printError(pkg, "hardcoded-library-path",
|
|
|
|
res.group(1), "in configure options")
|
2009-06-17 06:13:20 +08:00
|
|
|
configure_linenum = None
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2009-10-30 02:53:02 +08:00
|
|
|
if current_section != 'changelog' and './configure' in line:
|
2010-02-21 19:28:42 +08:00
|
|
|
# store line where it started
|
|
|
|
configure_linenum = pkg.current_linenum
|
2008-10-30 05:30:29 +08:00
|
|
|
configure_cmdline = line.strip()
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
res = hardcoded_library_path_regex.search(line)
|
2010-02-21 19:28:42 +08:00
|
|
|
if current_section != 'changelog' and res and not \
|
|
|
|
(biarch_package_regex.match(pkg.name) or
|
|
|
|
hardcoded_lib_path_exceptions_regex.search(
|
|
|
|
res.group(1).lstrip())):
|
|
|
|
printError(pkg, "hardcoded-library-path", "in",
|
|
|
|
res.group(1).lstrip())
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2009-10-30 02:53:02 +08:00
|
|
|
if '%mklibname' in line:
|
2009-06-17 06:13:20 +08:00
|
|
|
mklibname = True
|
2003-01-17 06:28:57 +08:00
|
|
|
|
2008-09-08 05:41:53 +08:00
|
|
|
if current_section == 'package':
|
2006-02-13 00:31:00 +08:00
|
|
|
|
2010-01-21 01:48:00 +08:00
|
|
|
# Would be cleaner to get sources and patches from the
|
|
|
|
# specfile parsed in Python (see below), but we want to
|
|
|
|
# catch %ifarch'd etc ones as well, and also catch these when
|
|
|
|
# the specfile is not parseable.
|
|
|
|
|
2008-09-08 05:41:53 +08:00
|
|
|
res = patch_regex.search(line)
|
|
|
|
if res:
|
|
|
|
pnum = int(res.group(1) or 0)
|
|
|
|
patches[pnum] = res.group(2)
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2008-09-08 05:41:53 +08:00
|
|
|
res = obsolete_tags_regex.search(line)
|
|
|
|
if res:
|
|
|
|
printWarning(pkg, "obsolete-tag", res.group(1))
|
2006-02-02 23:16:30 +08:00
|
|
|
|
2008-09-08 05:41:53 +08:00
|
|
|
res = buildroot_regex.search(line)
|
|
|
|
if res:
|
2009-06-17 06:13:20 +08:00
|
|
|
buildroot = True
|
2008-09-08 05:41:53 +08:00
|
|
|
if res.group(1).startswith('/'):
|
2010-02-21 19:28:42 +08:00
|
|
|
printWarning(pkg, 'hardcoded-path-in-buildroot-tag',
|
|
|
|
res.group(1))
|
2008-09-08 05:41:53 +08:00
|
|
|
|
|
|
|
res = packager_regex.search(line)
|
|
|
|
if res:
|
|
|
|
printWarning(pkg, 'hardcoded-packager-tag', res.group(1))
|
|
|
|
|
|
|
|
res = prefix_regex.search(line)
|
|
|
|
if res:
|
2008-10-18 03:58:22 +08:00
|
|
|
if not res.group(1).startswith('%'):
|
2008-09-08 05:41:53 +08:00
|
|
|
printWarning(pkg, 'hardcoded-prefix-tag', res.group(1))
|
|
|
|
|
|
|
|
res = noarch_regex.search(line)
|
|
|
|
if res:
|
2009-02-26 04:41:51 +08:00
|
|
|
package_noarch[current_package] = True
|
2008-09-08 05:41:53 +08:00
|
|
|
|
|
|
|
res = prereq_regex.search(line)
|
|
|
|
if res:
|
|
|
|
printError(pkg, 'prereq-use', res.group(2))
|
|
|
|
|
|
|
|
res = buildprereq_regex.search(line)
|
|
|
|
if res:
|
|
|
|
printError(pkg, 'buildprereq-use', res.group(1))
|
|
|
|
|
|
|
|
if scriptlet_requires_regex.search(line):
|
2010-02-21 19:28:42 +08:00
|
|
|
printError(pkg, 'broken-syntax-in-scriptlet-requires',
|
|
|
|
line.strip())
|
2006-06-06 02:57:33 +08:00
|
|
|
|
2009-05-20 23:30:55 +08:00
|
|
|
res = requires_regex.search(line)
|
|
|
|
if res:
|
2010-04-17 02:51:00 +08:00
|
|
|
reqs = Pkg.parse_deps(res.group(1))
|
2009-05-20 23:30:55 +08:00
|
|
|
for req in unversioned(reqs):
|
|
|
|
if compop_regex.search(req):
|
|
|
|
printWarning(pkg, 'comparison-operator-in-deptoken',
|
|
|
|
req)
|
|
|
|
|
2007-05-15 06:02:01 +08:00
|
|
|
res = provides_regex.search(line)
|
|
|
|
if res:
|
2010-04-17 02:51:00 +08:00
|
|
|
provs = Pkg.parse_deps(res.group(1))
|
2009-05-20 23:30:55 +08:00
|
|
|
for prov in unversioned(provs):
|
2007-05-15 06:02:01 +08:00
|
|
|
printWarning(pkg, 'unversioned-explicit-provides', prov)
|
2009-05-20 23:30:55 +08:00
|
|
|
if compop_regex.search(prov):
|
|
|
|
printWarning(pkg, 'comparison-operator-in-deptoken',
|
|
|
|
prov)
|
2006-09-04 02:32:13 +08:00
|
|
|
|
2007-05-15 06:02:01 +08:00
|
|
|
res = obsoletes_regex.search(line)
|
|
|
|
if res:
|
2010-04-17 02:51:00 +08:00
|
|
|
obses = Pkg.parse_deps(res.group(1))
|
2009-05-20 23:30:55 +08:00
|
|
|
for obs in unversioned(obses):
|
2007-05-15 06:02:01 +08:00
|
|
|
printWarning(pkg, 'unversioned-explicit-obsoletes', obs)
|
2009-05-20 23:30:55 +08:00
|
|
|
if compop_regex.search(obs):
|
|
|
|
printWarning(pkg, 'comparison-operator-in-deptoken',
|
|
|
|
obs)
|
|
|
|
|
|
|
|
res = conflicts_regex.search(line)
|
|
|
|
if res:
|
2010-04-17 02:51:00 +08:00
|
|
|
confs = Pkg.parse_deps(res.group(1))
|
2009-05-20 23:30:55 +08:00
|
|
|
for conf in unversioned(confs):
|
|
|
|
if compop_regex.search(conf):
|
|
|
|
printWarning(pkg, 'comparison-operator-in-deptoken',
|
|
|
|
conf)
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2008-09-08 05:41:53 +08:00
|
|
|
if current_section == 'changelog':
|
2010-01-20 05:46:51 +08:00
|
|
|
for match in AbstractCheck.macro_regex.findall(line):
|
|
|
|
res = re.match('%+', match)
|
|
|
|
if len(res.group(0)) % 2:
|
|
|
|
printWarning(pkg, 'macro-in-%changelog', match)
|
2008-09-08 05:41:53 +08:00
|
|
|
else:
|
|
|
|
if not depscript_override:
|
2010-02-21 19:28:42 +08:00
|
|
|
depscript_override = \
|
|
|
|
depscript_override_regex.search(line) is not None
|
2008-09-08 05:41:53 +08:00
|
|
|
if not depgen_disabled:
|
2010-02-21 19:28:42 +08:00
|
|
|
depgen_disabled = \
|
|
|
|
depgen_disable_regex.search(line) is not None
|
2008-09-08 05:41:53 +08:00
|
|
|
|
2008-04-30 02:45:03 +08:00
|
|
|
if current_section == 'files':
|
2009-02-26 04:41:51 +08:00
|
|
|
|
2008-04-30 02:45:03 +08:00
|
|
|
if not comment_or_empty_regex.search(line) and not \
|
|
|
|
(ifarch_regex.search(line) or if_regex.search(line) or
|
|
|
|
endif_regex.search(line)):
|
|
|
|
if defattr_regex.search(line):
|
2009-06-17 06:13:20 +08:00
|
|
|
files_has_defattr = True
|
2008-04-30 02:45:03 +08:00
|
|
|
elif not (files_has_defattr or attr_regex.search(line)):
|
2008-06-29 09:20:35 +08:00
|
|
|
printError(pkg, 'files-attr-not-set')
|
2008-04-30 02:45:03 +08:00
|
|
|
|
2009-02-26 04:41:51 +08:00
|
|
|
# TODO: check scriptlets for these too?
|
2010-02-21 19:28:42 +08:00
|
|
|
if package_noarch.get(current_package) or \
|
|
|
|
(current_package not in package_noarch and
|
|
|
|
package_noarch.get(None)):
|
2009-02-26 04:41:51 +08:00
|
|
|
res = libdir_regex.search(line)
|
|
|
|
if res:
|
|
|
|
pkgname = current_package
|
|
|
|
if pkgname is None:
|
|
|
|
pkgname = '(main package)'
|
|
|
|
printWarning(pkg, 'libdir-macro-in-noarch-package',
|
|
|
|
pkgname, line.rstrip())
|
2008-03-25 04:45:35 +08:00
|
|
|
|
2009-09-07 04:11:53 +08:00
|
|
|
if not indent_tabs and '\t' in line:
|
2007-05-15 06:02:01 +08:00
|
|
|
indent_tabs = pkg.current_linenum
|
|
|
|
if not indent_spaces and indent_spaces_regex.search(line):
|
|
|
|
indent_spaces = pkg.current_linenum
|
2009-01-15 03:18:42 +08:00
|
|
|
|
2010-03-14 23:04:09 +08:00
|
|
|
# Check if egrep or fgrep is used
|
|
|
|
if current_section not in \
|
|
|
|
('package', 'changelog', 'description', 'files'):
|
2010-03-14 23:13:32 +08:00
|
|
|
greps = deprecated_grep_regex.findall(line)
|
|
|
|
if greps:
|
|
|
|
printWarning(pkg, "deprecated-grep", greps)
|
2010-03-14 23:04:09 +08:00
|
|
|
|
2009-01-15 03:18:42 +08:00
|
|
|
# If not checking spec file only, we're checking one inside a
|
|
|
|
# SRPM -> skip this check to avoid duplicate warnings (#167)
|
|
|
|
if spec_only and VALID_GROUPS and \
|
|
|
|
line.lower().startswith("group:"):
|
2009-01-13 04:24:23 +08:00
|
|
|
group = line[6:].strip()
|
2009-01-15 03:08:31 +08:00
|
|
|
if group not in VALID_GROUPS:
|
2009-01-13 04:24:23 +08:00
|
|
|
printWarning(pkg, 'non-standard-group', group)
|
2007-05-15 06:02:01 +08:00
|
|
|
|
2010-03-11 04:34:58 +08:00
|
|
|
# Test if there is macro in comment
|
|
|
|
hashPos = line.find("#")
|
|
|
|
if hashPos != -1:
|
|
|
|
for match in AbstractCheck.macro_regex.findall(
|
|
|
|
line[hashPos+1:]):
|
|
|
|
res = re.match('%+', match)
|
|
|
|
if len(res.group(0)) % 2:
|
|
|
|
printWarning(pkg, 'macro-in-comment', match)
|
|
|
|
|
2010-02-01 06:38:44 +08:00
|
|
|
# Last line read is not useful after this point
|
2007-06-07 06:11:02 +08:00
|
|
|
pkg.current_linenum = None
|
|
|
|
|
2009-10-30 02:56:42 +08:00
|
|
|
for sect in (x for x in buildroot_clean if not buildroot_clean[x]):
|
|
|
|
printWarning(pkg, 'no-cleaning-of-buildroot', '%' + sect)
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
if not buildroot:
|
2009-08-04 05:10:49 +08:00
|
|
|
printWarning(pkg, 'no-buildroot-tag')
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
for sec in ('prep', 'build', 'install', 'clean'):
|
2009-01-30 04:15:44 +08:00
|
|
|
if not section.get(sec):
|
2007-05-15 06:02:01 +08:00
|
|
|
printWarning(pkg, 'no-%%%s-section' % sec)
|
|
|
|
for sec in ('changelog',):
|
2009-01-30 04:15:44 +08:00
|
|
|
# prep, build, install, clean, check prevented by rpmbuild 4.4
|
|
|
|
if section.get(sec, 0) > 1:
|
2007-05-15 06:02:01 +08:00
|
|
|
printWarning(pkg, 'more-than-one-%%%s-section' % sec)
|
|
|
|
|
2009-06-17 06:13:20 +08:00
|
|
|
if is_lib_pkg and not mklibname:
|
2007-05-15 06:02:01 +08:00
|
|
|
printError(pkg, 'lib-package-without-%mklibname')
|
|
|
|
|
|
|
|
if depscript_override and not depgen_disabled:
|
|
|
|
printWarning(pkg, 'depscript-without-disabling-depgen')
|
|
|
|
|
|
|
|
if indent_spaces and indent_tabs:
|
2010-02-01 06:38:44 +08:00
|
|
|
pkg.current_linenum = max(indent_spaces, indent_tabs)
|
2007-05-15 06:02:01 +08:00
|
|
|
printWarning(pkg, 'mixed-use-of-spaces-and-tabs',
|
|
|
|
'(spaces: line %d, tab: line %d)' %
|
|
|
|
(indent_spaces, indent_tabs))
|
2010-02-01 06:38:44 +08:00
|
|
|
pkg.current_linenum = None
|
2007-05-15 06:02:01 +08:00
|
|
|
|
|
|
|
# process gathered info
|
2009-01-28 05:44:11 +08:00
|
|
|
for pnum, pfile in patches.items():
|
|
|
|
if pnum in applied_patches_ifarch:
|
|
|
|
printWarning(pkg, "%ifarch-applied-patch", "Patch%d:" % pnum,
|
|
|
|
pfile)
|
|
|
|
if pnum not in applied_patches:
|
|
|
|
printWarning(pkg, "patch-not-applied", "Patch%d:" % pnum,
|
|
|
|
pfile)
|
2000-10-11 14:03:08 +08:00
|
|
|
|
2010-02-01 05:37:48 +08:00
|
|
|
# Rest of the checks require a real spec file
|
|
|
|
if not self._spec_file:
|
|
|
|
return
|
|
|
|
|
2010-01-21 01:48:00 +08:00
|
|
|
# We'd like to parse the specfile only once using python bindings,
|
|
|
|
# but it seems errors from rpmlib get logged to stderr and we can't
|
|
|
|
# capture and print them nicely, so we do it once each way :P
|
|
|
|
|
2009-01-31 02:52:04 +08:00
|
|
|
out = Pkg.getstatusoutput(('env', 'LC_ALL=C', 'rpm', '-q',
|
|
|
|
'--qf=', '--specfile', self._spec_file))
|
2010-01-21 01:48:00 +08:00
|
|
|
parse_error = False
|
2009-01-31 02:52:04 +08:00
|
|
|
for line in out[1].splitlines():
|
2009-02-28 19:08:02 +08:00
|
|
|
# No such file or dir hack: https://bugzilla.redhat.com/487855
|
2009-09-07 04:11:53 +08:00
|
|
|
if 'No such file or directory' not in line:
|
2010-01-21 01:48:00 +08:00
|
|
|
parse_error = True
|
2009-02-28 19:08:02 +08:00
|
|
|
printError(pkg, 'specfile-error', line)
|
2009-01-31 02:52:04 +08:00
|
|
|
|
2010-02-01 05:37:48 +08:00
|
|
|
if not parse_error:
|
2010-01-21 01:48:00 +08:00
|
|
|
# grab sources and patches from parsed spec object to get
|
|
|
|
# them with macros expanded for URL checking
|
|
|
|
|
|
|
|
spec_obj = None
|
|
|
|
try:
|
|
|
|
ts = rpm.TransactionSet()
|
|
|
|
spec_obj = ts.parseSpec(self._spec_file)
|
|
|
|
except:
|
|
|
|
# errors logged above already
|
|
|
|
pass
|
|
|
|
if spec_obj:
|
2010-01-26 07:05:02 +08:00
|
|
|
try:
|
|
|
|
# rpm < 4.8.0
|
|
|
|
sources = spec_obj.sources()
|
|
|
|
except TypeError:
|
|
|
|
# rpm >= 4.8.0
|
|
|
|
sources = spec_obj.sources
|
|
|
|
for src in sources:
|
2010-01-21 01:48:00 +08:00
|
|
|
(url, num, flags) = src
|
2010-01-21 03:31:57 +08:00
|
|
|
(scheme, netloc) = urlparse(url)[0:2]
|
2010-01-21 02:11:41 +08:00
|
|
|
if flags & 1: # rpmspec.h, rpm.org ticket #123
|
|
|
|
srctype = "Source"
|
|
|
|
else:
|
|
|
|
srctype = "Patch"
|
2010-01-21 02:35:54 +08:00
|
|
|
tag = '%s%s' % (srctype, num)
|
2010-01-21 03:31:57 +08:00
|
|
|
if scheme and netloc:
|
2010-01-21 02:35:54 +08:00
|
|
|
self.check_url(pkg, tag, url)
|
2010-01-21 02:17:22 +08:00
|
|
|
elif srctype == "Source" and tarball_regex.search(url):
|
2010-01-21 02:35:54 +08:00
|
|
|
printWarning(pkg, 'invalid-url', '%s:' % tag, url)
|
2009-01-31 02:52:04 +08:00
|
|
|
|
2000-10-11 14:03:08 +08:00
|
|
|
# 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
|
2009-01-31 06:01:50 +08:00
|
|
|
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
|
|
|
|
2010-03-14 23:13:32 +08:00
|
|
|
'deprecated-grep',
|
|
|
|
'''Direct use of grep as egrep or fgrep is deprecated in GNU grep and
|
|
|
|
historical in POSIX, use grep -E and grep -F instead.''',
|
2010-03-14 23:04:09 +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
|
2009-08-04 05:10:49 +08:00
|
|
|
allow building the package as non root on some systems. For some rpm versions
|
|
|
|
(e.g. rpm.org >= 4.6) the BuildRoot tag is not necessary in specfiles and is
|
|
|
|
ignored by rpmbuild; if your package is only going to be built with such rpm
|
|
|
|
versions you can ignore this warning.''',
|
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
|
|
|
|
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
|
2008-02-23 22:15:59 +08:00
|
|
|
options must be augmented with something like --libdir=%{_libdir} whenever
|
|
|
|
the script supports it.''',
|
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
|
|
|
|
2008-10-30 05:42:47 +08:00
|
|
|
'setup-not-in-prep',
|
|
|
|
'''The %setup macro should only be used within the %prep section because it may
|
|
|
|
not expand to anything outside of it and can break the build in unpredictable
|
|
|
|
ways.''',
|
|
|
|
|
2006-05-13 00:28:02 +08:00
|
|
|
'setup-not-quiet',
|
2007-02-06 05:26:31 +08:00
|
|
|
'''Use the -q option to the %setup macro to avoid useless build output from
|
|
|
|
unpacking the sources.''',
|
2006-05-13 00:28:02 +08:00
|
|
|
|
2006-05-13 17:16:20 +08:00
|
|
|
'no-cleaning-of-buildroot',
|
2009-08-04 05:10:49 +08:00
|
|
|
'''You should clean $RPM_BUILD_ROOT in the %clean section and in the beginning
|
|
|
|
of the %install section. Use "rm -rf $RPM_BUILD_ROOT". Some rpm configurations
|
|
|
|
do this automatically; if your package is only going to be built in such
|
|
|
|
configurations, you can ignore this warning for the section(s) where your rpm
|
|
|
|
takes care of it.''',
|
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
|
2009-08-04 05:07:54 +08:00
|
|
|
may break short circuit builds.''',
|
2006-05-13 17:20:36 +08:00
|
|
|
|
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.''',
|
2008-03-22 07:51:05 +08:00
|
|
|
|
2008-03-25 04:45:35 +08:00
|
|
|
'libdir-macro-in-noarch-package',
|
|
|
|
'''The %{_libdir} or %{_lib} macro was found in a noarch package in a section
|
|
|
|
that gets included in binary packages. This is most likely an error because
|
|
|
|
these macros are expanded on the build host and their values vary between
|
|
|
|
architectures, probably resulting in a package that does not work properly
|
|
|
|
on all architectures at runtime. Investigate whether the package is really
|
|
|
|
architecture independent or if some other dir/macro should be instead.''',
|
|
|
|
|
2008-03-22 07:51:05 +08:00
|
|
|
'non-break-space',
|
2008-03-25 05:13:24 +08:00
|
|
|
'''The spec file contains a non-break space, which looks like a regular space
|
|
|
|
in some editors but can lead to obscure errors. It should be replaced by a
|
|
|
|
regular space.''',
|
2008-04-30 02:45:03 +08:00
|
|
|
|
|
|
|
'files-attr-not-set',
|
|
|
|
'''A file or a directory entry in a %files section does not have attributes
|
|
|
|
set which may result in security issues in the resulting binary package
|
|
|
|
depending on the system where the package is built. Add default attributes
|
|
|
|
using %defattr before it in the %files section, or use per line %attr's.''',
|
2009-01-13 04:24:23 +08:00
|
|
|
|
|
|
|
'non-standard-group',
|
|
|
|
'''The value of the Group tag in the package is not valid. Valid groups are:
|
|
|
|
"%s".''' % '", "'.join(VALID_GROUPS),
|
2009-01-31 02:52:04 +08:00
|
|
|
|
|
|
|
'specfile-error',
|
|
|
|
'''This error occurred when rpmlint used rpm to query the specfile. The error
|
|
|
|
is output by rpm and the message should contain more information.''',
|
2009-05-20 23:30:55 +08:00
|
|
|
|
|
|
|
'comparison-operator-in-deptoken',
|
|
|
|
'''This dependency token contains a comparison operator (<, > or =). This is
|
|
|
|
usually not intended and may be caused by missing whitespace between the token's
|
|
|
|
name, the comparison operator and the version string.''',
|
2010-03-11 04:34:58 +08:00
|
|
|
|
|
|
|
'macro-in-comment',
|
|
|
|
'''There is a unescaped macro after a shell style comment in the specfile.
|
|
|
|
Macros are expanded everywhere, so check if it can cause a problem in this
|
|
|
|
case and escape the macro with another leading % if appropriate.''',
|
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
|