diff --git a/brp-fix-pyc-reproducibility b/brp-fix-pyc-reproducibility new file mode 100644 index 0000000..4118d97 --- /dev/null +++ b/brp-fix-pyc-reproducibility @@ -0,0 +1,18 @@ +#!/bin/bash -e + +# If using normal root, avoid changing anything. +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi + +# Defined as %py_reproducible_pyc_path macro and passed here as +# the first command-line argument +path_to_fix=$1 + +# First, check that the parser is available: +if [ ! -x /usr/bin/marshalparser ]; then + echo "ERROR: If %py_reproducible_pyc_path is defined, you have to also BuildRequire: /usr/bin/marshalparser !" + exit 1 +fi + +find "$path_to_fix" -type f -name "*.pyc" | xargs /usr/bin/marshalparser --fix --overwrite diff --git a/macros b/macros index 6bf915f..20396fb 100644 --- a/macros +++ b/macros @@ -233,6 +233,7 @@ print(result) %__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} %__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip} %__brp_python_bytecompile /usr/lib/rpm/redhat/brp-python-bytecompile "" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}" +%__brp_fix_pyc_reproducibility /usr/lib/rpm/redhat/brp-fix-pyc-reproducibility %__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink # __brp_mangle_shebangs_exclude - shebangs to exclude # __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude @@ -250,6 +251,7 @@ print(result) %{?__brp_strip_lto} \ %{?__brp_strip_static_archive} \ %{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \ + %{?py_reproducible_pyc_path:%{?__brp_fix_pyc_reproducibility} "%{py_reproducible_pyc_path}"} \ %{?__brp_python_hardlink} \ %{?__brp_mangle_shebangs} \ %{nil} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 2a657a4..7cd0eaa 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,8 +6,8 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 161 -Release: 2%{?dist} +Version: 162 +Release: 1%{?dist} # No version specified. License: GPL+ URL: https://src.fedoraproject.org/rpms/redhat-rpm-config @@ -53,6 +53,10 @@ Source201: brp-mangle-shebangs # however, now we can do Fedora changes within Source202: brp-python-bytecompile +# for fixing pyc files reproducibility with marshalparser +# https://github.com/fedora-python/marshalparser +Source203: brp-fix-pyc-reproducibility + # Dependency generator scripts (deprecated) Source300: find-provides Source301: find-provides.ksyms @@ -207,6 +211,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Thu Jul 16 2020 Lumír Balhar - 162-1 +- New script brp-fix-pyc-reproducibility + * Tue Jun 16 2020 Lumír Balhar - 161-2 - Use stdlib compileall for Python >= 3.9