csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
#!/bin/sh
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
STRIP=${1:-strip}
2ff057
OBJDUMP=${2:-objdump}
2ff057
2ff057
case `uname -a` in
2ff057
Darwin*) exit 0 ;;
2ff057
*) ;;
2ff057
esac
2ff057
2ff057
# Strip .comment and .note sections (the latter only if it is not allocated)
2ff057
# for already stripped elf files in the build root
2ff057
for f in `find "$RPM_BUILD_ROOT" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
2ff057
        grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
2ff057
	sed -n -e 's/^\(.*\):[ 	]*ELF.*, stripped.*/\1/p'`; do
2ff057
	note="-R .note"
2ff057
	if $OBJDUMP -h $f | grep '^[ 	]*[0-9]*[ 	]*.note[ 	]' -A 1 | \
2ff057
		grep ALLOC >/dev/null; then
2ff057
		note=
2ff057
	fi
2ff057
	$STRIP -R .comment $note "$f" || :
2ff057
done