diff --git a/rpmlint-1.10-py37mtime.patch b/rpmlint-1.10-py37mtime.patch new file mode 100644 index 0000000..ded068d --- /dev/null +++ b/rpmlint-1.10-py37mtime.patch @@ -0,0 +1,57 @@ +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( diff --git a/rpmlint.spec b/rpmlint.spec index e620240..a11ce57 100644 --- a/rpmlint.spec +++ b/rpmlint.spec @@ -16,7 +16,7 @@ Name: rpmlint Version: 1.10 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Tool for checking common errors in RPM packages Group: Development/Tools License: GPLv2 @@ -36,6 +36,8 @@ Patch0: rpmlint-1.10-ignore-debuginfo-useless-provides.patch 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 BuildArch: noarch %if %{with python3} BuildRequires: python3-devel @@ -89,6 +91,7 @@ and source packages as well as spec files can be checked. %patch0 -p1 -b .debuginfo-useless-provides %patch1 -p1 -b .flake %patch2 -p1 -b .missing-files +%patch3 -p1 -b .py37mtime sed -i -e /MenuCheck/d Config.py cp -p config config.example install -pm 644 %{SOURCE3} config @@ -138,6 +141,9 @@ make check PYTHON=%{python} PYTEST=%{pytest} FLAKE8=%{flake8} %{_mandir}/man1/rpmlint.1* %changelog +* Sat Jun 2 2018 Tom Callaway 1.10-13 +- apply upstream fix for python 3.7 mtime handling + * Thu May 03 2018 Todd Zullinger - 1.10-12 - Properly handle the exception on missing files (bz1574509) - Explicitly disable the non-standard-group check