2010-01-27 20:03:10 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# If using normal root, avoid changing anything.
|
2019-08-09 22:30:43 +08:00
|
|
|
if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then
|
2010-01-27 20:03:10 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-09-22 20:18:39 +08:00
|
|
|
hardlink_if_same() {
|
2015-11-14 01:15:23 +08:00
|
|
|
if cmp -s "$1" "$2" ; then
|
2015-09-22 20:18:39 +08:00
|
|
|
ln -f "$1" "$2"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Hardlink identical *.pyc, *.pyo, and *.opt-[12].pyc.
|
|
|
|
# Originally from PLD's rpm-build-macros
|
|
|
|
find "$RPM_BUILD_ROOT" -type f -name "*.pyc" -not -name "*.opt-[12].pyc" | while read pyc ; do
|
|
|
|
hardlink_if_same "$pyc" "${pyc%c}o"
|
|
|
|
o1pyc="${pyc%pyc}opt-1.pyc"
|
|
|
|
hardlink_if_same "$pyc" "$o1pyc"
|
|
|
|
o2pyc="${pyc%pyc}opt-2.pyc"
|
|
|
|
hardlink_if_same "$pyc" "$o2pyc" || hardlink_if_same "$o1pyc" "$o2pyc"
|
2010-01-27 20:03:10 +08:00
|
|
|
done
|
2016-04-14 20:11:39 +08:00
|
|
|
exit 0
|