Wrap bunch of long lines, tune comments and info messages.

git-svn-id: svn+ssh://rpmlint.zarb.org/home/projects/rpmlint/svn/trunk@1732 9bc8b190-ac0f-0410-8968-dc7d1f502856
This commit is contained in:
Ville Skyttä 2010-02-21 11:28:42 +00:00
parent a8f20c1d06
commit 8a514dd9aa
17 changed files with 281 additions and 136 deletions

View File

@ -213,7 +213,8 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
if not stat.S_ISDIR(pkgfile.mode) and usr_lib_regex.search(fname): if not stat.S_ISDIR(pkgfile.mode) and usr_lib_regex.search(fname):
has_usr_lib_file = True has_usr_lib_file = True
if not binary_in_usr_lib and usr_lib_exception_regex.search(fname): if not binary_in_usr_lib and \
usr_lib_exception_regex.search(fname):
# Fake that we have binaries there to avoid # Fake that we have binaries there to avoid
# only-non-binary-in-usr-lib false positives # only-non-binary-in-usr-lib false positives
binary_in_usr_lib = True binary_in_usr_lib = True
@ -226,11 +227,15 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
if is_binary: if is_binary:
binary = True binary = True
if has_usr_lib_file and not binary_in_usr_lib and usr_lib_regex.search(fname): if has_usr_lib_file and not binary_in_usr_lib and \
usr_lib_regex.search(fname):
binary_in_usr_lib = True binary_in_usr_lib = True
if pkg.arch == 'noarch': if pkg.arch == 'noarch':
printError(pkg, 'arch-independent-package-contains-binary-or-object', fname) printError(
pkg,
'arch-independent-package-contains-binary-or-object',
fname)
else: else:
# in /usr/share ? # in /usr/share ?
if fname.startswith('/usr/share/'): if fname.startswith('/usr/share/'):
@ -271,7 +276,9 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
symlink = directory + bin_info.soname symlink = directory + bin_info.soname
link = files[symlink].linkto link = files[symlink].linkto
if link not in (fname, base, ''): if link not in (fname, base, ''):
printError(pkg, 'invalid-ldconfig-symlink', fname, link) printError(
pkg, 'invalid-ldconfig-symlink',
fname, link)
except KeyError: except KeyError:
printError( printError(
pkg, 'no-ldconfig-symlink', fname) pkg, 'no-ldconfig-symlink', fname)
@ -292,7 +299,9 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
for p in bin_info.rpath: for p in bin_info.rpath:
if p in system_lib_paths or \ if p in system_lib_paths or \
not usr_lib_regex.search(p): not usr_lib_regex.search(p):
printError(pkg, 'binary-or-shlib-defines-rpath', fname, bin_info.rpath) printError(pkg,
'binary-or-shlib-defines-rpath',
fname, bin_info.rpath)
break break
# shared lib calls exit() or _exit()? # shared lib calls exit() or _exit()?
@ -320,34 +329,46 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
not (bin_info.soname and \ not (bin_info.soname and \
ldso_soname_regex.search(bin_info.soname)): ldso_soname_regex.search(bin_info.soname)):
if shared_object_regex.search(pkgfile.magic): if shared_object_regex.search(pkgfile.magic):
printError(pkg, 'shared-lib-without-dependency-information', fname) printError(pkg,
'shared-lib-without-dependency-information',
fname)
else: else:
printError(pkg, 'statically-linked-binary', fname) printError(pkg, 'statically-linked-binary', fname)
else: else:
# linked against libc ? # linked against libc ?
if not libc_regex.search(fname) and \ if not libc_regex.search(fname) and \
( not bin_info.soname or \ (not bin_info.soname or
( not libc_regex.search(bin_info.soname) and \ (not libc_regex.search(bin_info.soname) and
not ldso_soname_regex.search(bin_info.soname))): not ldso_soname_regex.search(
bin_info.soname))):
found_libc = False found_libc = False
for lib in bin_info.needed: for lib in bin_info.needed:
if libc_regex.search(lib): if libc_regex.search(lib):
found_libc = True found_libc = True
break break
if not found_libc: if not found_libc:
if shared_object_regex.search(pkgfile.magic): if shared_object_regex.search(
printError(pkg, 'library-not-linked-against-libc', fname) pkgfile.magic):
printError(pkg,
'library-not-linked-against-libc',
fname)
else: else:
printError(pkg, 'program-not-linked-against-libc', fname) printError(pkg,
'program-not-linked-against-libc',
fname)
# It could be useful to check these for others than # It could be useful to check these for others than
# shared libs only, but that has potential to # shared libs only, but that has potential to
# generate lots of false positives and noise. # generate lots of false positives and noise.
if is_shlib: if is_shlib:
for s in bin_info.undef: for s in bin_info.undef:
printWarning(pkg, 'undefined-non-weak-symbol', fname, s) printWarning(pkg,
'undefined-non-weak-symbol',
fname, s)
for s in bin_info.unused: for s in bin_info.unused:
printWarning(pkg, 'unused-direct-shlib-dependency', fname, s) printWarning(
pkg, 'unused-direct-shlib-dependency',
fname, s)
if bin_info.stack: if bin_info.stack:
if bin_info.exec_stack: if bin_info.exec_stack:
@ -356,7 +377,8 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
pkg.arch.endswith("86") or pkg.arch.endswith("86") or
pkg.arch.startswith("pentium") or pkg.arch.startswith("pentium") or
pkg.arch in ("athlon", "x86_64")): pkg.arch in ("athlon", "x86_64")):
printError(pkg, 'missing-PT_GNU_STACK-section', fname) printError(pkg, 'missing-PT_GNU_STACK-section',
fname)
else: else:
if reference_regex.search(fname): if reference_regex.search(fname):
@ -371,7 +393,8 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
for f in files: for f in files:
res = numeric_dir_regex.search(f) res = numeric_dir_regex.search(f)
fn = res and res.group(1) or f fn = res and res.group(1) or f
if f not in exec_files and not so_regex.search(f) and not versioned_dir_regex.search(fn): if f not in exec_files and not so_regex.search(f) and \
not versioned_dir_regex.search(fn):
printError(pkg, 'non-versioned-file-in-library-package', f) printError(pkg, 'non-versioned-file-in-library-package', f)
if version and version != -1 and version not in pkg.name: if version and version != -1 and version not in pkg.name:
printError(pkg, 'incoherent-version-in-name', version) printError(pkg, 'incoherent-version-in-name', version)
@ -474,7 +497,8 @@ indicate gratuitously bloated linkage; check that the binary has been linked
with the intended shared libraries only.''', with the intended shared libraries only.''',
'only-non-binary-in-usr-lib', 'only-non-binary-in-usr-lib',
'''There are only non binary files in /usr/lib so they should be in /usr/share.''', '''There are only non binary files in /usr/lib so they should be in
/usr/share.''',
'binaryinfo-readelf-failed', 'binaryinfo-readelf-failed',
'''Executing readelf on this file failed, all checks could not be run.''', '''Executing readelf on this file failed, all checks could not be run.''',

View File

