summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorSamuli Silvius <s.silvius@partner.samsung.com>2019-02-04 14:26:27 +0200
committerSamuli Silvius <s.silvius@partner.samsung.com>2019-02-08 14:43:53 +0200
commit730dc19b73430f43b8c8d003714fde8a0cc495fa (patch)
tree44c4149164510ed6acbeeb87f2df452da88fd6cd /build
parentfe2d638b68c74897c9b2ef7bccd1a323f8435f59 (diff)
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 <s.silvius@partner.samsung.com>
Diffstat (limited to 'build')
-rwxr-xr-xbuild/package.sh35
1 files changed, 23 insertions, 12 deletions
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) <project_name> <version> <packaging_target_dir>"
- echo "Example: ./$(basename $0) onap 1.0.1 /tmp/package_onap_1.0.0"
+ echo " ./$(basename $0) <project_name> <version> <packaging_target_dir> [--conf <file>]"
+ 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.")