diff --git a/Dockerfile b/Dockerfile index 6593b90..970a012 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM docker.io/fnndsc/civet:unofficial RUN apt-get update \ - && apt-get install -y binutils + && apt-get install -y binutils file COPY microminc.sh /usr/local/bin/microminc.sh diff --git a/microminc.sh b/microminc.sh index 46ca4a1..1ba59b5 100755 --- a/microminc.sh +++ b/microminc.sh @@ -40,6 +40,14 @@ function called_bins_of () { | grep "$MNIBASEPATH/bin" } +function is_perl_script () { + file "$(which "$1")" | grep -q 'Perl script text executable' +} + +function should_strip () { + file "$(which "$1")" | grep -q 'ELF .* executable.*not stripped' +} + # ARGUMENTS # ========== @@ -75,7 +83,7 @@ perl_scripts=() for prog in "$@"; do if [ "$prog" = "$last_arg" ]; then break - elif [[ "$prog" = *.pl ]]; then + elif is_perl_script "$prog"; then perl_scripts+=("$prog") else bin_progs+=("$prog") @@ -99,7 +107,10 @@ for prog in "${bin_progs[@]}"; do fi dst="$output_dir/bin/$(basename $prog)" cp -vu "$(which $prog)" "$dst" - strip --verbose "$dst" || echo "not stripping $dst" + + if should_strip "$dst"; then + strip --verbose "$dst" + fi done if [ -n "$(find "$output_dir/bin" -name '*.pl' | head)" ]; then