redhat-rpm-config/brp-python-hardlink
Toshio Kuratomi f40ecfaa06 Add patch from https://bugzilla.redhat.com/show_bug.cgi?id=783433
to fix spaces in files and directories that are fed to the
brp-python-hardlink script
2014-01-25 00:35:32 +02:00

20 lines
686 B
Bash
Executable File

#!/bin/sh
# If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
exit 0
fi
# Hardlink identical *.pyc and *.pyo, originally from PLD's rpm-build-macros
# Modified to use sha1sum instead of cmp to avoid a diffutils dependency.
find "$RPM_BUILD_ROOT" -type f -name "*.pyc" | while read pyc ; do
pyo="$(echo $pyc | sed -e 's/.pyc$/.pyo/')"
if [ -f "$pyo" ] ; then
csha="$(sha1sum -b "$pyc" | cut -d' ' -f 1)" && \
osha="$(sha1sum -b "$pyo" | cut -d' ' -f 1)" && \
if [ "$csha" = "$osha" ] ; then
ln -f "$pyc" "$pyo"
fi
fi
done