From cdb9ab9892775bd8903c0030bef86f009026f4ab Mon Sep 17 00:00:00 2001 From: Hung-I Wang Date: Mon, 23 Sep 2019 21:41:47 +0800 Subject: [PATCH] Avoid striping binaries incorrectly by detecting architecture: UNKNOWN reports --- ci/before_deploy.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh index c8a8a2d..87251f3 100644 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -4,9 +4,12 @@ set -ex try_compress() { file=$1 - target=$(objdump -a $file | grep -oP "(?<=format )[\w-]+" | tr -d '\n' || "") - if [ -n "$target" ] && strip -v $file --target $target; then - echo "Stripped $file (target: $target)." + header=$(objdump -f $file) + if ! echo $header | grep -P "architecture: \s*UNKNOWN" ; then + target=$(echo $header| grep -oP "(?<=format )\s*[\w-]+" | tr -d '\n' || "") + if [ -n "$target" ] && strip -v $file --target $target; then + echo "Stripped $file (target: $target)." + fi fi if upx $file; then echo "Upx $file done."