From 44ccc58f55c6f95a048fc51dd9820a5098a58e10 Mon Sep 17 00:00:00 2001 From: Davlet Panech Date: Wed, 17 Apr 2024 11:38:18 -0400 Subject: [PATCH] stx-init-env: get LAT installer from $STX_MIRROR LAT docker file downloads the installer from a hard-coded URL that points to https://mirror.starlingx.windriver.com . Allow users to override this location by defining STX_MIRROR_URL in the host environment. By default, guess mirror location from stx.conf. TESTS ========================== * Rebuild LAT container and make sure it uses the mirror URL from stx.conf * Set STX_MIRROR_URL prior to calling stx-init-env and make sure it gets picked up by the docker file Story: 2010055 Task: 49883 Signed-off-by: Davlet Panech Change-Id: Id8ea88407f74003db934337efd574451658633d8 --- import-stx | 5 +++++ stx-init-env | 15 ++++++++++++++- stx/dockerfiles/stx-lat-tool.Dockerfile | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/import-stx b/import-stx index 684b34e4..5e034b7a 100644 --- a/import-stx +++ b/import-stx @@ -79,6 +79,11 @@ # we delete them via sudo. If you set STX_RM_METHOD to "docker", we will # delete such files via a docker container with STX_BUILD_HOME mounted inside. # +# STX_MIRROR_URL +# StarlingX mirror URL; defaults to the value of "[repomgr]stx_mirror_url" from +# stx.conf; or https://mirror.starlingx.windriver.com/mirror. This is currently +# used when building stx-lat-sdk container. +# notice_warn () { local tty_on tty_off diff --git a/stx-init-env b/stx-init-env index cc5bb2f9..b9fa668c 100755 --- a/stx-init-env +++ b/stx-init-env @@ -395,6 +395,12 @@ safe_rm() { done } +init_stx_mirror_url() { + if [[ -z "$STX_MIRROR_URL" && -f "$STX_TOOLS_DIR/stx.conf" ]] ; then + STX_MIRROR_URL=$(sed -n -r 's/^\s*stx_mirror_url\s*=\s*//gp' "$STX_TOOLS_DIR/stx.conf" | sed "s/[\"']//g") + fi +} + cmdline_error() { if [[ -n "$1" ]] ; then echo "error: $1" >&2 @@ -712,7 +718,14 @@ if [[ -n "${BUILD_DOCKER_IMAGES}" ]] ; then docker_build_args+=("--no-cache") fi for img in $BUILD_DOCKER_IMAGES; do - docker build "${docker_build_args[@]}" -t $img:$DOCKER_TAG_LOCAL -f "$STX_TOOLS_DIR/"stx/dockerfiles/$img.Dockerfile "$STX_TOOLS_DIR" || exit 1 + extra_build_args=() + if grep -q -E '^\s*ARG\s+STX_MIRROR_URL\s*=' "$STX_TOOLS_DIR/"stx/dockerfiles/$img.Dockerfile ; then + init_stx_mirror_url + if [[ -n "$STX_MIRROR_URL" ]] ; then + extra_build_args+=("--build-arg" "STX_MIRROR_URL=$STX_MIRROR_URL") + fi + fi + docker build "${docker_build_args[@]}" "${extra_build_args[@]}" -t $img:$DOCKER_TAG_LOCAL -f "$STX_TOOLS_DIR/"stx/dockerfiles/$img.Dockerfile "$STX_TOOLS_DIR" || exit 1 info "built image $img:$DOCKER_TAG_LOCAL" done fi diff --git a/stx/dockerfiles/stx-lat-tool.Dockerfile b/stx/dockerfiles/stx-lat-tool.Dockerfile index a8523236..006cd159 100644 --- a/stx/dockerfiles/stx-lat-tool.Dockerfile +++ b/stx/dockerfiles/stx-lat-tool.Dockerfile @@ -16,7 +16,8 @@ FROM debian:bullseye MAINTAINER Chen Qi -ARG LAT_BINARY_RESOURCE_PATH=https://mirror.starlingx.windriver.com/mirror/lat-sdk/lat-sdk-20231206 +ARG STX_MIRROR_URL=https://mirror.starlingx.windriver.com/mirror +ARG LAT_BINARY_RESOURCE_PATH=${STX_MIRROR_URL}/lat-sdk/lat-sdk-20231206 # Update certificates RUN apt-get -y update && apt-get -y install --no-install-recommends ca-certificates && update-ca-certificates