@ -155,8 +155,9 @@ def isFiltered(s):
_filters_re = '(?:' + _filters[0] + ')' _filters_re = '(?:' + _filters[0] + ')'
for idx in range(1, len(_filters)): for idx in range(1, len(_filters)):
# to prevent named group overflow that happen when there is too many () in a single regexp # to prevent named group overflow that happen when there is too
# AssertionError: sorry, but this version only supports 100 named groups # many () in a single regexp: AssertionError: sorry, but this
# version only supports 100 named groups
if '(' in _filters[idx]: if '(' in _filters[idx]:
_non_named_group_re.subn('(:?', _filters[idx]) _non_named_group_re.subn('(:?', _filters[idx])
_filters_re = _filters_re + '|(?:' + _filters[idx] +')' _filters_re = _filters_re + '|(?:' + _filters[idx] +')'

View File

@ -38,7 +38,8 @@ class DistributionCheck(AbstractCheck.AbstractCheck):
printWarning(pkg, "invalid-vendor", pkg[rpm.RPMTAG_VENDOR]) printWarning(pkg, "invalid-vendor", pkg[rpm.RPMTAG_VENDOR])
if distribution and pkg[rpm.RPMTAG_DISTRIBUTION] != distribution: if distribution and pkg[rpm.RPMTAG_DISTRIBUTION] != distribution:
printWarning(pkg, "invalid-distribution", pkg[rpm.RPMTAG_DISTRIBUTION]) printWarning(pkg, "invalid-distribution",
pkg[rpm.RPMTAG_DISTRIBUTION])
if compress_ext: if compress_ext:
for fname in pkg.files(): for fname in pkg.files():
@ -58,7 +59,7 @@ check = DistributionCheck()
addDetails( addDetails(
'invalid-vendor', 'invalid-vendor',
'In the ' + distribution + ' distribution, the vendor should be "' + vendor + '".', '''In the "%s" distribution, vendor should be "%s".''' % (distribution, vendor),
'invalid-distribution', 'invalid-distribution',
'The distribution value should be "' + distribution + '".', 'The distribution value should be "' + distribution + '".',

View File

@ -388,7 +388,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
if standard_groups and group not in standard_groups: if standard_groups and group not in standard_groups:
printWarning(pkg, 'non-standard-gid', f, group) printWarning(pkg, 'non-standard-gid', f, group)
if not module_rpms_ok and kernel_modules_regex.search(f) and not is_kernel_package: if not module_rpms_ok and kernel_modules_regex.search(f) and not \
is_kernel_package:
printError(pkg, "kernel-modules-not-in-kernel-packages", f) printError(pkg, "kernel-modules-not-in-kernel-packages", f)
if tmp_regex.search(f): if tmp_regex.search(f):
@ -431,7 +432,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
ext = compr_regex.search(link) ext = compr_regex.search(link)
if ext: if ext:
if not re.compile('\.' + ext.group(1) + '$').search(f): if not re.compile('\.' + ext.group(1) + '$').search(f):
printError(pkg, 'compressed-symlink-with-wrong-ext', f, link) printError(pkg, 'compressed-symlink-with-wrong-ext',
f, link)
perm = mode & 07777 perm = mode & 07777
@ -449,10 +451,14 @@ class FilesCheck(AbstractCheck.AbstractCheck):
printError(pkg, 'setuid-binary', f, setuid, oct(perm)) printError(pkg, 'setuid-binary', f, setuid, oct(perm))
if setgid: if setgid:
if not (group == 'games' and if not (group == 'games' and
(games_path_regex.search(f) or games_group_regex.search(pkg[rpm.RPMTAG_GROUP]))): (games_path_regex.search(f) or
printError(pkg, 'setgid-binary', f, setgid, oct(perm)) games_group_regex.search(
pkg[rpm.RPMTAG_GROUP]))):
printError(pkg, 'setgid-binary', f, setgid,
oct(perm))
if mode & 0777 != 0755: if mode & 0777 != 0755:
printError(pkg, 'non-standard-executable-perm', f, oct(perm)) printError(pkg, 'non-standard-executable-perm', f,
oct(perm))
if log_regex.search(f): if log_regex.search(f):
log_file = f log_file = f
@ -536,15 +542,18 @@ class FilesCheck(AbstractCheck.AbstractCheck):
# check install-info call in %post and %postun # check install-info call in %post and %postun
if f.startswith('/usr/share/info/'): if f.startswith('/usr/share/info/'):
if not postin: if not postin:
printError(pkg, 'info-files-without-install-info-postin', f) printError(pkg,
'info-files-without-install-info-postin', f)
else: else:
if not install_info_regex.search(postin): if not install_info_regex.search(postin):
printError(pkg, 'postin-without-install-info', f) printError(pkg, 'postin-without-install-info', f)
if not postun and not preun: if not postun and not preun:
printError(pkg, 'info-files-without-install-info-postun', f) printError(pkg,
'info-files-without-install-info-postun', f)
else: else:
if (not postun or not install_info_regex.search(postun)) and \ if (not postun or
not install_info_regex.search(postun)) and \
(not preun or not install_info_regex.search(preun)): (not preun or not install_info_regex.search(preun)):
printError(pkg, 'postin-without-install-info', f) printError(pkg, 'postin-without-install-info', f)
@ -574,7 +583,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
break break
if not ok_nonreadable: if not ok_nonreadable:
printError(pkg, 'non-readable', f, oct(perm)) printError(pkg, 'non-readable', f, oct(perm))
if size == 0 and not normal_zero_length_regex.search(f) and f not in ghost_files: if size == 0 and not normal_zero_length_regex.search(f) and \
f not in ghost_files:
printError(pkg, 'zero-length', f) printError(pkg, 'zero-length', f)
if mode & 0002 != 0: if mode & 0002 != 0:
@ -589,15 +599,19 @@ class FilesCheck(AbstractCheck.AbstractCheck):
vers = res.group(1) + res.group(2) vers = res.group(1) + res.group(2)
if not (pkg.check_versioned_dep('perl-base', vers) or if not (pkg.check_versioned_dep('perl-base', vers) or
pkg.check_versioned_dep('perl', vers)): pkg.check_versioned_dep('perl', vers)):
printError(pkg, 'no-dependency-on', 'perl-base', vers) printError(pkg, 'no-dependency-on',
'perl-base', vers)
perl_dep_error = True perl_dep_error = True
if not python_dep_error: if not python_dep_error:
res = python_regex.search(f) res = python_regex.search(f)
if res: if res:
if not (pkg.check_versioned_dep('python-base', res.group(1)) or if not (pkg.check_versioned_dep('python-base',
pkg.check_versioned_dep('python', res.group(1))): res.group(1)) or
printError(pkg, 'no-dependency-on', 'python-base', res.group(1)) pkg.check_versioned_dep('python',
res.group(1))):
printError(pkg, 'no-dependency-on', 'python-base',
res.group(1))
python_dep_error = True python_dep_error = True
res = python_bytecode_regex.search(f) res = python_bytecode_regex.search(f)
@ -649,7 +663,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
# normal executable check # normal executable check
if mode & stat.S_IXUSR and perm != 0755: if mode & stat.S_IXUSR and perm != 0755:
printError(pkg, 'non-standard-executable-perm', f, oct(perm)) printError(pkg, 'non-standard-executable-perm',
f, oct(perm))
if mode & 0111 != 0: if mode & 0111 != 0:
if f in config_files: if f in config_files:
printError(pkg, 'executable-marked-as-config-file', f) printError(pkg, 'executable-marked-as-config-file', f)
@ -698,7 +713,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
# absolute link # absolute link
r = absolute_regex.search(link) r = absolute_regex.search(link)
if r: if r:
if not is_so and link not in files and link not in req_names: if not is_so and link not in files and \
link not in req_names:
is_exception = False is_exception = False
for e in dangling_exceptions: for e in dangling_exceptions:
if e[0].search(link): if e[0].search(link):
@ -706,7 +722,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
break break
if is_exception: if is_exception:
if is_exception not in req_names: if is_exception not in req_names:
printWarning(pkg, 'no-dependency-on', is_exception) printWarning(pkg, 'no-dependency-on',
is_exception)
else: else:
printWarning(pkg, 'dangling-symlink', f, link) printWarning(pkg, 'dangling-symlink', f, link)
linktop = r.group(1) linktop = r.group(1)
@ -714,7 +731,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
if r: if r:
filetop = r.group(1) filetop = r.group(1)
if filetop == linktop or use_relative_symlinks: if filetop == linktop or use_relative_symlinks:
printWarning(pkg, 'symlink-should-be-relative', f, link) printWarning(pkg, 'symlink-should-be-relative',
f, link)
# relative link # relative link
else: else:
if not is_so: if not is_so:
@ -728,9 +746,11 @@ class FilesCheck(AbstractCheck.AbstractCheck):
break break
if is_exception: if is_exception:
if is_exception not in req_names: if is_exception not in req_names:
printWarning(pkg, 'no-dependency-on', is_exception) printWarning(pkg, 'no-dependency-on',
is_exception)
else: else:
printWarning(pkg, 'dangling-relative-symlink', f, link) printWarning(pkg, 'dangling-relative-symlink',
f, link)
pathcomponents = f.split('/')[1:] pathcomponents = f.split('/')[1:]
r = points_regex.search(link) r = points_regex.search(link)
lastpop = None lastpop = None
@ -739,7 +759,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
while r: while r:
mylink = r.group(1) mylink = r.group(1)
if len(pathcomponents) == 0: if len(pathcomponents) == 0:
printError(pkg, 'symlink-has-too-many-up-segments', f, link) printError(pkg, 'symlink-has-too-many-up-segments',
f, link)
break break
else: else:
lastpop = pathcomponents[0] lastpop = pathcomponents[0]
@ -750,7 +771,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
r = absolute2_regex.search(mylink) r = absolute2_regex.search(mylink)
linktop = r.group(1) linktop = r.group(1)
# does the link go up and then down into the same directory? # does the link go up and then down into the same
# directory?
#if linktop == lastpop: #if linktop == lastpop:
# printWarning(pkg, 'lengthy-symlink', f, link) # printWarning(pkg, 'lengthy-symlink', f, link)
@ -758,11 +780,16 @@ class FilesCheck(AbstractCheck.AbstractCheck):
# we've reached the root directory # we've reached the root directory
if linktop != lastpop and not use_relative_symlinks: if linktop != lastpop and not use_relative_symlinks:
# relative link into other toplevel directory # relative link into other toplevel directory
printWarning(pkg, 'symlink-should-be-absolute', f, link) printWarning(pkg, 'symlink-should-be-absolute',
# check additional segments for mistakes like `foo/../bar/' f, link)
# check additional segments for mistakes like
# `foo/../bar/'
for linksegment in mylink.split('/'): for linksegment in mylink.split('/'):
if linksegment == '..': if linksegment == '..':
printError(pkg, 'symlink-contains-up-and-down-segments', f, link) printError(
pkg,
'symlink-contains-up-and-down-segments',
f, link)
# check text file # check text file
if stat.S_ISREG(mode): if stat.S_ISREG(mode):
@ -781,26 +808,34 @@ class FilesCheck(AbstractCheck.AbstractCheck):
# sourced scripts should not be executable # sourced scripts should not be executable
if sourced_script_regex.search(f): if sourced_script_regex.search(f):
if res: if res:
printError(pkg, 'sourced-script-with-shebang', f) printError(pkg,
'sourced-script-with-shebang', f)
if mode & 0111 != 0: if mode & 0111 != 0:
printError(pkg, 'executable-sourced-script', f, oct(perm)) printError(pkg, 'executable-sourced-script',
f, oct(perm))
# ...but executed ones should # ...but executed ones should
elif res or mode & 0111 != 0 or script_regex.search(f): elif res or mode & 0111 != 0 or script_regex.search(f):
interpreter = None interpreter = None
if res: if res:
interpreter = res.group(1) interpreter = res.group(1)
if not interpreter_regex.search(interpreter): if not interpreter_regex.search(interpreter):
printError(pkg, 'wrong-script-interpreter', f, interpreter) printError(pkg, 'wrong-script-interpreter',
elif not nonexec_file and not (lib_path_regex.search(f) and f.endswith('.la')): f, interpreter)
elif not nonexec_file and not \
(lib_path_regex.search(f) and
f.endswith('.la')):
printError(pkg, 'script-without-shebang', f) printError(pkg, 'script-without-shebang', f)
if mode & 0111 == 0 and not is_doc: if mode & 0111 == 0 and not is_doc:
printError(pkg, 'non-executable-script', f, oct(perm), interpreter) printError(pkg, 'non-executable-script', f,
oct(perm), interpreter)
if line.endswith('\r\n') or line.endswith('\r'): if line.endswith('\r\n') or line.endswith('\r'):
printError(pkg, 'wrong-script-end-of-line-encoding', f) printError(
pkg, 'wrong-script-end-of-line-encoding', f)
elif is_doc and not skipdocs_regex.search(f): elif is_doc and not skipdocs_regex.search(f):
if line.endswith('\r\n') or line.endswith('\r'): if line.endswith('\r\n') or line.endswith('\r'):
printWarning(pkg, 'wrong-file-end-of-line-encoding', f) printWarning(
pkg, 'wrong-file-end-of-line-encoding', f)
# We check only doc text files for UTF-8-ness; # We check only doc text files for UTF-8-ness;
# checking everything may be slow and can generate # checking everything may be slow and can generate
# lots of unwanted noise. # lots of unwanted noise.
@ -861,7 +896,8 @@ Standard groups are:
a call to ldconfig.''', a call to ldconfig.''',
'postin-without-ldconfig', 'postin-without-ldconfig',
'''This package contains a library and its %post scriptlet doesn't call ldconfig.''', '''This package contains a library and its %post scriptlet doesn't call
ldconfig.''',
'library-without-ldconfig-postun', 'library-without-ldconfig-postun',
'''This package contains a library and provides no %postun scriptlet containing '''This package contains a library and provides no %postun scriptlet containing
@ -882,7 +918,8 @@ a call to install-info.''',
a call to install-info.''', a call to install-info.''',
'postun-without-install-info', 'postun-without-install-info',
'''This package contains info files and its %postun doesn't call install-info.''', '''This package contains info files and its %postun doesn't call
install-info.''',
'perl-temp-file', 'perl-temp-file',
'''You have a perl temporary file in your package. Usually, this '''You have a perl temporary file in your package. Usually, this
@ -941,7 +978,8 @@ a configuration file. All non-executable files in /etc should be configuration
files. Mark the file as %config in the spec file.''', files. Mark the file as %config in the spec file.''',
'compressed-symlink-with-wrong-ext', 'compressed-symlink-with-wrong-ext',
'''The symlink points to a compressed file but doesn't use the same extension.''', '''The symlink points to a compressed file but doesn't use the same
extension.''',
'setuid-binary', 'setuid-binary',
'''The file is setuid, this may be dangerous, especially if this '''The file is setuid, this may be dangerous, especially if this
@ -1087,7 +1125,8 @@ customize an executable, make it for example read a config file in
/etc/sysconfig.''', /etc/sysconfig.''',
'sourced-script-with-shebang', 'sourced-script-with-shebang',
'''This text file contains a shebang, but is meant to be sourced, not executed.''', '''This text file contains a shebang, but is meant to be sourced, not
executed.''',
'executable-sourced-script', 'executable-sourced-script',
'''This text file has executable bit set, but is meant to be sourced, not '''This text file has executable bit set, but is meant to be sourced, not
@ -1122,7 +1161,8 @@ correctly in some circumstances.''',
in the specfile's %prep section for example using iconv(1).''', in the specfile's %prep section for example using iconv(1).''',
'filename-not-utf8', 'filename-not-utf8',
'''The character encoding of the name of this file is not UTF-8. Rename it.''', '''The character encoding of the name of this file is not UTF-8.
Rename it.''',
'file-in-meta-package', 'file-in-meta-package',
'''This package seems to be a meta-package (an empty package used to require '''This package seems to be a meta-package (an empty package used to require

View File

@ -111,7 +111,8 @@ class I18NCheck(AbstractCheck.AbstractCheck):
# others in /usr/share or /usr/lib, the only reliable way # others in /usr/share or /usr/lib, the only reliable way
# sofar to detect them is to look for an apache configuration file # sofar to detect them is to look for an apache configuration file
for f in files: for f in files:
if f.startswith('/etc/apache2/') or f.startswith('/etc/httpd/conf.d/'): if f.startswith('/etc/apache2/') or \
f.startswith('/etc/httpd/conf.d/'):
webapp = True webapp = True
for f in files: for f in files:
@ -204,7 +205,8 @@ addDetails(
""", """,
'subfile-not-in-%lang', 'subfile-not-in-%lang',
""" If /foo/bar is not tagged %lang(XX) whereas /foo is, the package won't be installable if XX is not in %_install_langs""", """ If /foo/bar is not tagged %lang(XX) whereas /foo is, the package won't be
installable if XX is not in %_install_langs.""",
) )

View File

@ -60,14 +60,16 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
# check chkconfig call in %post and %preun # check chkconfig call in %post and %preun
postin = pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG] postin = pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
if not postin: if not postin:
printError(pkg, 'init-script-without-chkconfig-postin', fname) printError(pkg,
'init-script-without-chkconfig-postin', fname)
else: else:
if not chkconfig_regex.search(postin): if not chkconfig_regex.search(postin):
printError(pkg, 'postin-without-chkconfig', fname) printError(pkg, 'postin-without-chkconfig', fname)
preun = pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG] preun = pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG]
if not preun: if not preun:
printError(pkg, 'init-script-without-chkconfig-preun', fname) printError(pkg,
'init-script-without-chkconfig-preun', fname)
else: else:
if not chkconfig_regex.search(preun): if not chkconfig_regex.search(preun):
printError(pkg, 'preun-without-chkconfig', fname) printError(pkg, 'preun-without-chkconfig', fname)
@ -115,9 +117,12 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
cres = lsb_cont_regex.search(line) cres = lsb_cont_regex.search(line)
if not (in_lsb_description and cres): if not (in_lsb_description and cres):
in_lsb_description = False in_lsb_description = False
printError(pkg, 'malformed-line-in-lsb-comment-block', line) printError(pkg,
'malformed-line-in-lsb-comment-block',
line)
else: else:
lsb_tags["Description"][-1] += " " + cres.group(1) lsb_tags["Description"][-1] += \
" " + cres.group(1)
else: else:
tag = res.group(1) tag = res.group(1)
if not tag.startswith('X-') and \ if not tag.startswith('X-') and \
@ -146,7 +151,8 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
printWarning(pkg, 'no-default-runlevel', fname) printWarning(pkg, 'no-default-runlevel', fname)
else: else:
if res.group(1) != '-': if res.group(1) != '-':
printWarning(pkg, 'service-default-enabled', fname) printWarning(pkg,
'service-default-enabled', fname)
res = subsys_regex.search(line) res = subsys_regex.search(line)
if res: if res:
@ -155,7 +161,8 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
if name != basename: if name != basename:
error = True error = True
if name[0] == '$': if name[0] == '$':
value = Pkg.substitute_shell_vars(name, content_str) value = Pkg.substitute_shell_vars(
name, content_str)
if value == basename: if value == basename:
error = False error = False
else: else:
@ -165,9 +172,11 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
error = name != basename error = name != basename
if error and len(name): if error and len(name):
if name[0] == '$': if name[0] == '$':
printWarning(pkg, 'incoherent-subsys', fname, name) printWarning(pkg, 'incoherent-subsys',
fname, name)
else: else:
printError(pkg, 'incoherent-subsys', fname, name) printError(pkg, 'incoherent-subsys',
fname, name)
if "Default-Start" in lsb_tags: if "Default-Start" in lsb_tags:
if "".join(lsb_tags["Default-Start"]): if "".join(lsb_tags["Default-Start"]):
@ -197,14 +206,16 @@ addDetails(
a call to chkconfig.''', a call to chkconfig.''',
'postin-without-chkconfig', 'postin-without-chkconfig',
'''The package contains an init script but doesn't call chkconfig in its %post.''', '''The package contains an init script but doesn't call chkconfig in its
%post script.''',
'init-script-without-chkconfig-preun', 'init-script-without-chkconfig-preun',
'''The package contains an init script but doesn't contain a %preun with '''The package contains an init script but doesn't contain a %preun with
a call to chkconfig.''', a call to chkconfig.''',
'preun-without-chkconfig', 'preun-without-chkconfig',
'''The package contains an init script but doesn't call chkconfig in its %preun.''', '''The package contains an init script but doesn't call chkconfig in its
%preun script.''',
'missing-lsb-keyword', 'missing-lsb-keyword',
'''The package contains an init script that does not contain one of the LSB '''The package contains an init script that does not contain one of the LSB

View File

@ -225,7 +225,9 @@ class MenuCheck(AbstractCheck.AbstractCheck):
if res: if res:
package = res.group(1) package = res.group(1)
if package != pkg.name: if package != pkg.name:
printWarning(pkg, 'incoherent-package-value-in-menu', package, f) printWarning(pkg,
'incoherent-package-value-in-menu',
package, f)
else: else:
printInfo(pkg, 'unable-to-parse-menu-entry', line) printInfo(pkg, 'unable-to-parse-menu-entry', line)
@ -239,8 +241,9 @@ class MenuCheck(AbstractCheck.AbstractCheck):
found = False found = False
if launcher[1]: if launcher[1]:
if ('/bin/' + command_line[0] in files or if ('/bin/' + command_line[0] in files or
'/usr/bin/' + command_line[0] in files or '/usr/bin/' + command_line[0] in files
'/usr/X11R6/bin/' + command_line[0] in files): or '/usr/X11R6/bin/' + command_line[0]
in files):
found = True found = True
else: else:
for l in launcher[1]: for l in launcher[1]:
@ -248,17 +251,21 @@ class MenuCheck(AbstractCheck.AbstractCheck):
found = True found = True
break break
if not found: if not found:
printError(pkg, 'use-of-launcher-in-menu-but-no-requires-on', launcher[1][0]) printError(pkg,
'use-of-launcher-in-menu-but-no-requires-on',
launcher[1][0])
command = command_line[1] command = command_line[1]
break break
if command[0] == '/': if command[0] == '/':
if command not in files: if command not in files:
printWarning(pkg, 'menu-command-not-in-package', command) printWarning(pkg, 'menu-command-not-in-package',
command)
else: else:
if not ('/bin/' + command in files or if not ('/bin/' + command in files or
'/usr/bin/' + command in files or '/usr/bin/' + command in files or
'/usr/X11R6/bin/' + command in files): '/usr/X11R6/bin/' + command in files):
printWarning(pkg, 'menu-command-not-in-package', command) printWarning(pkg, 'menu-command-not-in-package',
command)
else: else:
printWarning(pkg, 'missing-menu-command') printWarning(pkg, 'missing-menu-command')
command = False command = False
@ -268,10 +275,12 @@ class MenuCheck(AbstractCheck.AbstractCheck):
grp = res.groups() grp = res.groups()
title = grp[1] or grp[2] title = grp[1] or grp[2]
if title[0] != title[0].upper(): if title[0] != title[0].upper():
printWarning(pkg, 'menu-longtitle-not-capitalized', title) printWarning(pkg, 'menu-longtitle-not-capitalized',
title)
res = version_regex.search(title) res = version_regex.search(title)
if res: if res:
printWarning(pkg, 'version-in-menu-longtitle', title) printWarning(pkg, 'version-in-menu-longtitle',
title)
else: else:
printError(pkg, 'no-longtitle-in-menu', f) printError(pkg, 'no-longtitle-in-menu', f)
title = None title = None
@ -281,7 +290,8 @@ class MenuCheck(AbstractCheck.AbstractCheck):
grp = res.groups() grp = res.groups()
title = grp[1] or grp[2] title = grp[1] or grp[2]
if title[0] != title[0].upper(): if title[0] != title[0].upper():
printWarning(pkg, 'menu-title-not-capitalized', title) printWarning(pkg, 'menu-title-not-capitalized',
title)
res = version_regex.search(title) res = version_regex.search(title)
if res: if res:
printWarning(pkg, 'version-in-menu-title', title) printWarning(pkg, 'version-in-menu-title', title)
@ -303,9 +313,11 @@ class MenuCheck(AbstractCheck.AbstractCheck):
# don't warn entries for sections # don't warn entries for sections
if command: if command:
if section not in valid_sections: if section not in valid_sections:
printError(pkg, 'invalid-menu-section', section, f) printError(pkg, 'invalid-menu-section',
section, f)
else: else:
printInfo(pkg, 'unable-to-parse-menu-section', line) printInfo(pkg, 'unable-to-parse-menu-section',
line)
elif needs not in standard_needs: elif needs not in standard_needs:
printInfo(pkg, 'strange-needs', needs, f) printInfo(pkg, 'strange-needs', needs, f)
else: else:
@ -317,11 +329,14 @@ class MenuCheck(AbstractCheck.AbstractCheck):
if not icon_ext_regex.search(icon): if not icon_ext_regex.search(icon):
printWarning(pkg, 'invalid-menu-icon-type', icon) printWarning(pkg, 'invalid-menu-icon-type', icon)
if icon[0] == '/' and needs == 'x11': if icon[0] == '/' and needs == 'x11':
printWarning(pkg, 'hardcoded-path-in-menu-icon', icon) printWarning(pkg, 'hardcoded-path-in-menu-icon',
icon)
else: else:
for path in icon_paths: for path in icon_paths:
if (path[0] + icon) not in files: if (path[0] + icon) not in files:
printError(pkg, path[1] + '-icon-not-in-package', icon, f) printError(pkg,
path[1] + '-icon-not-in-package',
icon, f)
else: else:
printWarning(pkg, 'no-icon-in-menu', title) printWarning(pkg, 'no-icon-in-menu', title)

View File

@ -17,7 +17,8 @@ class MenuXDGCheck(AbstractCheck.AbstractFilesCheck):
# desktop file need to be in $XDG_DATA_DIRS # desktop file need to be in $XDG_DATA_DIRS
# $ echo $XDG_DATA_DIRS/applications # $ echo $XDG_DATA_DIRS/applications
# /var/lib/menu-xdg:/usr/share # /var/lib/menu-xdg:/usr/share
AbstractCheck.AbstractFilesCheck.__init__(self, "MenuXDGCheck", "/usr/share/applications/.*\.desktop$") AbstractCheck.AbstractFilesCheck.__init__(
self, "MenuXDGCheck", "/usr/share/applications/.*\.desktop$")
def check_file(self, pkg, filename): def check_file(self, pkg, filename):
f = pkg.dirName() + filename f = pkg.dirName() + filename

View File

@ -64,7 +64,8 @@ class NamingPolicyCheck(AbstractCheck.AbstractCheck):
# check for files then # check for files then
for c in self.checks_: for c in self.checks_:
for f in files: for f in files:
if c['file_re'].search(f) and not c['name_re'].search(pkg.name): if c['file_re'].search(f) and \
not c['name_re'].search(pkg.name):
raise NamingPolicyNotAppliedException raise NamingPolicyNotAppliedException
except NamingPolicyNotAppliedException: except NamingPolicyNotAppliedException:
printWarning(pkg, c['pkg_name'] + '-naming-policy-not-applied', f) printWarning(pkg, c['pkg_name'] + '-naming-policy-not-applied', f)
@ -72,7 +73,7 @@ class NamingPolicyCheck(AbstractCheck.AbstractCheck):
check = NamingPolicyCheck() check = NamingPolicyCheck()
# #
# these are the check currently impleted. # these are the check currently implemented.
# #
# first argument is the name of the check, printed by the warning. # first argument is the name of the check, printed by the warning.
# ex : xmms. # ex : xmms.
@ -80,10 +81,12 @@ check = NamingPolicyCheck()
# secund argument is the regular expression of the naming policy. # secund argument is the regular expression of the naming policy.
# ex: xmms plugin should be named xmms-name_of_plugin. # ex: xmms plugin should be named xmms-name_of_plugin.
# #
# third is the path of the file that should contains a package to be related to the naming scheme. # third is the path of the file that should contains a package to be related to
# the naming scheme.
# ex: xmms plugin are put under /usr/lib/xmms/ # ex: xmms plugin are put under /usr/lib/xmms/
# #
# the module is far from being perfect since you need to check this file for the naming file. # the module is far from being perfect since you need to check this file for
# the naming file.
# if somone as a elegant solution, I will be happy to implement and test it. # if somone as a elegant solution, I will be happy to implement and test it.

View File

@ -19,7 +19,8 @@ pam_stack_re = re.compile('^\s*[^#].*pam_stack\.so\s*service')
class PamCheck(AbstractCheck.AbstractFilesCheck): class PamCheck(AbstractCheck.AbstractFilesCheck):
def __init__(self): def __init__(self):
AbstractCheck.AbstractFilesCheck.__init__(self, "PamCheck", "/etc/pam\.d/.*") AbstractCheck.AbstractFilesCheck.__init__(self, "PamCheck",
"/etc/pam\.d/.*")
def check_file(self, pkg, filename): def check_file(self, pkg, filename):
lines = pkg.grep(pam_stack_re, filename) lines = pkg.grep(pam_stack_re, filename)

30
Pkg.py
View File

@ -69,7 +69,8 @@ def substitute_shell_vars(val, script):
value = shell_var_value(res.group(2), script) value = shell_var_value(res.group(2), script)
if not value: if not value:
value = '' value = ''
return res.group(1) + value + substitute_shell_vars(res.group(3), script) return res.group(1) + value + \
substitute_shell_vars(res.group(3), script)
else: else:
return val return val
@ -77,9 +78,12 @@ def getstatusoutput(cmd, stdoutonly = False):
'''A version of commands.getstatusoutput() which can take cmd as a '''A version of commands.getstatusoutput() which can take cmd as a
sequence, thus making it potentially more secure.''' sequence, thus making it potentially more secure.'''
if stdoutonly: if stdoutonly:
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, close_fds=True)
else: else:
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, close_fds=True)
proc.stdin.close() proc.stdin.close()
text = proc.stdout.read() text = proc.stdout.read()
sts = proc.wait() sts = proc.wait()
@ -98,7 +102,8 @@ def is_utf8(fname):
if bz2_regex.search(fname): cat = 'bzip2 -dcf' if bz2_regex.search(fname): cat = 'bzip2 -dcf'
elif xz_regex.search(fname): cat = 'xz -dc' elif xz_regex.search(fname): cat = 'xz -dc'
# TODO: better shell escaping or sequence based command invocation # TODO: better shell escaping or sequence based command invocation
cmd = commands.getstatusoutput('%s "%s" | iconv -f utf-8 -t utf-8 -o /dev/null' % (cat, fname)) cmd = commands.getstatusoutput(
'%s "%s" | iconv -f utf-8 -t utf-8 -o /dev/null' % (cat, fname))
return not cmd[0] return not cmd[0]
def is_utf8_str(s): def is_utf8_str(s):
@ -217,7 +222,8 @@ def rangeCompare(reqtuple, provtuple):
r = None r = None
if reqe is None: if reqe is None:
e = None e = None
if reqv is None: # just for the record if ver is None then we're going to segfault # just for the record if ver is None then we're going to segfault
if reqv is None:
v = None v = None
# if we just require foo-version, then foo-version-* will match # if we just require foo-version, then foo-version-* will match
@ -384,7 +390,9 @@ class Pkg:
prefix = 'rpmlint.%s.' % os.path.basename(self.filename), prefix = 'rpmlint.%s.' % os.path.basename(self.filename),
dir = self.dirname) dir = self.dirname)
# TODO: better shell escaping or sequence based command invocation # TODO: better shell escaping or sequence based command invocation
command_str = 'rpm2cpio "%s" | (cd "%s"; cpio -id); chmod -R +rX "%s"' % (self.filename, self.dirname, self.dirname) command_str = \
'rpm2cpio "%s" | (cd "%s"; cpio -id); chmod -R +rX "%s"' % \
(self.filename, self.dirname, self.dirname)
cmd = commands.getstatusoutput(command_str) cmd = commands.getstatusoutput(command_str)
self.extracted = True self.extracted = True
return cmd return cmd
@ -577,7 +585,8 @@ class Pkg:
return self._provides return self._provides
# internal function to gather dependency info used by the above ones # internal function to gather dependency info used by the above ones
def _gather_aux(self, header, list, nametag, versiontag, flagstag, prereq = None): def _gather_aux(self, header, list, nametag, versiontag, flagstag,
prereq = None):
names = header[nametag] names = header[nametag]
versions = header[versiontag] versions = header[versiontag]
flags = header[flagstag] flags = header[flagstag]
@ -585,7 +594,8 @@ class Pkg:
if versions: if versions:
for loop in range(len(versions)): for loop in range(len(versions)):
if prereq is not None and flags[loop] & PREREQ_FLAG: if prereq is not None and flags[loop] & PREREQ_FLAG:
prereq.append((names[loop], versions[loop], flags[loop] & (~PREREQ_FLAG))) prereq.append((names[loop], versions[loop],
flags[loop] & (~PREREQ_FLAG)))
else: else:
list.append((names[loop], versions[loop], flags[loop])) list.append((names[loop], versions[loop], flags[loop]))
@ -649,7 +659,9 @@ class InstalledPkg(Pkg):
self.extracted = True self.extracted = True
# create a fake filename to satisfy some checks on the filename # create a fake filename to satisfy some checks on the filename
self.filename = '%s-%s-%s.%s.rpm' % (self.name, self[rpm.RPMTAG_VERSION], self[rpm.RPMTAG_RELEASE], self[rpm.RPMTAG_ARCH]) self.filename = '%s-%s-%s.%s.rpm' % \
(self.name, self[rpm.RPMTAG_VERSION], self[rpm.RPMTAG_RELEASE],
self[rpm.RPMTAG_ARCH])
def cleanup(self): def cleanup(self):
pass pass

