Skip to content

Commit

Permalink
Use file to detect perl scripts and strippability
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Oct 31, 2023
1 parent fb41311 commit 3b18563
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions microminc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==========

Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 3b18563

Please sign in to comment.