From 8583bf98b526c23d487f0159401a65400fb044fa Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Wed, 21 Oct 2020 13:58:05 +0200 Subject: Support setting custom Nexus container name Change-Id: I41098413b96ac08fe479167aa0f5d0c4a699ef33 Issue-ID: OOM-2605 Signed-off-by: Bartek Grzybowski --- build/build_nexus_blob.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'build') diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh index 688410ef..b41d6cab 100755 --- a/build/build_nexus_blob.sh +++ b/build/build_nexus_blob.sh @@ -2,7 +2,7 @@ # COPYRIGHT NOTICE STARTS HERE # -# Copyright 2018-2019 © Samsung Electronics Co., Ltd. +# Copyright 2018-2020© Samsung Electronics Co., Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,13 +35,10 @@ SCRIPT_LOG="/tmp/$(basename $0)_$(eval ${TIMESTAMP}).log" # Log everything exec &> >(tee -a "${SCRIPT_LOG}") -# Nexus repository location +# Nexus repository properties NEXUS_DOMAIN="nexus" NEXUS_PORT="8081" NEXUS_DOCKER_PORT="8082" -NPM_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/npm-private/" -PYPI_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/pypi-private/" -DOCKER_REGISTRY="${NEXUS_DOMAIN}:${NEXUS_DOCKER_PORT}" DEFAULT_REGISTRY="docker.io" # Nexus repository credentials @@ -97,6 +94,7 @@ usage () { -o | --output-directory use specific directory for the target blob -p | --pypi use specific list of pypi packages to be pushed into Nexus -rl | --resource-list-directory use specific directory with docker, pypi and npm lists + -c | --container-name use specific Nexus docker container name " exit 1 } @@ -209,6 +207,15 @@ push_docker () { done } +validate_container_name () { + # Verify $1 is a valid hostname + if ! echo "${1}" | egrep -q "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$"; + then + echo "ERROR: ${1} is not a valid name!" + exit 1; + fi +} + while [ "${1}" != "" ]; do case ${1} in -d | --docker ) shift @@ -224,6 +231,10 @@ while [ "${1}" != "" ]; do shift NXS_NPM_LISTS+=("$(realpath ${1})") ;; + -c | --container-name ) shift + validate_container_name "${1}" + NEXUS_DOMAIN="${1}" + ;; -o | --output-directory ) shift NEXUS_DATA_DIR="$(realpath ${1})" ;; @@ -256,6 +267,11 @@ if [ ${#FAILED_COMMANDS[*]} -gt 0 ]; then exit 1 fi +# Nexus repository locations +NPM_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/npm-private/" +PYPI_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/pypi-private/" +DOCKER_REGISTRY="${NEXUS_DOMAIN}:${NEXUS_DOCKER_PORT}" + # Setup directories with resources for docker, npm and pypi NXS_SRC_DOCKER_IMG_DIR="${DATA_DIR}/offline_data/docker_images_for_nexus" NXS_SRC_NPM_DIR="${DATA_DIR}/offline_data/npm_tar" -- cgit 1.2.3-korg