+#-----------------------------------------------------------------
+# remove all RPATH from executable binaries and shared object files
+#
+# Requires: find, awk, cut, xargs, chrpath, uname
+#
+#%no_install_post_chrpath 1
+%__spec_install_post_chrpath {%{!?debug: \
+%{!?no_install_post_chrpath: \
+ %{?verbose:set -x;} \
+echo "Remove RPATH from executable binaries and shared object files."; \
+if [ "$(uname -m)" != alpha ] ; then \
+find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" | xargs -r file | \
+ awk '/ELF.*(executable|shared object)/ {print $1}' | cut -d: -f1 | \
+while read file ; do \
+ rpath= ; \
+ chmod u+w "$file"; \
+ for dir in `chrpath -l "$file" | \
+ awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
+ case $dir in \
+ /home/* | /tmp/* | /usr/lib | /lib | /usr/local/lib | /usr/X11R6/lib ) \
+ echo "remove-rpath: $dir in $file"; \
+ ;; \
+ * ) \
+ if [ "$rpath" = "" ] ; then rpath="$dir" ; \
+ else rpath="$rpath:$dir" ; fi ; \
+ ;; \
+ esac ; \
+ done ; \
+ if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
+ else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
+done; fi; } \
+} }
+#-----------------------------------------------------------------
+# Find and gzip all kernel modules
+#
+# Requires: find
+#
+#%no_install_post_compress_modules 1
+%__spec_install_post_compress_modules { \
+%{!?no_install_post_compress_modules: \
+echo "Compress kernel modules if any."; \
+ %{?verbose:set -x;} \
+ if test -d $RPM_BUILD_ROOT/lib/modules ; then \
+ find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
+ xargs -r %{__gzip} -9nf; \
+ find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
+ while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
+ fi; \
+} }