View File

@ -119,7 +119,8 @@ class PostCheck(AbstractCheck.AbstractCheck):
self.check_aux(pkg, files, prog, script, tag, prereq) self.check_aux(pkg, files, prog, script, tag, prereq)
else: else:
for idx in range(0, len(prog)): for idx in range(0, len(prog)):
self.check_aux(pkg, files, prog[idx], script[idx], tag, prereq) self.check_aux(
pkg, files, prog[idx], script[idx], tag, prereq)
ghost_files = pkg.ghostFiles() ghost_files = pkg.ghostFiles()
if ghost_files: if ghost_files:
@ -132,7 +133,8 @@ class PostCheck(AbstractCheck.AbstractCheck):
if (not postin or f not in postin) and \ if (not postin or f not in postin) and \
(not prein or f not in prein) and \ (not prein or f not in prein) and \
f not in pkg.missingOkFiles(): f not in pkg.missingOkFiles():
printWarning(pkg, 'postin-without-ghost-file-creation', f) printWarning(pkg,
'postin-without-ghost-file-creation', f)
def check_aux(self, pkg, files, prog, script, tag, prereq): def check_aux(self, pkg, files, prog, script, tag, prereq):
if script: if script:
@ -148,10 +150,12 @@ class PostCheck(AbstractCheck.AbstractCheck):
printWarning(pkg, 'spurious-bracket-in-' + tag[2]) printWarning(pkg, 'spurious-bracket-in-' + tag[2])
res = dangerous_command_regex.search(script) res = dangerous_command_regex.search(script)
if res: if res:
printWarning(pkg, 'dangerous-command-in-' + tag[2], res.group(2)) printWarning(pkg, 'dangerous-command-in-' + tag[2],
res.group(2))
res = selinux_regex.search(script) res = selinux_regex.search(script)
if res: if res:
printError(pkg, 'forbidden-selinux-command-in-' + tag[2], res.group(2)) printError(pkg, 'forbidden-selinux-command-in-' + tag[2],
res.group(2))
if 'update-menus' in script: if 'update-menus' in script:
menu_error = True menu_error = True
@ -160,7 +164,8 @@ class PostCheck(AbstractCheck.AbstractCheck):
menu_error = False menu_error = False
break break
if menu_error: if menu_error:
printError(pkg, 'update-menus-without-menu-file-in-' + tag[2]) printError(pkg, 'update-menus-without-menu-file-in-' +
tag[2])
if tmp_regex.search(script): if tmp_regex.search(script):
printError(pkg, 'use-tmp-in-' + tag[2]) printError(pkg, 'use-tmp-in-' + tag[2])
for c in prereq_assoc: for c in prereq_assoc:
@ -180,7 +185,8 @@ class PostCheck(AbstractCheck.AbstractCheck):
printError(pkg, 'use-of-home-in-' + tag[2]) printError(pkg, 'use-of-home-in-' + tag[2])
res = bogus_var_regex.search(script) res = bogus_var_regex.search(script)
if res: if res:
printWarning(pkg, 'bogus-variable-use-in-' + tag[2], res.group(1)) printWarning(pkg, 'bogus-variable-use-in-' + tag[2],
res.group(1))
if prog == '/usr/bin/perl': if prog == '/usr/bin/perl':
if incorrect_perl_script(prog, script): if incorrect_perl_script(prog, script):

