Drop placeholder substitution for ldconfig aux-cache cleanup in Dockerfile template

In 4b15f9a1a1, a placeholder for the ldconfig aux-cache cleanup (required for the repro image) was implemented in the Dockerfile template and was substituted by either `&& rm -f /var/cache/ldconfig/aux-cache` for the repro group or `&& true` for other groups (so that it does nothing).

While technically harmless, the resulting `&& true` for the non-repro groups is slightly confusing and may raise some eyebrows (see https://github.com/docker-library/official-images/pull/21366). This change aims to drop the placeholder for the ldconfig aux-cache cleanup in the Dockerfile template and simply expand the "ldconfig + sed" RUN command to include the ldconfig aux-cache cleanup for the repro group. This results in a more precisely targeted substitution without unnecessary and confusing addition in the Dockerfile of the non-repro groups.
This commit is contained in:
Robin Candau 2026-05-08 09:59:51 +02:00
parent b43ff00eac
commit 5f9435cfe9
No known key found for this signature in database
GPG Key ID: FDC3040B92ACA748
2 changed files with 6 additions and 5 deletions

View File

@ -37,8 +37,7 @@ LABEL org.opencontainers.image.created="TEMPLATE_CREATED"
COPY --from=verify /rootfs/ /
RUN ldconfig && \
sed -i '/BUILD_ID/a VERSION_ID=TEMPLATE_VERSION_ID' /etc/os-release && \
LDCONFIG_AUX_CACHE
sed -i '/BUILD_ID/a VERSION_ID=TEMPLATE_VERSION_ID' /etc/os-release
ENV LANG=C.UTF-8
CMD ["/usr/bin/bash"]

View File

@ -22,10 +22,8 @@ CI_COMMIT_SHA="${CI_COMMIT_SHA:-$(git rev-parse HEAD)}"
# Honor SOURCE_DATE_EPOCH and delete non-determistic ldconfig auxiliary cache file for the repro GROUP
if [[ "$GROUP" == "repro" ]]; then
CREATED_TIMESTAMP=$(date -u -d "@$SOURCE_DATE_EPOCH" +%Y-%m-%dT%H:%M:%SZ)
LDCONFIG_AUX_CACHE="rm -f /var/cache/ldconfig/aux-cache"
else
CREATED_TIMESTAMP=$(date -Is)
LDCONFIG_AUX_CACHE="true"
fi
sed -e "s|TEMPLATE_ROOTFS_FILE|$ROOTFS_FILE|" \
@ -35,5 +33,9 @@ sed -e "s|TEMPLATE_ROOTFS_FILE|$ROOTFS_FILE|" \
-e "s|TEMPLATE_VERSION_ID|$BUILD_VERSION|" \
-e "s|TEMPLATE_REVISION|$CI_COMMIT_SHA|" \
-e "s|TEMPLATE_CREATED|$CREATED_TIMESTAMP|" \
-e "s|LDCONFIG_AUX_CACHE|$LDCONFIG_AUX_CACHE|" \
Dockerfile.template > "$OUTPUTDIR/Dockerfile.$GROUP"
if [[ "$GROUP" == "repro" ]]; then
sed -i '/VERSION_ID=.*os-release$/ s/$/ \&\& \\\n rm -f \/var\/cache\/ldconfig\/aux-cache/' \
"$OUTPUTDIR/Dockerfile.$GROUP"
fi