7d233e
#!/bin/bash
7d233e
7d233e
# If using normal root, avoid changing anything.
7d233e
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
7d233e
        exit 0
7d233e
fi
7d233e
7d233e
tempdir=`mktemp -d /tmp/implant-ident-XXXXXX`
7d233e
if test -z "$tempdir" ; then
7d233e
	exit 1
7d233e
fi
7d233e
7d233e
cleanup() {
7d233e
	rm -f $tempdir/*
7d233e
	rmdir $tempdir
7d233e
}
7d233e
trap cleanup 0 1 2 3 4 5 6 7 8 9 11 13 14 15
7d233e
7d233e
for library in `find $RPM_BUILD_ROOT -type f -exec file \{\} \; | grep 'current ar archive' | sed 's,:.*,,g' ` ; do
7d233e
	pushd $tempdir > /dev/null
7d233e
	if test -n "$RPM_BUILD_ROOT" ; then
7d233e
		cleanedlibrary=`echo "$library" | sed s,"$RPM_BUILD_ROOT",,g`
7d233e
	else
7d233e
		cleanedlibrary="$library"
7d233e
	fi
7d233e
	ar x "$library"
7d233e
	for object in *.o ; do
7d233e
		echo '$RPM: '${RPM_PACKAGE_NAME:-UNKNOWN_NAME}-${RPM_PACKAGE_VERSION:-UNKNOWN_VERSION}-${RPM_PACKAGE_RELEASE:-UNKNOWN_RELEASE}:"$cleanedlibrary":"$object"' $' > __x_rpm_ident_string.txt
7d233e
		objcopy --add-section .rodata=__x_rpm_ident_string.txt "$object"
7d233e
		ar r "$library" "$object"
7d233e
	done
7d233e
	rm -f *.o
7d233e
	popd > /dev/null
7d233e
done