View File

@ -39,7 +39,8 @@ check = RpmFileCheck()
addDetails( addDetails(
'filename-too-long-for-joliet', 'filename-too-long-for-joliet',
'This filename is too long to fit on a joliet filesystem (limit is 64 unicode chars).', '''This filename is too long to fit on a joliet filesystem (limit is 64 unicode
chars).''',
) )
# Local variables: # Local variables:

View File

@ -32,7 +32,8 @@ class SignatureCheck(AbstractCheck.AbstractCheck):
if kres: if kres:
printError(pkg, "unknown-key", kres.group(1)) printError(pkg, "unknown-key", kres.group(1))
else: else:
Pkg.warn("Error checking signature of %s: %s" % (pkg.filename, res[1])) Pkg.warn("Error checking signature of %s: %s" %
(pkg.filename, res[1]))
else: else:
if not SignatureCheck.pgp_regex.search(res[1]): if not SignatureCheck.pgp_regex.search(res[1]):
printError(pkg, "no-signature") printError(pkg, "no-signature")

View File

@ -266,12 +266,15 @@ class SpecCheck(AbstractCheck.AbstractCheck):
if current_section in ('prep', 'build'): if current_section in ('prep', 'build'):
if contains_buildroot(line): if contains_buildroot(line):
printWarning(pkg, 'rpm-buildroot-usage', '%' + current_section, line[:-1].strip()) printWarning(pkg, 'rpm-buildroot-usage',
'%' + current_section, line[:-1].strip())
if make_check_regex.search(line) and current_section not in ('check', 'changelog', 'package', 'description'): if make_check_regex.search(line) and current_section not in \
('check', 'changelog', 'package', 'description'):
printWarning(pkg, 'make-check-outside-check-section', line[:-1]) printWarning(pkg, 'make-check-outside-check-section', line[:-1])
if current_section in buildroot_clean and not buildroot_clean[current_section]: if current_section in buildroot_clean and \
not buildroot_clean[current_section]:
if contains_buildroot(line) and rm_regex.search(line): if contains_buildroot(line) and rm_regex.search(line):
buildroot_clean[current_section] = True buildroot_clean[current_section] = True
@ -327,16 +330,22 @@ class SpecCheck(AbstractCheck.AbstractCheck):
elif res.group(1): elif res.group(1):
res = re.match(hardcoded_library_paths, res.group(1)) res = re.match(hardcoded_library_paths, res.group(1))
if res: if res:
printError(pkg, "hardcoded-library-path", res.group(1), "in configure options") printError(pkg, "hardcoded-library-path",
res.group(1), "in configure options")
configure_linenum = None configure_linenum = None
if current_section != 'changelog' and './configure' in line: if current_section != 'changelog' and './configure' in line:
configure_linenum = pkg.current_linenum # store line where it started # store line where it started
configure_linenum = pkg.current_linenum
configure_cmdline = line.strip() configure_cmdline = line.strip()
res = hardcoded_library_path_regex.search(line) res = hardcoded_library_path_regex.search(line)
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())): if current_section != 'changelog' and res and not \
printError(pkg, "hardcoded-library-path", "in", res.group(1).lstrip()) (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())
if '%mklibname' in line: if '%mklibname' in line:
mklibname = True mklibname = True
@ -361,7 +370,8 @@ class SpecCheck(AbstractCheck.AbstractCheck):
if res: if res:
buildroot = True buildroot = True
if res.group(1).startswith('/'): if res.group(1).startswith('/'):
printWarning(pkg, 'hardcoded-path-in-buildroot-tag', res.group(1)) printWarning(pkg, 'hardcoded-path-in-buildroot-tag',
res.group(1))
res = packager_regex.search(line) res = packager_regex.search(line)
if res: if res:
@ -385,7 +395,8 @@ class SpecCheck(AbstractCheck.AbstractCheck):
printError(pkg, 'buildprereq-use', res.group(1)) printError(pkg, 'buildprereq-use', res.group(1))
if scriptlet_requires_regex.search(line): if scriptlet_requires_regex.search(line):
printError(pkg, 'broken-syntax-in-scriptlet-requires', line.strip()) printError(pkg, 'broken-syntax-in-scriptlet-requires',
line.strip())
res = requires_regex.search(line) res = requires_regex.search(line)
if res: if res:
@ -428,9 +439,11 @@ class SpecCheck(AbstractCheck.AbstractCheck):
printWarning(pkg, 'macro-in-%changelog', match) printWarning(pkg, 'macro-in-%changelog', match)
else: else:
if not depscript_override: if not depscript_override:
depscript_override = depscript_override_regex.search(line) is not None depscript_override = \
depscript_override_regex.search(line) is not None
if not depgen_disabled: if not depgen_disabled:
depgen_disabled = depgen_disable_regex.search(line) is not None depgen_disabled = \
depgen_disable_regex.search(line) is not None
if current_section == 'files': if current_section == 'files':
@ -443,7 +456,9 @@ class SpecCheck(AbstractCheck.AbstractCheck):
printError(pkg, 'files-attr-not-set') printError(pkg, 'files-attr-not-set')
# TODO: check scriptlets for these too? # TODO: check scriptlets for these too?
if package_noarch.get(current_package) or (current_package not in package_noarch and package_noarch.get(None)): if package_noarch.get(current_package) or \
(current_package not in package_noarch and
package_noarch.get(None)):
res = libdir_regex.search(line) res = libdir_regex.search(line)
if res: if res:
pkgname = current_package pkgname = current_package

