diff --git a/build-tools/build-docker-images/build-stx-base.sh b/build-tools/build-docker-images/build-stx-base.sh index ebfddb8c..8d447484 100755 --- a/build-tools/build-docker-images/build-stx-base.sh +++ b/build-tools/build-docker-images/build-stx-base.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2018-2019 Wind River Systems, Inc. +# Copyright (c) 2018-2023 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -10,6 +10,7 @@ MY_SCRIPT_DIR=$(dirname $(readlink -f $0)) source ${MY_SCRIPT_DIR}/../utils.sh +source ${MY_SCRIPT_DIR}/../git-utils.sh # Required env vars if [ -z "${MY_WORKSPACE}" -o -z "${MY_REPO}" ]; then @@ -356,6 +357,7 @@ else -e "s!@DEBIAN_DISTRIBUTION@!${DEBIAN_DISTRIBUTION}!g" \ -e "s!@REPOMGR_DEPLOY_URL@!${REPOMGR_DEPLOY_URL}!g" \ -e "s!@REPOMGR_ORIGIN@!${REPOMGR_ORIGIN}!g" \ + -e "s!@LAYER@!${LAYER}!g" \ "$@" } @@ -365,6 +367,22 @@ else # debian.sources.list replace_vars "${SRC_DOCKER_DIR}/apt/debian.sources.list.in" >"${BUILDDIR}/apt/debian.sources.list" + # .sources.list + # These can be optionally used if it is necessary to build an image that + # requires dependencies that are in repositories not listed in + # `stx.sources.list`. + layer_cfg_name="${OS}_build_layer.cfg" + layer_cfgs=($(find ${GIT_LIST} -maxdepth 1 -name ${layer_cfg_name})) + LAYERS=($( + for layer_cfg in "${layer_cfgs[@]}"; do + echo $(cat "${layer_cfg}") + done | sort --unique + )) + + for LAYER in "${LAYERS[@]}"; do + replace_vars "${SRC_DOCKER_DIR}/apt/layer.sources.list.in" >"${BUILDDIR}/apt/${LAYER}.layer.sources.list" + done + # stx.sources: if user provided any --repo's use them instead of the template if [[ "${#REPO_LIST[@]}" -gt 0 ]] ; then rm -f "${BUILDDIR}/apt/stx.sources.list" diff --git a/build-tools/build-docker-images/stx-debian/Dockerfile.stable b/build-tools/build-docker-images/stx-debian/Dockerfile.stable index 8c11a0b1..f9814e94 100644 --- a/build-tools/build-docker-images/stx-debian/Dockerfile.stable +++ b/build-tools/build-docker-images/stx-debian/Dockerfile.stable @@ -18,6 +18,15 @@ COPY apt/debian.sources.list /etc/apt/sources.list.d/debian.list.disabled COPY apt/stx.sources.list /etc/apt/sources.list.d/stx.list.disabled COPY apt/stx.preferences /etc/apt/preferences.d/stx +# Install layer-specific binary repositories. +# Note: They are all supposed to be disabled by default, but can be optionally +# enabled if it is necessary to build an image that requires +# dependencies that are in repositories not listed in `stx.sources.list`. +COPY apt/*.layer.sources.list /etc/apt/sources.list.d/ +RUN for layer in /etc/apt/sources.list.d/*.layer.sources.list; do \ + mv "${layer}" "$(echo "${layer}" | sed s/.layer.sources.list/.list.disabled/)"; \ + done + # repo templates: # /etc/apt/sources.list.d/ # debian.list.disabled - vanilla debian repos diff --git a/build-tools/build-docker-images/stx-debian/apt/layer.sources.list.in b/build-tools/build-docker-images/stx-debian/apt/layer.sources.list.in new file mode 100644 index 00000000..23adb872 --- /dev/null +++ b/build-tools/build-docker-images/stx-debian/apt/layer.sources.list.in @@ -0,0 +1 @@ +deb [trusted=yes] @REPOMGR_DEPLOY_URL@/deb-local-binary-@LAYER@ @DEBIAN_DISTRIBUTION@ main