# This file is part of the src2pkg program: # Copyright 2005-2009 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 # Strip ELF Binaries and Libraries strip_bins() { if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any pre-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/10.pre ]] && . "$HOME"/.src2pkg/extensions/10.pre fi if [[ "$FAILED" = "" ]] ; then if [[ $STRIP_BINS = "YES" ]] ; then cd "$PKG_DIR" ; if [[ $(find . | xargs -r file | grep "executable" | grep ELF) ]] ; then echo -n $BLUE"Stripping ELF binaries - "$NORMAL find . | xargs -r file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip $BIN_STRIP_COMMAND 2> /dev/null echo $GREEN"Done"$NORMAL else ! [[ $QUIET = "YES" ]] && echo "No unstripped ELF binaries were found. "$BLUE"Skipping..."$NORMAL fi fi if [[ $STRIP_LIBS = "YES" ]] ; then cd "$PKG_DIR" ; if [[ $(find . | xargs -r file | grep "current ar archive") ]] ; then echo -n $BLUE"Stripping static archives - "$NORMAL find . | xargs -r file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip -p --strip-debug 2> /dev/null echo $GREEN"Done"$NORMAL else ! [[ $QUIET = "YES" ]] && echo "No unstripped static archives found. "$BLUE"Skipping..."$NORMAL fi if [[ $(find . | xargs -r file | grep "not stripped" | grep shared | grep ELF ) ]] \ || [[ $(find . | xargs -r file | grep "not stripped" | grep relocatable | grep ELF ) ]] ; then echo -n $BLUE"Stripping shared libraries - "$NORMAL find . | xargs -r file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs -r strip $LIB_STRIP_COMMAND 2> /dev/null find . | xargs -r file | grep "relocatable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs -r strip $LIB_STRIP_COMMAND 2> /dev/null echo $GREEN"Done"$NORMAL else ! [[ $QUIET = "YES" ]] && echo "No unstripped shared libraries found. "$BLUE"Skipping..."$NORMAL fi fi if [[ $STRIP_HARD = "YES" ]] ; then cd "$PKG_DIR" ; # Strip .comment and .note sections (the latter only if it is not allocated) # for already stripped elf files in the PKG_DIR (code taken from rpm) #for f in `find "$PKG_DIR" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \ #sed -n -e 's/^\(.*\):[ ]*ELF.*, stripped/\1/p'`; do for f in $(find "$PKG_DIR" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \ sed -n -e 's/^\(.*\):[ ]*ELF.*, stripped/\1/p') ; do note="-R .note" if objdump -h $f | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | \ grep ALLOC >/dev/null; then note= fi strip -R .comment $note $f || : strip -R .compact_rel $note $f || : done fi # this has been moved to make_doinst so that bins are only compressed after # generating any dependency info -upx'd binaries are shown as statically linked #if [[ $COMPRESS_BINS = "YES" ]] || [[ $SAVE_SPACE -gt 2 ]] ; then # compress_bins #fi fi if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any post-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/10.post ]] && . "$HOME"/.src2pkg/extensions/10.post fi } # end strip_bins