Add MIRROR_LOCAL support to build-stx-images.sh
As the loci build runs in a container, it is unable to directly use a PROJECT_REPO ref that requires ssh keys to be setup. In order to support this, a MIRROR_LOCAL option is added to loci image directives files. If the image directives file has MIRROR_LOCAL=yes, the build utility will first setup a bare clone of the PROJECT_REPO in the local workspace and instead pass a reference to that to the loci build. This functionality can be used by developers to test an image build using a private forked repo that requires an ssh key to access, for example. This should not be used in the formal build, as CENGN and other developers are unlikely to have the required access. Note: This requires that the build server in use has lighttpd server setup with external access, as the container cannot access localhost. Change-Id: Ibd260fbb47d2bece4dc27e1cf1c026fb5cd5ff0f Story: 2003907 Task: 42364 Co-Authored-By: Scott Little <scott.little@windriver.com> Signed-off-by: Don Penney <don.penney@windriver.com>
This commit is contained in:
parent
28fc03bde9
commit
33895c2922
@ -334,9 +334,46 @@ function build_image_loci {
|
||||
PROFILES=$(source ${image_build_file} && echo ${PROFILES})
|
||||
local PYTHON3
|
||||
PYTHON3=$(source ${image_build_file} && echo ${PYTHON3})
|
||||
local MIRROR_LOCAL
|
||||
MIRROR_LOCAL=$(source ${image_build_file} && echo ${MIRROR_LOCAL})
|
||||
|
||||
echo "Building ${LABEL}"
|
||||
|
||||
local ORIGWD=${PWD}
|
||||
|
||||
if [ "${MIRROR_LOCAL}" = "yes" ]; then
|
||||
# Setup a local mirror of PROJECT_REPO
|
||||
|
||||
local BARE_CLONES=${WORKDIR}/bare_clones
|
||||
mkdir -p ${BARE_CLONES}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to create ${BARE_CLONES}" >&2
|
||||
RESULTS_FAILED+=(${LABEL})
|
||||
return 1
|
||||
fi
|
||||
|
||||
local CLONE_DIR=${BARE_CLONES}/${PROJECT}.git
|
||||
|
||||
# Remove prior clone dir, if it exists
|
||||
\rm -rf ${CLONE_DIR}
|
||||
|
||||
echo "Creating bare clone of ${PROJECT_REPO} for ${LABEL} build..."
|
||||
git clone --bare ${PROJECT_REPO} ${CLONE_DIR} \
|
||||
&& mv ${CLONE_DIR}/hooks/post-update.sample ${CLONE_DIR}/hooks/post-update \
|
||||
&& chmod a+x ${CLONE_DIR}/hooks/post-update \
|
||||
&& cd ${CLONE_DIR} \
|
||||
&& git update-server-info \
|
||||
&& cd ${ORIGWD}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to clone ${PROJECT_REPO}... Aborting ${LABEL} build"
|
||||
RESULTS_FAILED+=(${LABEL})
|
||||
cd ${ORIGWD}
|
||||
return 1
|
||||
fi
|
||||
|
||||
PROJECT_REPO=http://${HOSTNAME}:8088/${CLONE_DIR}
|
||||
fi
|
||||
|
||||
local -a BUILD_ARGS=
|
||||
BUILD_ARGS=(--build-arg PROJECT=${PROJECT})
|
||||
BUILD_ARGS+=(--build-arg PROJECT_REPO=${PROJECT_REPO})
|
||||
|
Loading…
x
Reference in New Issue
Block a user