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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2024-03-01 10:20:49 +01:00
commit 1cf0ae1d4e

View file

@ -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