Skip to content

Commit 327a084

Browse files
committed
Make ClamAV library copy resilient on Ubuntu 24.04
1 parent fd5e588 commit 327a084

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

cdk/Dockerfile

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,14 @@ RUN apt-get update -y && \
1010
# Copy Clamscan
1111
RUN cp /usr/bin/clamscan /tmp/
1212

13-
# Detect platform and copy libraries
13+
# Collect the runtime-linked shared libraries for clamscan and libclamav.
1414
RUN mkdir -p /tmp/clamav_libs && \
15-
ARCH=$(uname -m) && \
16-
LIB_DIR="/lib/$ARCH-linux-gnu" && \
17-
echo "Detected architecture: $ARCH, copying libraries from $LIB_DIR" && \
18-
cp ${LIB_DIR}/libclamav.so.* /tmp/clamav_libs/ && \
19-
cp ${LIB_DIR}/libjson-c.so.* /tmp/clamav_libs/ && \
20-
cp ${LIB_DIR}/libbz2.so.* /tmp/clamav_libs/ && \
21-
cp ${LIB_DIR}/libltdl.so.* /tmp/clamav_libs/ && \
22-
cp ${LIB_DIR}/libxml2.so.* /tmp/clamav_libs/ && \
23-
cp ${LIB_DIR}/libmspack.so.* /tmp/clamav_libs/ && \
24-
cp ${LIB_DIR}/libcrypto.so.* /tmp/clamav_libs/ && \
25-
cp ${LIB_DIR}/libz.so.* /tmp/clamav_libs/ && \
26-
(cp ${LIB_DIR}/libtfm.so.* /tmp/clamav_libs/ || true) && \
27-
cp ${LIB_DIR}/libpcre2-8.so.* /tmp/clamav_libs/ && \
28-
cp ${LIB_DIR}/liblzma.so.* /tmp/clamav_libs/
15+
LIBCLAMAV=$(find /usr/lib -path '*/libclamav.so.*' | head -n 1) && \
16+
echo "Collecting runtime libraries for /usr/bin/clamscan and $LIBCLAMAV" && \
17+
ldd /usr/bin/clamscan "$LIBCLAMAV" | \
18+
awk '/=> \// { print $3 } /^\/[^[:space:]]+/ { print $1 }' | \
19+
sort -u | \
20+
xargs -I '{}' cp -v '{}' /tmp/clamav_libs/
2921

3022

3123
# Create a directory for the definitions and run freshclam to update them.

0 commit comments

Comments
 (0)