diff --git a/brp-fix-pyc-reproducibility b/brp-fix-pyc-reproducibility index 8047890..95e481b 100644 --- a/brp-fix-pyc-reproducibility +++ b/brp-fix-pyc-reproducibility @@ -5,14 +5,23 @@ if [ -z "${RPM_BUILD_ROOT:-}" ] || [ "${RPM_BUILD_ROOT:-}" = "/" ]; then exit 0 fi -# Defined as %py_reproducible_pyc_path macro and passed here as -# the first command-line argument +automatic= +if [ "${1:?}" = "-a" ]; then + automatic=yes + shift +fi + 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 + if [ -n "$automatic" ]; then + echo "WARNING: marshalparser is not installed" + exit 0 + else + echo "ERROR: marshalparser is not installed" + exit 1 + fi fi # Set pipefail so if $path_to_fix does not exist, the build fails diff --git a/macros.python-srpm b/macros.python-srpm index 278571f..490f91e 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -77,6 +77,9 @@ ## https://fedoraproject.org/wiki/Changes/ReproducibleBuildsClampMtimes#Python_bytecode %__env_unset_source_date_epoch_if_not_clamp_mtime %[0%{?clamp_mtime_to_source_date_epoch} == 0 ? "env -u SOURCE_DATE_EPOCH" : "env"] +## Automatically apply __brp_fix_pyc_reproducibility +%py_fix_reproducibility 1 + ## The individual BRP scripts %__brp_python_bytecompile %{__env_unset_source_date_epoch_if_not_clamp_mtime} %{_rpmconfigdir}/redhat/brp-python-bytecompile "" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}" "%{?_smp_build_ncpus:-j%{_smp_build_ncpus}}" %__brp_fix_pyc_reproducibility %{_rpmconfigdir}/redhat/brp-fix-pyc-reproducibility @@ -89,7 +92,8 @@ # 3. brp-python-hardlink de-duplicates identical pyc files %__os_install_post_python \ %{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \ - %{?py_reproducible_pyc_path:%{?__brp_fix_pyc_reproducibility} "%{py_reproducible_pyc_path}"} \ + %{?py_fix_reproducibility:%{__brp_fix_pyc_reproducibility} -a "%{buildroot}%{_prefix}"} \ + %{?py_reproducible_pyc_path:%{__brp_fix_pyc_reproducibility} "%{py_reproducible_pyc_path}"} \ %{?__brp_python_hardlink} \ %{nil} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 06fc622..dcdd307 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -3,6 +3,8 @@ Summary: The common Python RPM macros URL: https://src.fedoraproject.org/rpms/python-rpm-macros/ +%bcond bootstrap 0 + # Macros: Source101: macros.python Source102: macros.python-srpm @@ -53,7 +55,7 @@ elseif posix.stat('macros.python-srpm') then end } Version: %{__default_python3_version} -Release: 7%{?dist} +Release: 8%{?dist} BuildArch: noarch @@ -82,6 +84,10 @@ Summary: RPM macros for building Python source packages # For directory structure and flags macros # Versions before 190 contained some brp scripts moved into python-srpm-macros Requires: redhat-rpm-config >= 190 +# Require marshalparser if we're not bootstrapping and python3 is installed +%if %{without bootstrap} +Requires: (marshalparser if python3) +%endif # We bundle our own software here :/ Provides: bundled(python3dist(compileall2)) = %{compileall2_version} @@ -163,6 +169,10 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true %changelog +* Fri Mar 1 2024 Zbigniew Jedrzejewski-Szmek - 3.12-8 +- Call %%__brp_fix_pyc_reproducibility for all .pyc files under /usr + (rhbz#2266767) + * Thu Jan 25 2024 Miro HronĨok - 3.12-7 - %%py3_test_envvars: Only set $PYTEST_XDIST_AUTO_NUM_WORKERS if not already set