From dfaf7ae498a27f5f34736a566e67e21a21872242 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Tue, 12 Nov 2024 09:19:55 +0100 Subject: [PATCH] fix: proper initialize v2 tools --- src/usr/local/containerbase/bin/init-tool.sh | 33 ++++++++++++-------- test/golang/Dockerfile | 16 ++++++++++ test/node/Dockerfile | 2 +- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/usr/local/containerbase/bin/init-tool.sh b/src/usr/local/containerbase/bin/init-tool.sh index 186abe3f7..93a041ed6 100755 --- a/src/usr/local/containerbase/bin/init-tool.sh +++ b/src/usr/local/containerbase/bin/init-tool.sh @@ -5,19 +5,26 @@ set -e # shellcheck source=/dev/null . /usr/local/containerbase/util.sh +function main() { + local TOOL_NAME + TOOL_NAME=${1} + check TOOL_NAME true -V2_TOOL="${CONTAINERBASE_DIR}/tools/v2/${TOOL_NAME}.sh" + V2_TOOL="${CONTAINERBASE_DIR}/tools/v2/${TOOL_NAME}.sh" -if [[ -f "$V2_TOOL" ]]; then - # init v2 tool - # load overrides needed for v2 tools - # shellcheck source=/dev/null - . "${CONTAINERBASE_DIR}/utils/v2/overrides.sh" - # shellcheck source=/dev/null - . "${V2_TOOL}" - init_v2_tool -else - echo "No tool defined - skipping: ${TOOL_NAME}" >&2 - exit 1; -fi + if [[ -f "$V2_TOOL" ]]; then + # init v2 tool + # load overrides needed for v2 tools + # shellcheck source=/dev/null + . "${CONTAINERBASE_DIR}/utils/v2/overrides.sh" + # shellcheck source=/dev/null + . "${V2_TOOL}" + init_v2_tool + else + echo "No tool defined - skipping: ${TOOL_NAME}" >&2 + exit 1; + fi +} + +main "$@" diff --git a/test/golang/Dockerfile b/test/golang/Dockerfile index 8da962127..c5c15a131 100644 --- a/test/golang/Dockerfile +++ b/test/golang/Dockerfile @@ -89,8 +89,24 @@ FROM base AS testc RUN prepare-tool golang +# emulate emtpy containerbase folders +RUN set -ex; \ + ls -la /tmp/containerbase/cache; \ + rm -rf /opt/containerbase/*; \ + ls -la /opt/containerbase/; \ + rm -rf /tmp/*; \ + ls -la /tmp/; \ + ls -la /var/lib/containerbase/; \ + cat /var/lib/containerbase/tool.prep; \ + true + USER 12021 +RUN [[ ! -d /tmp/containerbase ]] || (echo "/tmp/containerbase should not exist"; exit 1 ) +RUN containerbase-cli init tool golang +RUN [[ -d /tmp/containerbase ]] || (echo "/tmp/containerbase should exist"; exit 1) +RUN rm -rf /tmp/*; + # renovate: datasource=github-releases packageName=containerbase/golang-prebuild RUN install-tool golang 1.23.3 diff --git a/test/node/Dockerfile b/test/node/Dockerfile index 2bc03a384..e0a278150 100644 --- a/test/node/Dockerfile +++ b/test/node/Dockerfile @@ -467,7 +467,7 @@ RUN set -ex; \ ls -la /opt/containerbase; \ ls -la /tmp/containerbase; \ ls -la /tmp/containerbase/cache; \ - true;true + true RUN prepare-tool node