2010-01-27 20:03:10 +08:00
|
|
|
#!/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
|
2010-02-04 05:15:31 +08:00
|
|
|
pyo="${pyc%c}o"
|
2010-01-27 20:03:10 +08:00
|
|
|
if [ -f "$pyo" ] ; then
|
2012-04-23 20:35:29 +08:00
|
|
|
csha="$(sha1sum -b "$pyc" | cut -d' ' -f 1)" && \
|
|
|
|
osha="$(sha1sum -b "$pyo" | cut -d' ' -f 1)" && \
|
2010-01-27 20:03:10 +08:00
|
|
|
if [ "$csha" = "$osha" ] ; then
|
|
|
|
ln -f "$pyc" "$pyo"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|