View File

@ -513,7 +513,8 @@ class TagsCheck(AbstractCheck.AbstractCheck):
self._unexpanded_macros(pkg, 'Packager', packager) self._unexpanded_macros(pkg, 'Packager', packager)
if not packager: if not packager:
printError(pkg, 'no-packager-tag') printError(pkg, 'no-packager-tag')
elif Config.getOption('Packager') and not packager_regex.search(packager): elif Config.getOption('Packager') and \
not packager_regex.search(packager):
printWarning(pkg, 'invalid-packager', packager) printWarning(pkg, 'invalid-packager', packager)
version = pkg[rpm.RPMTAG_VERSION] version = pkg[rpm.RPMTAG_VERSION]
@ -543,10 +544,12 @@ class TagsCheck(AbstractCheck.AbstractCheck):
if use_epoch: if use_epoch:
for o in pkg.obsoletes(): for o in pkg.obsoletes():
if o[1] and not epoch_regex.search(o[1]): if o[1] and not epoch_regex.search(o[1]):
printWarning(pkg, 'no-epoch-in-obsoletes', o[0] + ' ' + o[1]) printWarning(pkg,
'no-epoch-in-obsoletes', o[0] + ' ' + o[1])
for c in pkg.conflicts(): for c in pkg.conflicts():
if c[1] and not epoch_regex.search(c[1]): if c[1] and not epoch_regex.search(c[1]):
printWarning(pkg, 'no-epoch-in-conflicts', c[0] + ' ' + c[1]) printWarning(pkg,
'no-epoch-in-conflicts', c[0] + ' ' + c[1])
for p in pkg.provides(): for p in pkg.provides():
if p[1] and not epoch_regex.search(p[1]): if p[1] and not epoch_regex.search(p[1]):
printWarning(pkg, 'no-epoch-in-provides', p[0] + ' ' + p[1]) printWarning(pkg, 'no-epoch-in-provides', p[0] + ' ' + p[1])
@ -557,7 +560,8 @@ class TagsCheck(AbstractCheck.AbstractCheck):
is_devel = FilesCheck.devel_regex.search(name) is_devel = FilesCheck.devel_regex.search(name)
is_source = pkg.isSource() is_source = pkg.isSource()
for d in deps: for d in deps:
if use_epoch and d[1] and d[0][0:7] != 'rpmlib(' and not epoch_regex.search(d[1]): if use_epoch and d[1] and d[0][0:7] != 'rpmlib(' and \
not epoch_regex.search(d[1]):
printWarning(pkg, 'no-epoch-in-dependency', d[0] + ' ' + d[1]) printWarning(pkg, 'no-epoch-in-dependency', d[0] + ' ' + d[1])
for r in INVALID_REQUIRES: for r in INVALID_REQUIRES:
if r.search(d[0]): if r.search(d[0]):
@ -611,9 +615,12 @@ class TagsCheck(AbstractCheck.AbstractCheck):
expected = version expected = version
if dep[1][:len(expected)] != expected: if dep[1][:len(expected)] != expected:
if dep[1] != '': if dep[1] != '':
printWarning(pkg, 'incoherent-version-dependency-on', base_or_libs, dep[1], expected) printWarning(pkg,
'incoherent-version-dependency-on',
base_or_libs, dep[1], expected)
else: else:
printWarning(pkg, 'no-version-dependency-on', base_or_libs, expected) printWarning(pkg, 'no-version-dependency-on',
base_or_libs, expected)
res = devel_number_regex.search(name) res = devel_number_regex.search(name)
if not res: if not res:
printWarning(pkg, 'no-major-in-name', name) printWarning(pkg, 'no-major-in-name', name)
@ -687,10 +694,12 @@ class TagsCheck(AbstractCheck.AbstractCheck):
# Allow EVR in changelog without release extension, # Allow EVR in changelog without release extension,
# the extension is often a macro or otherwise dynamic. # the extension is often a macro or otherwise dynamic.
if release_ext: if release_ext:
expected.append(extension_regex.sub('', expected[0])) expected.append(
extension_regex.sub('', expected[0]))
if ret.group(1) not in expected: if ret.group(1) not in expected:
if len(expected) == 1: expected = expected[0] if len(expected) == 1: expected = expected[0]
printWarning(pkg, 'incoherent-version-in-changelog', ret.group(1), expected) printWarning(pkg, 'incoherent-version-in-changelog',
ret.group(1), expected)
if clt: changelog = changelog + clt if clt: changelog = changelog + clt
if use_utf8 and not Pkg.is_utf8_str(' '.join(changelog)): if use_utf8 and not Pkg.is_utf8_str(' '.join(changelog)):
@ -784,7 +793,8 @@ class TagsCheck(AbstractCheck.AbstractCheck):
j += 1 j += 1
i += 1 i += 1
expected = pkg.header.sprintf(rpm.expandMacro("%{_build_name_fmt}")).split("/")[-1] expected = pkg.header.sprintf(
rpm.expandMacro("%{_build_name_fmt}")).split("/")[-1]
basename = os.path.basename(pkg.filename) basename = os.path.basename(pkg.filename)
if basename != expected: if basename != expected:
printWarning(pkg, 'non-coherent-filename', basename, expected) printWarning(pkg, 'non-coherent-filename', basename, expected)
@ -866,12 +876,12 @@ with something you have control over.''',
'''The value of this tag appears to be misspelled. Please double-check.''', '''The value of this tag appears to be misspelled. Please double-check.''',
'no-packager-tag', 'no-packager-tag',
'''There is no Packager tag in your package. You have to specify a packager using '''There is no Packager tag in your package. You have to specify a packager
the Packager tag. Ex: Packager: John Doo <john.doo@example.com>.''', using the Packager tag. Ex: Packager: John Doe <john.doe@example.com>.''',
'invalid-packager', 'invalid-packager',
'''The packager email must finish with a email compatible with the Packager option '''The packager email must end with an email compatible with the Packager
of rpmlint. Please change it and rebuild your package.''', option of rpmlint. Please change it and rebuild your package.''',
'no-version-tag', 'no-version-tag',
'''There is no Version tag in your package. You have to specify a version using '''There is no Version tag in your package. You have to specify a version using
@ -909,8 +919,8 @@ Name tag.''',
''', ''',
'no-provides', 'no-provides',
'''Your library package doesn't provide the -devel name without the major version '''Your library package doesn't provide the -devel name without the major
included.''', version included.''',
'no-summary-tag', 'no-summary-tag',
'''There is no Summary tag in your package. You have to describe your package '''There is no Summary tag in your package. You have to describe your package
@ -1008,8 +1018,8 @@ Epoch tag.''',
package itself.''', package itself.''',
'invalid-build-requires', 'invalid-build-requires',
'''Your source package contains a dependency not compliant with the lib64 naming. '''Your source package contains a dependency not compliant with the lib64
This BuildRequires dependency will not be resolved on lib64 platforms naming. This BuildRequires dependency will not be resolved on lib64 platforms
(eg. amd64).''', (eg. amd64).''',
'explicit-lib-dependency', 'explicit-lib-dependency',

View File

@ -55,7 +55,8 @@ class ZipCheck(AbstractCheck.AbstractCheck):
try: try:
mf = z.read('META-INF/MANIFEST.MF') mf = z.read('META-INF/MANIFEST.MF')
if classpath_regex.search(mf): if classpath_regex.search(mf):
printWarning(pkg, 'class-path-in-manifest', fname) printWarning(pkg,
'class-path-in-manifest', fname)
except KeyError: except KeyError:
# META-INF/* are optional: # META-INF/* are optional:
# http://java.sun.com/j2se/1.4/docs/guide/jar/jar.html # http://java.sun.com/j2se/1.4/docs/guide/jar/jar.html