From 1cf0ae1d4e4d0ac85258004df66d9fa8a42e7327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 1 Mar 2024 10:20:49 +0100 Subject: [PATCH] brp-fix-pyc-reproducibility: suppress python2 files and errors When %{py_reproducible_pyc_path} is used explicitly, then error our if marshalparser returns an error. But when running in the automatic mode, only warn. marshalparser fails for example for python2 pyc files. Also, filter out the python2.7 directory. In Fedora, it's the major and only source of python2 pyc files and it doesn't make much sense to try to do anything with them. --- brp-fix-pyc-reproducibility | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/brp-fix-pyc-reproducibility b/brp-fix-pyc-reproducibility index 95e481b..c6c674d 100644 --- a/brp-fix-pyc-reproducibility +++ b/brp-fix-pyc-reproducibility @@ -26,4 +26,18 @@ fi # Set pipefail so if $path_to_fix does not exist, the build fails set -o pipefail -find "$path_to_fix" -type f -name "*.pyc" -print0 | xargs -0 /usr/bin/marshalparser --fix --overwrite + +extra=() +if [ -n "$automatic" ]; then + extra+=(-name "python2.7" -prune -o) +fi + +# Unset -e so that we can collect the return code below +set +e +find "$path_to_fix" "${extra[@]}" -type f -name "*.pyc" -print0 | xargs -0 /usr/bin/marshalparser --fix --overwrite +ret=$? +if [ "$ret" -eq 123 ]; then + echo "WARNING: some marshalparser invocations failed" + [ -n "$automatic" ] && exit 0 +fi +exit $ret