Fix dynamic libraries loading (#226)
authorWilliam Desportes <redacted>
Tue, 1 Aug 2023 21:39:02 +0000 (23:39 +0200)
committerGitHub <redacted>
Tue, 1 Aug 2023 21:39:02 +0000 (23:39 +0200)
Fixes: #224
Ref: https://github.com/phpmyadmin/docker/commit/87bbb8dd8f3bddd6e5206926c54f9603cb22f136
Ref: https://github.com/phpmyadmin/docker/commit/da4b8f273a0a81078185076683ed92a382814ef3

apache/Dockerfile
fpm/Dockerfile
nightly/Dockerfile
templates/Dockerfile-debian.templ

index 27ecd30f9013b4b5b67edecb3bb81a125868b99d..f6b0341d3ad76c7e0367f246bcd7674ec8434727 100644 (file)
@@ -41,8 +41,9 @@ RUN set -ex; \
 # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
        apt-mark auto '.*' > /dev/null; \
        apt-mark manual $savedAptMark; \
-       ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
-               | awk '/=>/ { print $3 }' \
+       extdir="$(php -r 'echo ini_get("extension_dir");')"; \
+       ldd "$extdir"/*.so \
+               | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
                | sort -u \
                | xargs -r dpkg-query -S \
                | cut -d: -f1 \
@@ -50,7 +51,12 @@ RUN set -ex; \
                | xargs -rt apt-mark manual; \
        \
        apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
-       rm -rf /var/lib/apt/lists/*
+       rm -rf /var/lib/apt/lists/*; \
+    ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \
+    ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \
+    err="$(php --version 3>&1 1>&2 2>&3)"; \
+    [ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;);
+
 
 # installto.sh dependencies
 RUN set -ex; \
@@ -66,6 +72,7 @@ RUN set -ex; \
 
 COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
 
+
 RUN a2enmod rewrite
 
 # Define Roundcubemail version
index 115bd8bd82efd11e2d6df12d79e7603d259474b3..b5d4fe293787831212ce5e57db5adfe3ad1b87ac 100644 (file)
@@ -41,8 +41,9 @@ RUN set -ex; \
 # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
        apt-mark auto '.*' > /dev/null; \
        apt-mark manual $savedAptMark; \
-       ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
-               | awk '/=>/ { print $3 }' \
+       extdir="$(php -r 'echo ini_get("extension_dir");')"; \
+       ldd "$extdir"/*.so \
+               | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
                | sort -u \
                | xargs -r dpkg-query -S \
                | cut -d: -f1 \
@@ -50,7 +51,12 @@ RUN set -ex; \
                | xargs -rt apt-mark manual; \
        \
        apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
-       rm -rf /var/lib/apt/lists/*
+       rm -rf /var/lib/apt/lists/*; \
+    ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \
+    ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \
+    err="$(php --version 3>&1 1>&2 2>&3)"; \
+    [ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;);
+
 
 # installto.sh dependencies
 RUN set -ex; \
index 6ba664bb7e4b84360b93f07f088e019e56c4f0e4..7cdeb6faf86d12c0d1412266a7bb35e8786f93c7 100644 (file)
@@ -37,8 +37,9 @@ RUN set -ex; \
 # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
        apt-mark auto '.*' > /dev/null; \
        apt-mark manual $savedAptMark; \
-       ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
-               | awk '/=>/ { print $3 }' \
+       extdir="$(php -r 'echo ini_get("extension_dir");')"; \
+       ldd "$extdir"/*.so \
+               | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
                | sort -u \
                | xargs -r dpkg-query -S \
                | cut -d: -f1 \
@@ -46,7 +47,12 @@ RUN set -ex; \
                | xargs -rt apt-mark manual; \
        \
        apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
-       rm -rf /var/lib/apt/lists/*
+       rm -rf /var/lib/apt/lists/*; \
+    ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \
+    ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \
+    err="$(php --version 3>&1 1>&2 2>&3)"; \
+    [ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;);
+
 
 # installto.sh dependencies
 RUN set -ex; \
index c0196c276b2fa330d8708e3bccc1409c474e5b6a..44967dd12b7a11238c6def903168147155cce724 100644 (file)
@@ -41,8 +41,9 @@ RUN set -ex; \
 # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
        apt-mark auto '.*' > /dev/null; \
        apt-mark manual $savedAptMark; \
-       ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
-               | awk '/=>/ { print $3 }' \
+       extdir="$(php -r 'echo ini_get("extension_dir");')"; \
+       ldd "$extdir"/*.so \
+               | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
                | sort -u \
                | xargs -r dpkg-query -S \
                | cut -d: -f1 \
@@ -50,7 +51,12 @@ RUN set -ex; \
                | xargs -rt apt-mark manual; \
        \
        apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
-       rm -rf /var/lib/apt/lists/*
+       rm -rf /var/lib/apt/lists/*; \
+    ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \
+    ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \
+    err="$(php --version 3>&1 1>&2 2>&3)"; \
+    [ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;);
+
 
 # installto.sh dependencies
 RUN set -ex; \
git clone https://git.99rst.org/PROJECT