From 730dc19b73430f43b8c8d003714fde8a0cc495fa Mon Sep 17 00:00:00 2001 From: Samuli Silvius Date: Mon, 4 Feb 2019 14:26:27 +0200 Subject: Configuration file option for packaging At the moment configuration file for the package.sh script is fixed by name and location package.conf in the same dir as the script. Allow user to give configuration file as parameter for the script. Issue-ID: OOM-1627 Change-Id: I8b728996ead73a48b88bbbf364ec913217cbd8d6 Signed-off-by: Samuli Silvius --- build/package.sh | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'build') diff --git a/build/package.sh b/build/package.sh index ee985339..0e4f1213 100755 --- a/build/package.sh +++ b/build/package.sh @@ -32,8 +32,8 @@ crash () { usage () { echo "Usage:" - echo " ./$(basename $0) " - echo "Example: ./$(basename $0) onap 1.0.1 /tmp/package_onap_1.0.0" + echo " ./$(basename $0) [--conf ]" + echo "Example: ./$(basename $0) myproject 1.0.1 /tmp/package --conf ~/myproject.conf" echo "packaging_target_dir will be created if does not exist. All tars will be produced into it." } @@ -89,7 +89,7 @@ function build_sw_artifacts { } function create_sw_package { - local pkg_root="${PACKAGING_TARGET_DIR}/onap" + local pkg_root="${PACKAGING_TARGET_DIR}/sw" # Create tar package echo "[Creating software package]" @@ -186,26 +186,37 @@ PROJECT_VERSION="$2" PACKAGING_TARGET_DIR="$3" TIMESTAMP=$(date -u +%Y%m%dT%H%M%S) - -# ensure that package.conf is sourced even when package.sh executed from another place SCRIPT_DIR=$(dirname "${0}") LOCAL_PATH=$(readlink -f "$SCRIPT_DIR") -# lets start from script directory as some path in script are relative -pushd "${LOCAL_PATH}" -source ./package.conf - - if [ "$#" -lt 3 ]; then echo "Missing some mandatory parameter!" usage exit 1 fi -if [ ! -f "./package.conf" ]; then - crash 2 "Mandatory config file ./package.conf missing!" +CONF_FILE="" +for arg in "$@"; do + shift + case "$arg" in + -c|--conf) + CONF_FILE="$1" ;; + *) + set -- "$@" "$arg" + esac +done + +if [ -z ${CONF_FILE} ]; then + CONF_FILE=${LOCAL_PATH}/package.conf # Fall to default conf file fi +if [ ! -f ${CONF_FILE} ]; then + crash 2 "Mandatory config file missing! Provide it with --conf option or ${LOCAL_PATH}/package.conf" +fi + +source ${CONF_FILE} +pushd ${LOCAL_PATH} + # checking bash capability of parsing arrays whotest[0]='test' || (crash 3 "Arrays not supported in this version of bash.") -- cgit 1.2.3-korg