Skip to content

Commit

Permalink
Make sure libs are unique before copying (#74)
Browse files Browse the repository at this point in the history
* Make sure libs are unique before copying

* fix i iterator
  • Loading branch information
agouin committed Jan 20, 2023
1 parent 8fec180 commit b1e586a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
27 changes: 18 additions & 9 deletions dockerfile/rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,31 @@ RUN apt update && apt install -y libssl1.1 openssl clang libstdc++6
COPY --from=build-env /root/bin /root/bin
RUN mkdir -p /root/lib_abs && touch /root/lib_abs.list
RUN bash -c \
'ls /root/bin; \
for BIN in /root/bin/*; do \
'i=0; for BIN in /root/bin/*; do \
echo "Getting $(uname -m) libs for bin: $BIN"; \
readarray -t LIBS < <(ldd "$BIN"); \
i=0; for LIB in "${LIBS[@]}"; do \
for LIB in "${LIBS[@]}"; do \
PATH1=$(echo $LIB | awk "{print \$1}") ; \
if [ "$PATH1" = "linux-vdso.so.1" ]; then continue; fi; \
PATH2=$(echo $LIB | awk "{print \$3}") ; \
if [ ! -z "$PATH2" ]; then \
echo "Copying $(uname -m) lib2: $PATH2"; \
cp $PATH2 /root/lib_abs/$i ; \
echo $PATH2 >> /root/lib_abs.list; \
if cat /root/lib_abs.list | grep -x "$PATH2"; then \
echo "Skipping $PATH2, already accounted for"; \
continue; \
else \
echo "Copying lib2: $PATH2"; \
cp -L $PATH2 /root/lib_abs/$i ; \
echo $PATH2 >> /root/lib_abs.list; \
fi; \
else \
echo "Copying $(uname -m) lib1: $PATH1"; \
cp $PATH1 /root/lib_abs/$i ; \
echo $PATH1 >> /root/lib_abs.list; \
if cat /root/lib_abs.list | grep -x "$PATH1"; then \
echo "Skipping $PATH1, already accounted for"; \
continue; \
else \
echo "Copying lib1: $PATH1"; \
cp -L $PATH1 /root/lib_abs/$i ; \
echo $PATH1 >> /root/lib_abs.list; \
fi; \
fi; \
((i = i + 1)) ;\
done; \
Expand Down
24 changes: 18 additions & 6 deletions dockerfile/rust/native.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ENV BINARIES_ENV ${BINARIES}
RUN bash -c \
'export ARCH=$(uname -m); \
IFS=, read -ra BINARIES_ARR <<< "$BINARIES_ENV"; \
for BINARY in "${BINARIES_ARR[@]}"; do \
i=0; for BINARY in "${BINARIES_ARR[@]}"; do \
IFS=: read -ra BINSPLIT <<< "$BINARY"; \
BINPATH=${BINSPLIT[1]} ;\
BIN="$(eval "echo "${BINSPLIT[0]}"")"; \
Expand All @@ -70,16 +70,28 @@ RUN bash -c \
cp "$BIN" /root/bin/ ; \
fi; \
readarray -t LIBS < <(ldd "$BIN"); \
i=0; for LIB in "${LIBS[@]}"; do \
for LIB in "${LIBS[@]}"; do \
PATH1=$(echo $LIB | awk "{print \$1}") ; \
if [ "$PATH1" = "linux-vdso.so.1" ]; then continue; fi; \
PATH2=$(echo $LIB | awk "{print \$3}") ; \
if [ ! -z "$PATH2" ]; then \
cp $PATH2 /root/lib_abs/$i ; \
echo $PATH2 >> /root/lib_abs.list; \
if cat /root/lib_abs.list | grep -x "$PATH2"; then \
echo "Skipping $PATH2, already accounted for"; \
continue; \
else \
echo "Copying $(uname -m) lib2: $PATH2"; \
cp -L $PATH2 /root/lib_abs/$i ; \
echo $PATH2 >> /root/lib_abs.list; \
fi; \
else \
cp $PATH1 /root/lib_abs/$i ; \
echo $PATH1 >> /root/lib_abs.list; \
if cat /root/lib_abs.list | grep -x "$PATH1"; then \
echo "Skipping $PATH1, already accounted for"; \
continue; \
else \
echo "Copying $(uname -m) lib1: $PATH1"; \
cp -L $PATH1 /root/lib_abs/$i ; \
echo $PATH1 >> /root/lib_abs.list; \
fi; \
fi; \
((i = i + 1)) ;\
done; \
Expand Down

0 comments on commit b1e586a

Please sign in to comment.