This commit is contained in:
Tom Callaway 2019-06-21 10:49:39 -04:00
parent 4e0d749337
commit b129e361c8
7 changed files with 6 additions and 529 deletions

View File

@ -1,358 +0,0 @@
diff -up rpmlint-rpmlint-1.10/AbstractCheck.py.flake rpmlint-rpmlint-1.10/AbstractCheck.py
--- rpmlint-rpmlint-1.10/AbstractCheck.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/AbstractCheck.py 2018-04-17 12:22:20.681609697 -0400
@@ -11,7 +11,7 @@ import contextlib
import re
try:
import urllib2
-except:
+except ImportError:
import urllib.request as urllib2
import Config
diff -up rpmlint-rpmlint-1.10/BinariesCheck.py.flake rpmlint-rpmlint-1.10/BinariesCheck.py
--- rpmlint-rpmlint-1.10/BinariesCheck.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/BinariesCheck.py 2018-04-17 12:22:52.688880629 -0400
@@ -101,32 +101,32 @@ class BinaryInfo(object):
('readelf', '-W', '-S', '-l', '-d', '-s', path))
if not res[0]:
lines = res[1].splitlines()
- for l in lines:
- r = BinaryInfo.needed_regex.search(l)
+ for line in lines:
+ r = BinaryInfo.needed_regex.search(line)
if r:
self.needed.append(r.group(1))
continue
- r = BinaryInfo.rpath_regex.search(l)
+ r = BinaryInfo.rpath_regex.search(line)
if r:
for p in r.group(1).split(':'):
self.rpath.append(p)
continue
- if BinaryInfo.comment_regex.search(l):
+ if BinaryInfo.comment_regex.search(line):
self.comment = True
continue
- if BinaryInfo.pic_regex.search(l):
+ if BinaryInfo.pic_regex.search(line):
self.non_pic = False
continue
- r = BinaryInfo.soname_regex.search(l)
+ r = BinaryInfo.soname_regex.search(line)
if r:
self.soname = r.group(1)
continue
- r = BinaryInfo.stack_regex.search(l)
+ r = BinaryInfo.stack_regex.search(line)
if r:
self.stack = True
flags = r.group(1)
@@ -134,45 +134,45 @@ class BinaryInfo(object):
self.exec_stack = True
continue
- if l.startswith("Symbol table"):
+ if line.startswith("Symbol table"):
break
- for l in lines:
- r = BinaryInfo.call_regex.search(l)
+ for line in lines:
+ r = BinaryInfo.call_regex.search(line)
if not r:
continue
- l = r.group(1)
+ line = r.group(1)
- if BinaryInfo.mktemp_call_regex.search(l):
+ if BinaryInfo.mktemp_call_regex.search(line):
self.mktemp = True
- if BinaryInfo.setgid_call_regex.search(l):
+ if BinaryInfo.setgid_call_regex.search(line):
self.setgid = True
- if BinaryInfo.setuid_call_regex.search(l):
+ if BinaryInfo.setuid_call_regex.search(line):
self.setuid = True
- if BinaryInfo.setgroups_call_regex.search(l):
+ if BinaryInfo.setgroups_call_regex.search(line):
self.setgroups = True
- if BinaryInfo.chdir_call_regex.search(l):
+ if BinaryInfo.chdir_call_regex.search(line):
self.chdir = True
- if BinaryInfo.chroot_call_regex.search(l):
+ if BinaryInfo.chroot_call_regex.search(line):
self.chroot = True
if BinaryInfo.forbidden_functions:
for r_name, func in BinaryInfo.forbidden_functions.items():
- ret = func['f_regex'].search(l)
+ ret = func['f_regex'].search(line)
if ret:
self.forbidden_calls.append(r_name)
if is_shlib:
- r = BinaryInfo.exit_call_regex.search(l)
+ r = BinaryInfo.exit_call_regex.search(line)
if r:
self.exit_calls.append(r.group(1))
continue
- r = BinaryInfo.fork_call_regex.search(l)
+ r = BinaryInfo.fork_call_regex.search(line)
if r:
fork_called = True
continue
@@ -182,14 +182,14 @@ class BinaryInfo(object):
if self.forbidden_calls:
res = Pkg.getstatusoutput(('strings', path))
if not res[0]:
- for l in res[1].splitlines():
+ for line in res[1].splitlines():
# as we need to remove elements, iterate backwards
for i in range(len(self.forbidden_calls) - 1, -1, -1):
func = self.forbidden_calls[i]
f = BinaryInfo.forbidden_functions[func]
if 'waiver_regex' not in f:
continue
- r = f['waiver_regex'].search(l)
+ r = f['waiver_regex'].search(line)
if r:
del self.forbidden_calls[i]
@@ -254,8 +254,8 @@ class BinaryInfo(object):
# We could do this with objdump, but it's _much_ simpler with ldd.
res = Pkg.getstatusoutput(('ldd', '-d', '-r', path))
if not res[0]:
- for l in res[1].splitlines():
- undef = BinaryInfo.undef_regex.search(l)
+ for line in res[1].splitlines():
+ undef = BinaryInfo.undef_regex.search(line)
if undef:
self.undef.append(undef.group(1))
if self.undef:
@@ -263,7 +263,7 @@ class BinaryInfo(object):
res = Pkg.getstatusoutput(['c++filt'] + self.undef)
if not res[0]:
self.undef = res[1].splitlines()
- except:
+ except OSError:
pass
else:
printWarning(pkg, 'ldd-failed', file)
@@ -272,13 +272,13 @@ class BinaryInfo(object):
# Either ldd doesn't grok -u (added in glibc 2.3.4) or we have
# unused direct dependencies
in_unused = False
- for l in res[1].splitlines():
- if not l.rstrip():
+ for line in res[1].splitlines():
+ if not line.rstrip():
pass
- elif l.startswith('Unused direct dependencies'):
+ elif line.startswith('Unused direct dependencies'):
in_unused = True
elif in_unused:
- unused = BinaryInfo.unused_regex.search(l)
+ unused = BinaryInfo.unused_regex.search(line)
if unused:
self.unused.append(unused.group(1))
else:
diff -up rpmlint-rpmlint-1.10/Config.py.flake rpmlint-rpmlint-1.10/Config.py
--- rpmlint-rpmlint-1.10/Config.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/Config.py 2018-04-17 12:22:20.684609629 -0400
@@ -42,11 +41,11 @@ USEUTF8_DEFAULT = False
try:
if locale.getpreferredencoding() == 'UTF-8':
USEUTF8_DEFAULT = True
-except:
+except UnicodeError:
try:
if re.match('utf', locale.getdefaultlocale()[1], re.I):
USEUTF8_DEFAULT = True
- except:
+ except UnicodeError:
pass
info = False
@@ -105,10 +105,7 @@ def setOption(name, value):
def getOption(name, default=""):
- try:
- return _options[name]
- except:
- return default
+ return _options.get(name, default)
# List of filters
@@ -128,7 +125,7 @@ def removeFilter(s):
try:
_filters.remove(s)
- except:
+ except ValueError:
pass
else:
_filters_re = None
diff -up rpmlint-rpmlint-1.10/MenuXDGCheck.py.flake rpmlint-rpmlint-1.10/MenuXDGCheck.py
--- rpmlint-rpmlint-1.10/MenuXDGCheck.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/MenuXDGCheck.py 2018-04-17 12:22:20.681609697 -0400
@@ -9,7 +9,7 @@
import os
try:
from ConfigParser import RawConfigParser
-except:
+except ImportError:
from configparser import RawConfigParser
import AbstractCheck
diff -up rpmlint-rpmlint-1.10/Pkg.py.flake rpmlint-rpmlint-1.10/Pkg.py
--- rpmlint-rpmlint-1.10/Pkg.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/Pkg.py 2018-04-17 12:22:20.681609697 -0400
@@ -18,7 +18,7 @@ import sys
import tempfile
try:
from urlparse import urljoin
-except:
+except ImportError:
from urllib.parse import urljoin
try:
@@ -27,7 +27,7 @@ try:
_magic = magic.open(magic.MAGIC_NONE)
_ = _magic.descriptor # magic >= 5.05 needed
_magic.load()
-except:
+except ImportError:
_magic = None
import rpm
@@ -52,7 +52,7 @@ else:
try:
from shlex import quote as shquote
-except:
+except ImportError:
def shquote(s):
return '"%s"' % s
@@ -166,7 +166,7 @@ def is_utf8(fname):
def is_utf8_bytestr(s):
try:
s.decode('UTF-8')
- except:
+ except UnicodeError:
return False
return True
@@ -227,7 +227,7 @@ def get_default_valid_rpmgroups(filename
groupsfiles = [x for x in p.files() if x.endswith('/GROUPS')]
if groupsfiles:
filename = groupsfiles[0]
- except: # the rpm package might not be installed
+ except KeyError: # the rpm package might not be installed
pass
if filename and os.path.exists(filename):
with open(filename) as fobj:
@@ -532,7 +532,7 @@ class Pkg(AbstractPkg):
def __getitem__(self, key):
try:
val = self.header[key]
- except:
+ except KeyError:
val = []
if val == []:
return None
@@ -680,7 +680,7 @@ class Pkg(AbstractPkg):
magics = [b2s(x) for x in self.header[rpm.RPMTAG_FILECLASS]]
try: # rpm >= 4.7.0
filecaps = self.header[rpm.RPMTAG_FILECAPS]
- except:
+ except AttributeError:
filecaps = None
# rpm-python < 4.6 does not return a list for this (or FILEDEVICES,
@@ -915,9 +915,11 @@ class Pkg(AbstractPkg):
Depending on rpm-python version, the string may or may not include
interpreter arguments, if any.
"""
+ if which is None:
+ return ''
prog = self[which]
if prog is None:
- prog = ""
+ prog = ''
elif isinstance(prog, (list, tuple)):
# http://rpm.org/ticket/847#comment:2
prog = "".join(prog)
diff -up rpmlint-rpmlint-1.10/rpmlint.flake rpmlint-rpmlint-1.10/rpmlint
--- rpmlint-rpmlint-1.10/rpmlint.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/rpmlint 2018-04-17 12:22:20.682609674 -0400
@@ -20,7 +20,7 @@ import tempfile
try:
import importlib
-except: # Python < 2.7
+except ImportError: # Python < 2.7
importlib = None
import imp
diff -up rpmlint-rpmlint-1.10/SCLCheck.py.flake rpmlint-rpmlint-1.10/SCLCheck.py
--- rpmlint-rpmlint-1.10/SCLCheck.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/SCLCheck.py 2018-04-17 12:22:20.682609674 -0400
@@ -50,7 +50,7 @@ def index_or_sub(source, word, sub=0):
"""
try:
return source.index(word)
- except:
+ except ValueError:
return sub
diff -up rpmlint-rpmlint-1.10/SpecCheck.py.flake rpmlint-rpmlint-1.10/SpecCheck.py
--- rpmlint-rpmlint-1.10/SpecCheck.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/SpecCheck.py 2018-04-17 12:22:20.682609674 -0400
@@ -571,7 +571,7 @@ class SpecCheck(AbstractCheck.AbstractCh
try:
ts = rpm.TransactionSet()
spec_obj = ts.parseSpec(self._spec_file)
- except:
+ except rpm.error:
# errors logged above already
pass
if spec_obj:
diff -up rpmlint-rpmlint-1.10/ZipCheck.py.flake rpmlint-rpmlint-1.10/ZipCheck.py
--- rpmlint-rpmlint-1.10/ZipCheck.py.flake 2017-09-05 02:40:05.000000000 -0400
+++ rpmlint-rpmlint-1.10/ZipCheck.py 2018-04-17 12:22:20.682609674 -0400
@@ -43,6 +43,10 @@ class ZipCheck(AbstractCheck.AbstractChe
badcrc = z.testzip()
if badcrc:
printError(pkg, 'bad-crc-in-zip', badcrc, fname)
+ except zipfile.error:
+ printWarning(pkg, 'unable-to-read-zip', '%s: %s' %
+ (fname, sys.exc_info()[1]))
+ else:
compressed = False
for zinfo in z.infolist():
if zinfo.compress_type != zipfile.ZIP_STORED:
@@ -70,9 +74,6 @@ class ZipCheck(AbstractCheck.AbstractChe
if want_indexed_jars:
printWarning(pkg, 'jar-not-indexed', fname)
pass
- except:
- printWarning(pkg, 'unable-to-read-zip', '%s: %s' %
- (fname, sys.exc_info()[1]))
z and z.close()

View File

@ -1,36 +0,0 @@
From 7f86c79068be1c83303da30f5f4f030080e6326a Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Sat, 4 Nov 2017 02:24:30 +0100
Subject: [PATCH] Ignore useless-provides on debuginfo provides (#112)
Also flip to set's rather than lists as the main operation
here is lookup, so set()s should be faster.
---
TagsCheck.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/TagsCheck.py b/TagsCheck.py
index a8d87aa..dc890b1 100644
--- a/TagsCheck.py
+++ b/TagsCheck.py
@@ -823,11 +823,13 @@ class TagsCheck(AbstractCheck.AbstractCheck):
# TODO: should take versions, <, <=, =, >=, > into account here
# https://bugzilla.redhat.com/460872
- useless_provides = []
+ useless_provides = set()
for p in prov_names:
- if prov_names.count(p) != 1 and p not in useless_provides:
- useless_provides.append(p)
- for p in useless_provides:
+ if (prov_names.count(p) != 1 and
+ not p.startswith('debuginfo(') and
+ p not in useless_provides):
+ useless_provides.add(p)
+ for p in sorted(useless_provides):
printError(pkg, 'useless-provides', p)
for p in pkg.provides():
--
2.17.0

View File

@ -1,44 +0,0 @@
From 3a072351314c3a3ec11650ad8efd2fc6ececf987 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Sat, 4 Nov 2017 02:17:52 +0100
Subject: [PATCH] Properly handle the exception on missing files
Missing files raises a FileNotFoundError, not OSError. Also
simplify logic.
(cherry picked from commit d59bc2a1e2698040553c09610cb2befa1ef8d76a)
---
Pkg.py | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/Pkg.py b/Pkg.py
index e257243..01d0289 100644
--- a/Pkg.py
+++ b/Pkg.py
@@ -714,20 +714,15 @@ class Pkg(AbstractPkg):
pkgfile.magic = "symbolic link to `%s'" % pkgfile.linkto
elif not pkgfile.size:
pkgfile.magic = 'empty'
- if not pkgfile.magic and _magic:
+ if (not pkgfile.magic and
+ not pkgfile.is_ghost and _magic):
# file() method evaluates every file twice with python2,
# use descriptor() method instead
try:
fd = os.open(pkgfile.path, os.O_RDONLY)
- except OSError:
- if not pkgfile.is_ghost:
- raise
- else:
pkgfile.magic = b2s(_magic.descriptor(fd))
- # libmagic up to 5.18 already closes the descriptor
- try:
os.close(fd)
- except OSError:
+ except FileNotFoundError:
pass
if pkgfile.magic is None:
pkgfile.magic = ''
--
2.17.0

View File

@ -1,13 +0,0 @@
diff --git a/FilesCheck.py b/FilesCheck.py
index c8666b9..78b22ef 100644
--- a/FilesCheck.py
+++ b/FilesCheck.py
@@ -331,7 +331,7 @@ def peek(filename, pkg, length=1024):
'3.4': [3310],
'3.5': [3350, 3351], # 3350 for < 3.5.2
'3.6': [3379],
- '3.7': [3390],
+ '3.7': [3390, 3391, 3392, 3393, 3394],
}

View File

@ -1,57 +0,0 @@
diff -up rpmlint-rpmlint-1.10/FilesCheck.py.py37mtime rpmlint-rpmlint-1.10/FilesCheck.py
--- rpmlint-rpmlint-1.10/FilesCheck.py.py37mtime 2018-06-02 14:29:53.035453468 -0400
+++ rpmlint-rpmlint-1.10/FilesCheck.py 2018-06-02 14:32:55.430860108 -0400
@@ -377,6 +377,27 @@ def py_demarshal_long(b):
return (b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24))
+def pyc_magic_from_chunk(chunk):
+ """From given chunk (beginning of the file), return Python magic number"""
+ return py_demarshal_long(chunk[:4]) & 0xffff
+
+
+def pyc_mtime_from_chunk(chunk):
+ """From given chunk (beginning of the file), return mtime or None
+
+ From Python 3.7, mtime is not always present.
+
+ See https://www.python.org/dev/peps/pep-0552/#specification
+ """
+ magic = pyc_magic_from_chunk(chunk)
+ second = py_demarshal_long(chunk[4:8])
+ if magic >= _python_magic_values['3.7'][0]:
+ if second == 0:
+ return py_demarshal_long(chunk[8:12])
+ return None # No mtime saved, TODO check hashes instead
+ return second
+
+
def python_bytecode_to_script(path):
"""
Given a python bytecode path, give the path of the .py file
@@ -729,7 +750,7 @@ class FilesCheck(AbstractCheck.AbstractC
if chunk:
# Verify that the magic ABI value embedded in the
# .pyc header is correct
- found_magic = py_demarshal_long(chunk[:4]) & 0xffff
+ found_magic = pyc_magic_from_chunk(chunk)
exp_magic, exp_version = get_expected_pyc_magic(f)
if exp_magic and found_magic not in exp_magic:
found_version = 'unknown'
@@ -752,13 +773,14 @@ class FilesCheck(AbstractCheck.AbstractC
# Verify that the timestamp embedded in the .pyc
# header matches the mtime of the .py file:
- pyc_timestamp = py_demarshal_long(chunk[4:8])
+ pyc_timestamp = pyc_mtime_from_chunk(chunk)
# If it's a symlink, check target file mtime.
srcfile = pkg.readlink(files[source_file])
if not srcfile:
printWarning(
pkg, 'python-bytecode-without-source', f)
- elif pyc_timestamp != srcfile.mtime:
+ elif (pyc_timestamp is not None and
+ pyc_timestamp != srcfile.mtime):
cts = datetime.fromtimestamp(
pyc_timestamp).isoformat()
sts = datetime.fromtimestamp(

View File

@ -22,27 +22,14 @@
%endif
Name: rpmlint
Version: 1.10
Release: 22%{?dist}
Version: 1.11
Release: 1%{?dist}
Summary: Tool for checking common errors in RPM packages
License: GPLv2
URL: https://github.com/rpm-software-management/rpmlint
Source0: https://github.com/rpm-software-management/rpmlint/archive/rpmlint-%{version}.tar.gz
Source1: %{name}.config
Source3: %{name}-etc.config
# https://github.com/rpm-software-management/rpmlint/commit/e739876
Patch0: rpmlint-1.10-ignore-debuginfo-useless-provides.patch
# https://github.com/rpm-software-management/rpmlint/commit/b748e6fadb8e68df2aa679ccf62822ad56577b80
# https://github.com/rpm-software-management/rpmlint/commit/c1945e37e2989364c5caedc05aa429a5c2d39f4d
# https://github.com/rpm-software-management/rpmlint/commit/f267bf1c60d067436b360c68d8e956876758b268
Patch1: rpmlint-1.10-flake-cleanups.patch
# https://github.com/rpm-software-management/rpmlint/commit/d59bc2a
Patch2: rpmlint-1.10-missing-files-exception.patch
# https://github.com/rpm-software-management/rpmlint/commit/e52dcc73bab5c4310e9bb773e6aedea020e340ff
Patch3: rpmlint-1.10-py37mtime.patch
# https://github.com/rpm-software-management/rpmlint/commit/52b715763217bbc1cfcad9bba8e6a446e820690e
# https://github.com/rpm-software-management/rpmlint/commit/78e073e2a5a09bbd8206b52578fd29bd53ff1065
Patch4: rpmlint-1.10-py37magic.patch
BuildArch: noarch
%if %{with python3}
BuildRequires: python3-devel
@ -95,11 +82,6 @@ and source packages as well as spec files can be checked.
%prep
%setup -q -n %{name}-%{name}-%{version}
%patch0 -p1 -b .debuginfo-useless-provides
%patch1 -p1 -b .flake
%patch2 -p1 -b .missing-files
%patch3 -p1 -b .py37mtime
%patch4 -p1 -b .py37magic
%if %{with python3}
%patch5 -p1
%patch6 -p1
@ -146,6 +128,9 @@ make check PYTHON=%{python} PYTEST=%{pytest} FLAKE8=%{flake8}
%{_mandir}/man1/rpmlint.1*
%changelog
* Fri Jun 21 2019 Tom Callaway <spot@fedoraproject.org> - 1.11-1
- update to 1.11
* Sun Mar 10 2019 Miro Hrončok <mhroncok@redhat.com> - 1.10-22
- Suppress locale error in order to work in default mock (#1668400)

View File

@ -1 +1 @@
SHA512 (rpmlint-1.10.tar.gz) = e2d4a5189f13ba7f12af9b72955bb355e2a384f3130fd12a452b81f19126b66496b84ce7cc8cb17c449b793fe8ff574297b26be50a84668a1cfe736aa304f974
SHA512 (rpmlint-1.11.tar.gz) = bff01e742103fa030996e7198e58f41a4ede8ae650b4a4835dbf9c7b9edc3838f6867414cc758978ec865113caa00b19bb8189ac887f31261d541b74d2a9c51b