SHA256
1
0
forked from pool/rpmlint

0001-split-wrong-script-interpreter-into-env-script-inter.patch,

0001-Handle-post-scripts-that-contain-non-ascii-character.patch

OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=515
This commit is contained in:
Dirk Mueller 2017-10-04 13:59:08 +00:00 committed by Git OBS Bridge
parent 946eb5c616
commit 2764482b3b
15 changed files with 173 additions and 91 deletions

View File

@ -9,11 +9,11 @@ to do.
BinariesCheck.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/BinariesCheck.py b/BinariesCheck.py
index 887e0f0..26983bb 100644
--- a/BinariesCheck.py
+++ b/BinariesCheck.py
@@ -206,7 +206,8 @@ class BinaryInfo(object):
Index: rpmlint-rpmlint-1.10/BinariesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/BinariesCheck.py
+++ rpmlint-rpmlint-1.10/BinariesCheck.py
@@ -223,7 +223,8 @@ class BinaryInfo(object):
# without chdir)
# Currently this implementation works only on x86_64 due to reliance
# on x86_64 specific assembly. Skip it on other architectures
@ -23,7 +23,7 @@ index 887e0f0..26983bb 100644
p = subprocess.Popen(('objdump', '-d', path),
stdout=subprocess.PIPE, bufsize=-1,
env=dict(os.environ, LC_ALL="C"))
@@ -531,7 +532,7 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
@@ -578,7 +579,7 @@ class BinariesCheck(AbstractCheck.Abstra
printError(pkg, 'missing-call-to-setgroups-before-setuid',
fname)
@ -32,6 +32,3 @@ index 887e0f0..26983bb 100644
if not bin_info.chdir or not bin_info.chroot_near_chdir:
printError(pkg, 'missing-call-to-chdir-with-chroot', fname)
--
2.14.1

View File

@ -9,11 +9,11 @@ Also add unit test coverage for it.
test/test_files.py | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/FilesCheck.py b/FilesCheck.py
index a7724de..87965bc 100644
--- a/FilesCheck.py
+++ b/FilesCheck.py
@@ -201,7 +201,9 @@ ldconfig_regex = re.compile(r'^[^#]*ldconfig', re.MULTILINE)
Index: rpmlint-rpmlint-1.10/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.10/FilesCheck.py
@@ -202,7 +202,9 @@ ldconfig_regex = re.compile(r'^[^#]*ldco
depmod_regex = re.compile(r'^[^#]*depmod', re.MULTILINE)
install_info_regex = re.compile(r'^[^#]*install-info', re.MULTILINE)
perl_temp_file_regex = re.compile(r'.*perl.*/(\.packlist|perllocal\.pod)$')
@ -24,10 +24,10 @@ index a7724de..87965bc 100644
games_path_regex = re.compile(r'^/usr(/lib(64)?)?/games/')
games_group_regex = re.compile(Config.getOption('RpmGamesGroups', DEFAULT_GAMES_GROUPS))
dangling_exceptions = Config.getOption('DanglingSymlinkExceptions', DEFAULT_DANGLING_EXCEPTIONS)
diff --git a/test/test_files.py b/test/test_files.py
index 469a227..f26c0c3 100644
--- a/test/test_files.py
+++ b/test/test_files.py
Index: rpmlint-rpmlint-1.10/test/test_files.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/test/test_files.py
+++ rpmlint-rpmlint-1.10/test/test_files.py
@@ -52,3 +52,13 @@ def test_script_interpreter():
assert se(b"#! /usr/bin/perl -wT \n") == ("/usr/bin/perl", "-wT")
assert se(b"#!/usr/bin/env python3 foo") == ("/usr/bin/env", "python3 foo")
@ -42,6 +42,3 @@ index 469a227..f26c0c3 100644
+ assert scm_regex.search('/bar/foo,v')
+ assert scm_regex.search('bar/.svnignore')
+ assert scm_regex.search('bar/.git/refs')
--
2.14.1

View File

@ -0,0 +1,120 @@
From 53b868fcaba87016c623f47e8d40e09f4fccaafa Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Wed, 4 Oct 2017 14:40:02 +0200
Subject: [PATCH] Handle %post scripts that contain non-ascii characters
when running LC_ALL=C and python3 this otherwise traces with:
File "rpmlint/PostCheck.py", line 83, in check_syntax_script
tmpfile.write(script)
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 16: ordinal not in range(128)
Add test coverage.
---
PostCheck.py | 31 +++++++++++++++++------------
test/binary/Nonutfpostcheck-0-0.x86_64.rpm | Bin 0 -> 6028 bytes
2 files changed, 18 insertions(+), 13 deletions(-)
create mode 100644 test/binary/Nonutfpostcheck-0-0.x86_64.rpm
Index: rpmlint-rpmlint-1.10/PostCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/PostCheck.py
+++ rpmlint-rpmlint-1.10/PostCheck.py
@@ -10,6 +10,7 @@
import os
import re
+import tempfile
import rpm
@@ -78,7 +79,8 @@ def check_syntax_script(prog, commandlin
if not script:
return False
# TODO: test that "prog" is available/executable
- tmpfile, tmpname = Pkg.mktemp()
+ tmpfd, tmpname = tempfile.mkstemp(prefix='rpmlint.')
+ tmpfile = os.fdopen(tmpfd, 'wb')
try:
tmpfile.write(script)
tmpfile.close()
@@ -105,35 +107,38 @@ class PostCheck(AbstractCheck.AbstractCh
prog = pkg.scriptprog(tag[1])
if prog:
prog = prog.split()[0]
- self.check_aux(pkg, files, prog, script, tag[2], prereq)
+ self.check_aux(pkg, files, prog, pkg.header[tag[0]],
+ tag[2], prereq)
else:
prog = pkg[tag[1]]
for idx in range(0, len(prog)):
self.check_aux(
- pkg, files, prog[idx], script[idx], tag[2], prereq)
+ pkg, files, prog[idx],
+ pkg.header[tag[0]][idx], tag[2], prereq)
def check_aux(self, pkg, files, prog, script, tag, prereq):
if script:
+ script_str = Pkg.b2s(script)
if prog:
if prog not in valid_shells:
printError(pkg, 'invalid-shell-in-' + tag, prog)
if prog in empty_shells:
printError(pkg, 'non-empty-' + tag, prog)
if prog in syntaxcheck_shells or prog == '/usr/bin/perl':
- if percent_regex.search(script):
+ if percent_regex.search(script_str):
printWarning(pkg, 'percent-in-' + tag)
- if bracket_regex.search(script):
+ if bracket_regex.search(script_str):
printWarning(pkg, 'spurious-bracket-in-' + tag)
- res = dangerous_command_regex.search(script)
+ res = dangerous_command_regex.search(script_str)
if res:
printWarning(pkg, 'dangerous-command-in-' + tag,
res.group(2))
- res = selinux_regex.search(script)
+ res = selinux_regex.search(script_str)
if res:
printError(pkg, 'forbidden-selinux-command-in-' + tag,
res.group(2))
- if 'update-menus' in script:
+ if 'update-menus' in script_str:
menu_error = True
for f in files:
if menu_regex.search(f):
@@ -142,10 +147,10 @@ class PostCheck(AbstractCheck.AbstractCh
if menu_error:
printError(pkg, 'update-menus-without-menu-file-in-' +
tag)
- if tmp_regex.search(script):
+ if tmp_regex.search(script_str):
printError(pkg, 'use-tmp-in-' + tag)
for c in prereq_assoc:
- if c[0].search(script):
+ if c[0].search(script_str):
found = False
for p in c[1]:
if p in prereq or p in files:
@@ -157,9 +162,9 @@ class PostCheck(AbstractCheck.AbstractCh
if prog in syntaxcheck_shells:
if incorrect_shell_script(prog, script):
printError(pkg, 'shell-syntax-error-in-' + tag)
- if home_regex.search(script):
+ if home_regex.search(script_str):
printError(pkg, 'use-of-home-in-' + tag)
- res = bogus_var_regex.search(script)
+ res = bogus_var_regex.search(script_str)
if res:
printWarning(pkg, 'bogus-variable-use-in-' + tag,
res.group(1))
@@ -168,7 +173,7 @@ class PostCheck(AbstractCheck.AbstractCh
if incorrect_perl_script(prog, script):
printError(pkg, 'perl-syntax-error-in-' + tag)
elif prog.endswith('sh'):
- res = single_command_regex.search(script)
+ res = single_command_regex.search(script_str)
if res:
printWarning(pkg, 'one-line-command-in-' + tag,
res.group(1))

View File

@ -14,11 +14,11 @@ warning about those, as there are more likely legitimate reasons.
FilesCheck.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/FilesCheck.py b/FilesCheck.py
index 1852b38..0b93e73 100644
--- a/FilesCheck.py
+++ b/FilesCheck.py
@@ -848,7 +848,10 @@ class FilesCheck(AbstractCheck.AbstractCheck):
Index: rpmlint-rpmlint-1.10/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.10/FilesCheck.py
@@ -861,7 +861,10 @@ class FilesCheck(AbstractCheck.AbstractC
elif interpreter or mode_is_exec or script_regex.search(f):
if interpreter:
res = interpreter_regex.search(interpreter)
@ -30,6 +30,3 @@ index 1852b38..0b93e73 100644
printError(pkg, 'wrong-script-interpreter',
f, interpreter, interpreter_args)
elif not nonexec_file and not \
--
2.14.1

View File

@ -10,24 +10,24 @@ Also add unit test coverage for it.
test/test_files.py | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/FilesCheck.py b/FilesCheck.py
index 57de8fb..1852b38 100644
--- a/FilesCheck.py
+++ b/FilesCheck.py
@@ -196,7 +196,7 @@ devel_regex = re.compile(r'(.*)-(debug(info|source)?|devel|headers|source|static
Index: rpmlint-rpmlint-1.10/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.10/FilesCheck.py
@@ -197,7 +197,7 @@ devel_regex = re.compile(r'(.*)-(debug(i
debuginfo_package_regex = re.compile(r'-debug(info)?$')
debugsource_package_regex = re.compile(r'-debugsource$')
use_debugsource = Config.getOption('UseDebugSource', False)
-lib_regex = re.compile(r'lib(64)?/lib[^/]*(\.so\..*|-[0-9.]+\.so)')
+lib_regex = re.compile(r'lib(?:64)?/lib[^/]*(?:\.so\.[\d\.]+|\.so)$')
+lib_regex = re.compile(r'/lib(?:64)?/lib[^/]+(?:\.so\.[\d\.]+|-[\d\.]+\.so)$')
ldconfig_regex = re.compile(r'^[^#]*ldconfig', re.MULTILINE)
depmod_regex = re.compile(r'^[^#]*depmod', re.MULTILINE)
install_info_regex = re.compile(r'^[^#]*install-info', re.MULTILINE)
diff --git a/test/test_files.py b/test/test_files.py
index f26c0c3..bfffda5 100644
--- a/test/test_files.py
+++ b/test/test_files.py
@@ -62,3 +62,20 @@ def test_scm_regex():
Index: rpmlint-rpmlint-1.10/test/test_files.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/test/test_files.py
+++ rpmlint-rpmlint-1.10/test/test_files.py
@@ -62,3 +62,22 @@ def test_scm_regex():
assert scm_regex.search('/bar/foo,v')
assert scm_regex.search('bar/.svnignore')
assert scm_regex.search('bar/.git/refs')
@ -40,46 +40,13 @@ index f26c0c3..bfffda5 100644
+ assert all(
+ lib_regex.search(x) for x in
+ ('/lib/libnsl-2.26.so',
+ '/lib64/libSegFault.so',
+ '/usr/lib64/libgnomeui.so.3',
+ '/lib64/libgcc_s.so.1'))
+
+ # false positives
+ assert not any(
+ lib_regex.search(x) for x in
+ ('/usr/share/gdb/auto-load/usr/lib/libglib-2.0.so.0.4600.1-gdb.py',
+ '/usr/lib64/rsocket/binary',))
--
2.14.1
diff --git a/FilesCheck.py b/FilesCheck.py
index 6a97601..abb3fa7 100644
--- a/FilesCheck.py
+++ b/FilesCheck.py
@@ -196,7 +196,7 @@ devel_regex = re.compile(r'(.*)-(debug(info|source)?|devel|headers|source|static
debuginfo_package_regex = re.compile(r'-debug(info)?$')
debugsource_package_regex = re.compile(r'-debugsource$')
use_debugsource = Config.getOption('UseDebugSource', False)
-lib_regex = re.compile(r'lib(?:64)?/lib[^/]*(?:\.so\.[\d\.]+|\.so)$')
+lib_regex = re.compile(r'/lib(?:64)?/lib[^/]+(?:\.so\.[\d\.]+|-[\d\.]+\.so)$')
ldconfig_regex = re.compile(r'^[^#]*ldconfig', re.MULTILINE)
depmod_regex = re.compile(r'^[^#]*depmod', re.MULTILINE)
install_info_regex = re.compile(r'^[^#]*install-info', re.MULTILINE)
diff --git a/test/test_files.py b/test/test_files.py
index bfffda5..0192c13 100644
--- a/test/test_files.py
+++ b/test/test_files.py
@@ -71,11 +71,13 @@ def test_lib_regex():
assert all(
lib_regex.search(x) for x in
('/lib/libnsl-2.26.so',
- '/lib64/libSegFault.so',
+ '/usr/lib64/libgnomeui.so.3',
'/lib64/libgcc_s.so.1'))
# false positives
assert not any(
lib_regex.search(x) for x in
('/usr/share/gdb/auto-load/usr/lib/libglib-2.0.so.0.4600.1-gdb.py',
+ '/usr/share/doc/findlib/lib-1.0.so',
+ '/usr/lib64/libvulkan_radeon.so',
'/usr/lib64/rsocket/binary',))
+ '/usr/lib64/rsocket/binary',))

View File

@ -19,7 +19,7 @@ Index: rpmlint-rpmlint-1.10/TagsCheck.py
for c in pkg.conflicts():
value = Pkg.formatRequire(*c)
@@ -1234,6 +1236,10 @@ objects should thus not be depended on a
@@ -1215,6 +1217,10 @@ objects should thus not be depended on a
in the containing package. Get rid of the provides if appropriate, for example
by filtering it out during build. Note that in some cases this may require
disabling rpmbuild's internal dependency generator.''',

View File

@ -1,7 +1,7 @@
diff --git a/SpecCheck.py b/SpecCheck.py
index 8cb85b3..45ad404 100644
--- a/SpecCheck.py
+++ b/SpecCheck.py
Index: rpmlint-rpmlint-1.10/SpecCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/SpecCheck.py
+++ rpmlint-rpmlint-1.10/SpecCheck.py
@@ -9,7 +9,6 @@
import re
@ -10,7 +10,7 @@ index 8cb85b3..45ad404 100644
try:
from urlparse import urlparse
except ImportError: # Python 3
@@ -106,7 +105,7 @@ filelist_regex = re.compile(r'\s+-f\s+\S+')
@@ -107,7 +106,7 @@ filelist_regex = re.compile(r'\s+-f\s+\S
pkgname_regex = re.compile(r'\s+(?:-n\s+)?(\S+)')
tarball_regex = re.compile(r'\.(?:t(?:ar|[glx]z|bz2?)|zip)\b', re.IGNORECASE)

View File

@ -1,6 +1,8 @@
--- a/BinariesCheck.py
+++ b/BinariesCheck.py
@@ -240,8 +240,11 @@ class BinaryInfo(object):
Index: rpmlint-rpmlint-1.10/BinariesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/BinariesCheck.py
+++ rpmlint-rpmlint-1.10/BinariesCheck.py
@@ -255,8 +255,11 @@ class BinaryInfo(object):
else:
self.readelf_error = True

View File

@ -29,7 +29,7 @@ Index: rpmlint-rpmlint-1.10/TagsCheck.py
if is_source:
if lib_devel_number_regex.search(d[0]):
printError(pkg, 'invalid-build-requires', d[0])
@@ -1181,6 +1185,12 @@ unneeded explicit Requires: tags.''',
@@ -1162,6 +1166,12 @@ unneeded explicit Requires: tags.''',
'''This package provides 2 times the same capacity. It should only provide it
once.''',

View File

@ -30,7 +30,7 @@ Index: rpmlint-rpmlint-1.10/BinariesCheck.py
is_elf = 'ELF' in pkgfile.magic
is_ar = 'current ar archive' in pkgfile.magic
is_ocaml_native = 'Objective caml native' in pkgfile.magic
@@ -596,9 +601,12 @@ class BinariesCheck(AbstractCheck.Abstra
@@ -592,9 +597,12 @@ class BinariesCheck(AbstractCheck.Abstra
if version and version != -1 and version not in pkg.name:
printError(pkg, 'incoherent-version-in-name', version)
@ -44,7 +44,7 @@ Index: rpmlint-rpmlint-1.10/BinariesCheck.py
if has_usr_lib_file and not binary_in_usr_lib:
printWarning(pkg, 'only-non-binary-in-usr-lib')
@@ -623,6 +631,11 @@ FHS and the FSSTND forbid this.''',
@@ -619,6 +627,11 @@ FHS and the FSSTND forbid this.''',
# 'non-sparc32-binary',
# '',

View File

@ -95,7 +95,8 @@ Thu Sep 28 10:40:08 UTC 2017 - dmueller@suse.com
fix-diag-sortorder.diff, drop-unicodedata-dep.diff,
0001-Tighten-wrong-script-interpreter-check-to-lower-fals.patch,
0001-Improve-XDG-Menu-checks-stability.patch,
0001-split-wrong-script-interpreter-into-env-script-inter.patch
0001-split-wrong-script-interpreter-into-env-script-inter.patch,
0001-Handle-post-scripts-that-contain-non-ascii-character.patch
- drop config.in: unused
- switch to python 3.x

View File

@ -81,6 +81,7 @@ Patch62: ignore-readelf-ar-error.diff
Patch63: fix-diag-sortorder.diff
Patch64: drop-unicodedata-dep.diff
Patch65: 0001-split-wrong-script-interpreter-into-env-script-inter.patch
Patch66: 0001-Handle-post-scripts-that-contain-non-ascii-character.patch
Patch70: rpmlint-all-pie.patch
BuildRequires: obs-service-format_spec_file
BuildRequires: python3-flake8

View File

@ -28,7 +28,7 @@ Index: rpmlint-rpmlint-1.10/TagsCheck.py
if prov_names.count(p) != 1 and p not in useless_provides:
useless_provides.append(p)
for p in useless_provides:
@@ -1030,6 +1033,10 @@ the Release tag.''',
@@ -1011,6 +1014,10 @@ the Release tag.''',
'''There is no Name tag in your package. You have to specify a name using the
Name tag.''',

View File

@ -11,7 +11,7 @@ Index: rpmlint-rpmlint-1.10/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.10/FilesCheck.py
@@ -869,7 +869,8 @@ class FilesCheck(AbstractCheck.AbstractC
@@ -872,7 +872,8 @@ class FilesCheck(AbstractCheck.AbstractC
f.endswith('.la')):
printError(pkg, 'script-without-shebang', f)

View File

@ -11,7 +11,7 @@ Index: rpmlint-rpmlint-1.10/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.10/TagsCheck.py
@@ -972,7 +972,7 @@ class TagsCheck(AbstractCheck.AbstractCh
@@ -953,7 +953,7 @@ class TagsCheck(AbstractCheck.AbstractCh
spell_check(pkg, summary, 'Summary(%s)', lang, ignored_words)
if '\n' in summary:
printError(pkg, 'summary-on-multiple-lines', lang)