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 <davlet.panech@windriver.com>
Change-Id: Id8ea88407f74003db934337efd574451658633d8
This commit is contained in:
Davlet Panech 2024-04-17 11:38:18 -04:00
parent b4b826082d
commit 44ccc58f55
3 changed files with 21 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -16,7 +16,8 @@ FROM debian:bullseye
MAINTAINER Chen Qi <Qi.Chen@windriver.com>
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