summaryrefslogtreecommitdiffstats
path: root/build/build_nexus_blob.sh
diff options
context:
space:
mode:
authorMateusz Pilat <m.pilat@partner.samsung.com>2019-05-23 15:55:56 +0200
committerMateusz Pilat <m.pilat@partner.samsung.com>2019-05-27 15:34:39 +0200
commitb12b440404f179993ddc8b6dc086cc2144f30cfd (patch)
treef2075b3ee0a110e570fe142970c5a9ca19321f5d /build/build_nexus_blob.sh
parentb1fe78553ea7d1caf90c1d52e195cd8f2a082008 (diff)
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 <m.pilat@partner.samsung.com> Change-Id: Ifd1218b69e0b341fd929a5d4cda96cea17153f12
Diffstat (limited to 'build/build_nexus_blob.sh')
-rwxr-xr-xbuild/build_nexus_blob.sh77
1 files changed, 48 insertions, 29 deletions
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) <project version> [<target>]"
- 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 <tag> --input-directory </path/to/downloaded/files/dir> --output-directory
+ </path/to/output/dir> --resource-list-directory </path/to/dir/with/resource/list>
+
+ -t | --tag release tag, taken from available on git or placed by data generating script (mandatory) must fallow scheme onap_<semver>
+ -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
+