X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fstripper;h=ac5f58ca50cb76f858de26c3108d741cb5f87d65;hb=8d6012f0f54455f0b693f9d8f711ddc731e9051c;hp=2b4feafe9063c50bf0c01795bd8ea887fcf21e19;hpb=c7f9e0e99c67ed945d1c170d0329ed1b7ad02249;p=ipfire-2.x.git diff --git a/src/stripper b/src/stripper index 2b4feafe90..ac5f58ca50 100755 --- a/src/stripper +++ b/src/stripper @@ -1,4 +1,4 @@ -#!/tools/bin/bash +#!/usr/bin/env bash dirs="" excludes="/dev /proc /sys /run" @@ -17,7 +17,7 @@ done function _strip() { local file=${1} - local cmd="${STRIP-strip}" + local strip="${STRIP-strip}" local exclude l for exclude in ${excludes}; do @@ -27,31 +27,33 @@ function _strip() { fi done + local cmd=( "${strip}" ) + case "$(file -bi ${file})" in - application/x-sharedlib*|application/x-archive*) - cmd="${cmd} --strip-debug --remove-section=.comment --remove-section=.note" + application/x-archive*) + cmd+=( "--strip-debug" "--remove-section=.comment" "--remove-section=.note" ) ;; *) - cmd="${cmd} --strip-unneeded" + cmd+=( "--strip-all" ) ;; esac echo "Stripping ${file}..." - ${cmd} ${file} + ${cmd[*]} ${file} } for dir in ${dirs}; do # Strip shared objects. find ${dir} -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \ - | file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped/\1/p' | + | file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' | while read file; do - _strip ${file} - done + _strip ${file} || exit $? + done || exit $? # Strip static archives. find ${dir} -name \*.a -a -exec file {} \; \ | grep 'current ar archive' | sed -n -e 's/^\(.*\):[ ]*current ar archive/\1/p' | while read file; do - _strip ${file} - done + _strip ${file} || exit $? + done || exit $? done