From b12b440404f179993ddc8b6dc086cc2144f30cfd Mon Sep 17 00:00:00 2001 From: Mateusz Pilat Date: Thu, 23 May 2019 15:55:56 +0200 Subject: Modify build_nexus_blob.sh to accept more input parameters In order to connect nexus build blob with dynamically generated input files Issue-ID: OOM-1848 Signed-off-by: Mateusz Pilat Change-Id: Ifd1218b69e0b341fd929a5d4cda96cea17153f12 --- build/build_nexus_blob.sh | 77 +++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 29 deletions(-) (limited to 'build') diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh index 4b1697e3..64cf9d8d 100755 --- a/build/build_nexus_blob.sh +++ b/build/build_nexus_blob.sh @@ -21,9 +21,10 @@ ### This script prepares Nexus repositories data blobs for ONAP ## The script requires following dependencies are installed: nodejs, jq, docker -## All required resources are expected in the upper directory -## created during download procedure as DATA_DIR -## All lists used must be in project data_lists directory +## All required resources are expected in the upper directory created during +## download procedure as DATA_DIR or in the directory given as --input-directory +## All lists used must be in project data_lists directory or in the directory given +## as --resource-list-directory # Fail fast settings set -e @@ -34,18 +35,6 @@ SCRIPT_LOG="/tmp/$(basename $0)_$(eval ${TIMESTAMP}).log" # Log everything exec &> >(tee -a "${SCRIPT_LOG}") -usage () { - echo " This script is preparing Nexus data blob from docker images and npm and pypi packages" - echo " Usage:" - echo " ./$(basename $0) []" - echo " " - echo " Example: ./$(basename $0) onap_3.0.1 /root/nexus_data" - echo " " - echo " Dependencies: nodejs, jq, docker" - echo " " - exit 1 -} - # Nexus repository location NEXUS_DOMAIN="nexus" NEXUS_PORT="8081" @@ -60,24 +49,53 @@ NEXUS_USERNAME=admin NEXUS_PASSWORD=admin123 NEXUS_EMAIL=admin@example.org -if [ "${1}" == "-h" ] || [ "${1}" == "--help" ] || [ $# -eq 0 ]; then - usage -else - TAG="${1}" -fi - # Setting paths LOCAL_PATH="$(readlink -f $(dirname ${0}))" + +#Defaults DATA_DIR="$(realpath ${LOCAL_PATH}/../../resources)" +NEXUS_DATA_DIR="${DATA_DIR}/nexus_data" +LISTS_DIR="${LOCAL_PATH}/data_lists" -if [ -z "${2}" ]; then - NEXUS_DATA_DIR="${DATA_DIR}/nexus_data" -else - NEXUS_DATA_DIR="${2}" -fi +usage () { + echo " Example usage: build_nexus_blob.sh -t --input-directory --output-directory + --resource-list-directory + + -t | --tag release tag, taken from available on git or placed by data generating script (mandatory) must fallow scheme onap_ + -i | --input-directory directory containing file needed to create nexus blob. The structure of this directory must organized as described in build guide + -o | --output-directory + -rl | --resource-list-directory directory with files containing docker, pypi and rpm lists + " + exit 1 +} + +while [ "$1" != "" ]; do + case $1 in + -t | --tag ) shift + TAG=$1 + ;; + -i | --input-directory ) shift + DATA_DIR=$1 + ;; + -o | --output-directory ) shift + NEXUS_DATA_DIR=$1 + ;; + -rl | --resource-list-directory ) shift + LISTS_DIR=$1 + ;; + -h | --help ) usage + ;; + *) usage + esac + shift +done -# Setup directory with resources lists -LISTS_DIR="${LOCAL_PATH}/data_lists" + +# exit if no tag given +if [ -z ${TAG} ]; then + usage + exit 1 +fi # Setup directories with resources for docker, npm and pypi NXS_SRC_DOCKER_IMG_DIR="${DATA_DIR}/offline_data/docker_images_for_nexus" @@ -284,7 +302,7 @@ for IMAGE in $(sed $'s/\r// ; /^#/d' ${NXS_DOCKER_IMG_LIST} | awk '{ print $1 }' if [[ ${IMAGE} != *"/"* ]]; then PUSH="${DOCKER_REGISTRY}/library/${IMAGE}" elif [[ ${IMAGE} == *"${DEFAULT_REGISTRY}"* ]]; then - if [[ ${IMAGE} == *"/"*"/"* ]]; then + if [[ ${IMAGE} == *"/"*"/"* ]]; then PUSH="$(sed 's/'"${DEFAULT_REGISTRY}"'/'"${DOCKER_REGISTRY}"'/' <<< ${IMAGE})" else PUSH="$(sed 's/'"${DEFAULT_REGISTRY}"'/'"${DOCKER_REGISTRY}"'\/library/' <<< ${IMAGE})" @@ -322,3 +340,4 @@ npm config set registry "https://registry.npmjs.org" echo "Nexus blob is built" exit 0 + -- cgit 1.2.3-korg