csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
#!/bin/sh
2ff057
2ff057
# If using normal root, avoid changing anything.
2ff057
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
2ff057
	exit 0
2ff057
fi
2ff057
2ff057
hardlink_if_same() {
2ff057
	if cmp -s "$1" "$2" ; then
2ff057
		ln -f "$1" "$2"
2ff057
		return 0
2ff057
	fi
2ff057
	return 1
2ff057
}
2ff057
2ff057
# Hardlink identical *.pyc, *.pyo, and *.opt-[12].pyc.
2ff057
# Originally from PLD's rpm-build-macros
2ff057
find "$RPM_BUILD_ROOT" -type f -name "*.pyc" -not -name "*.opt-[12].pyc" | while read pyc ; do
2ff057
	hardlink_if_same "$pyc" "${pyc%c}o"
2ff057
	o1pyc="${pyc%pyc}opt-1.pyc"
2ff057
	hardlink_if_same "$pyc" "$o1pyc"
2ff057
	o2pyc="${pyc%pyc}opt-2.pyc"
2ff057
	hardlink_if_same "$pyc" "$o2pyc" || hardlink_if_same "$o1pyc" "$o2pyc"
2ff057
done
2ff057
exit 0