# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 # Strip ELF Binaries and Libraries strip_bins() { 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 ( cd $PKG_DIR 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 [[ $COMPRESS_BINS = "YES" ]] && compress_bins fi } # compress binaries with upx if requested and available compress_bins() { if [[ "$FAILED" = "" ]] ; then [[ $COMPRESS_BINS = "YES" ]] && [[ $(which upx) ]] && { cd $PKG_DIR ; for d in $BIN_DIRS ; do [[ -d $d ]] && { for f in $(ls $d) ; do [[ "$(file $f |grep 'ELF')" ]] && continue || { echo $CYAN"NOTE- "$NORMAL"Attempting to compress binary file ""$BLUE""$d/$f""$NORMAL" echo "upx won't compress files smaller than about 50K." echo "Be aware that files compressed with UPX normally show a corrupt header." [[ $QUIET != "YES" ]] && upx $d/$f \ || upx $d/$f 2> /dev/null 1> /dev/null } done } done } fi }