From: William Desportes Date: Tue, 1 Aug 2023 21:39:02 +0000 (+0200) Subject: Fix dynamic libraries loading (#226) X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=5ad2eaa33987cf2b508a5816dffa2c54671df9cd;p=roundcube-roundcubemail-docker.git Fix dynamic libraries loading (#226) Fixes: #224 Ref: https://github.com/phpmyadmin/docker/commit/87bbb8dd8f3bddd6e5206926c54f9603cb22f136 Ref: https://github.com/phpmyadmin/docker/commit/da4b8f273a0a81078185076683ed92a382814ef3 --- diff --git a/apache/Dockerfile b/apache/Dockerfile index 27ecd30..f6b0341 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -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 diff --git a/fpm/Dockerfile b/fpm/Dockerfile index 115bd8b..b5d4fe2 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -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; \ diff --git a/nightly/Dockerfile b/nightly/Dockerfile index 6ba664b..7cdeb6f 100644 --- a/nightly/Dockerfile +++ b/nightly/Dockerfile @@ -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; \ diff --git a/templates/Dockerfile-debian.templ b/templates/Dockerfile-debian.templ index c0196c2..44967dd 100644 --- a/templates/Dockerfile-debian.templ +++ b/templates/Dockerfile-debian.templ @@ -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; \