diff options
author | Samuli Silvius <s.silvius@partner.samsung.com> | 2019-02-06 11:25:01 +0200 |
---|---|---|
committer | Samuli Silvius <s.silvius@partner.samsung.com> | 2019-02-12 09:37:14 +0200 |
commit | 426e6c09fe0c8a0d0c35631231f023eaf8823775 (patch) | |
tree | 0b807ac6e1d50ab7203eec6be18702778a6612fa /build/package.sh | |
parent | fe111116be4128a9fb90d175c38e0aa955e7e33f (diff) |
Clarify packaging variables documentation
For the user package.sh/package.conf is a bit confusing
and variables are not well named nor documented.
Binary definition can be also simplified by providing
just single directory to take binaries from.
Corresponding variable documentation on installer
side (ansible code) is also confusing and missing
relation to packaging variables
This commit aims on improving that documentation.
Issue-ID: OOM-1633
Change-Id: I81261f51d393f434eac26c4a46624388671bd36b
Signed-off-by: Samuli Silvius <s.silvius@partner.samsung.com>
Diffstat (limited to 'build/package.sh')
-rwxr-xr-x | build/package.sh | 118 |
1 files changed, 50 insertions, 68 deletions
diff --git a/build/package.sh b/build/package.sh index 89764ccf..63774e02 100755 --- a/build/package.sh +++ b/build/package.sh @@ -50,12 +50,18 @@ function create_tar { find ${tar_dir}/* -maxdepth 0 -type d -exec rm -rf '{}' \; # Remove packaged files find ${tar_dir}/* ! -name ${tar_name} -exec rm '{}' \; - echo "tar file ${tar_name} created in target dir" + echo "Tar file created to $(dirname ${tar_dir})/${tar_name}" +} + +function create_pkg { + local pkg_type="$1" + echo "[Creating ${pkg_type} package]" + create_tar "${PKG_ROOT}" offline-${PROJECT_NAME}-${PROJECT_VERSION}-${pkg_type}.tar + rm -rf "${PKG_ROOT}" } function add_metadata { local metafile="$1" - echo "Project name: ${PROJECT_NAME}" >> "${metafile}" echo "Project version: ${PROJECT_VERSION}" >> "${metafile}" echo "Package date: ${TIMESTAMP}" >> "${metafile}" @@ -64,7 +70,6 @@ function add_metadata { function add_additions { local source="$1" local target="$2" - if [ -d "${source}" ]; then mkdir -p "${target}/$(basename $source)" cp -r "${source}" "${target}" @@ -80,7 +85,7 @@ function add_additions { } function build_sw_artifacts { - cd ../ansible/docker + cd ${LOCAL_PATH}/../ansible/docker ./build_ansible_image.sh if [ $? -ne 0 ]; then crash 5 "Building of ansible runner image failed." @@ -89,95 +94,75 @@ function build_sw_artifacts { } function create_sw_package { - local pkg_root="${PACKAGING_TARGET_DIR}/sw" - - # Create tar package - echo "[Creating software package]" + PKG_ROOT="${PACKAGING_TARGET_DIR}/sw" # Create directory structure of the sw package - mkdir -p "${pkg_root}" - cp -r ansible "${pkg_root}" + mkdir -p "${PKG_ROOT}" + cp -r ${LOCAL_PATH}/../ansible "${PKG_ROOT}" - # Add additional files/dirs into package based on package.conf - for item in "${SW_PACKAGE_ADDONS[@]}";do + # Add application additional files/dirs into package based on package.conf + for item in "${APP_CONFIGURATION[@]}";do # all SW package addons are expected within ./ansible/application folder - add_additions "${item}" "${pkg_root}/ansible/application" + add_additions "${item}" "${PKG_ROOT}/${APPLICATION_FILES_IN_PACKAGE}" done - # Helm charts handling + # Application Helm charts + # To be consistent with resources and aux dir, create charts dir even if no charts provided. + mkdir -p ${PKG_ROOT}/${HELM_CHARTS_DIR_IN_PACKAGE} if [ ! -z "${HELM_CHARTS_DIR}" ]; then - echo "Helm charts handling" + echo "Add application Helm charts" # Copy charts available for ansible playbook to use/move them to target server/dir - mkdir -p ${pkg_root}/${HELM_CHARTS_DIR_IN_PACKAGE} - cp -r "${HELM_CHARTS_DIR}"/* ${pkg_root}/${HELM_CHARTS_DIR_IN_PACKAGE} + cp -r "${HELM_CHARTS_DIR}"/* ${PKG_ROOT}/${HELM_CHARTS_DIR_IN_PACKAGE} + else + echo "No Helm charts defined, no application will be automatically installed by this package!" fi # Add metadata to the package - add_metadata "${pkg_root}"/package.info + add_metadata "${PKG_ROOT}"/package.info # Create sw tar package - echo "Creating tar file ..." - PACKAGE_BASE_NAME="${SOFTWARE_PACKAGE_BASENAME}" - create_tar "${pkg_root}" ${PACKAGE_BASE_NAME}-${PROJECT_NAME}-${PROJECT_VERSION}-sw.tar - rm -rf "${pkg_root}" + create_pkg sw } function create_resource_package { - local pkg_root="${PACKAGING_TARGET_DIR}/resources" - - # Create resource tar package - echo "[Creating resource package]" + PKG_ROOT="${PACKAGING_TARGET_DIR}/resources" # Create directory structure of the resource package - mkdir -p "${pkg_root}" + mkdir -p "${PKG_ROOT}" - # Add artifacts into resource packagee based on package.conf config - for item in "${EXTERNAL_BINARIES_PACKAGE_ADDONS[@]}";do - if [ "$(basename $item)" == "resources" ]; then - echo "Note: Packaging all resources at once" - add_additions "${item}" "${PACKAGING_TARGET_DIR}" - else - add_additions "${item}" "${pkg_root}" - fi - done + # Add artifacts into resource package based on package.conf config + if [ ! -z ${APP_BINARY_RESOURCES_DIR} ]; then + cp -r ${APP_BINARY_RESOURCES_DIR}/* ${PKG_ROOT} + fi # tar file with nexus_data is expected, we should find and untar it # before resource.tar is created - for i in `ls -1 ${pkg_root} | grep tar`; do - tar tvf "${pkg_root}/${i}" | grep nexus_data &> /dev/null - if [ $? -eq 0 ]; then - echo "Debug: tar file with nexus blobs detected ${pkg_root}/${i}. Start unarchive ..." - tar xf "${pkg_root}/${i}" -C "${pkg_root}" &> /dev/null - echo "Debug: unarchive finished. Removing original file" - rm -f "${pkg_root}/${i}" - fi + for i in `ls -1 ${PKG_ROOT} | grep tar`; do + tar tvf "${PKG_ROOT}/${i}" | grep nexus_data &> /dev/null + if [ $? -eq 0 ]; then + echo "Debug: tar file with nexus blobs detected ${PKG_ROOT}/${i}. Start unarchive ..." + tar xf "${PKG_ROOT}/${i}" -C "${PKG_ROOT}" &> /dev/null + echo "Debug: unarchive finished. Removing original file" + rm -f "${PKG_ROOT}/${i}" + fi done - echo "Creating tar file ..." - PACKAGE_BASE_NAME="${SOFTWARE_PACKAGE_BASENAME}" - create_tar "${pkg_root}" "${PACKAGE_BASE_NAME}-${PROJECT_NAME}-${PROJECT_VERSION}-resources.tar" - rm -rf "${pkg_root}" + create_pkg resources } function create_aux_package { - local pkg_root="${PACKAGING_TARGET_DIR}/aux" - - # Create aux resource tar package - echo "Creating aux resource package" + PKG_ROOT="${PACKAGING_TARGET_DIR}/aux" # Create directory structure of the aux resource package - mkdir -p "${pkg_root}" + mkdir -p "${PKG_ROOT}" # Add artifacts into resource packagee based on package.conf config - for item in "${AUX_BINARIES_PACKAGE_ADDONS[@]}";do - add_additions "${item}" "${pkg_root}" + for item in "${APP_AUX_BINARIES[@]}";do + add_additions "${item}" "${PKG_ROOT}" done - echo "Creating tar file ..." - PACKAGE_BASE_NAME="${SOFTWARE_PACKAGE_BASENAME}" - create_tar "${pkg_root}" "${PACKAGE_BASE_NAME}-${PROJECT_NAME}-${PROJECT_VERSION}-aux-resources.tar" - rm -rf "${pkg_root}" + create_pkg aux-resources } # @@ -192,6 +177,10 @@ TIMESTAMP=$(date -u +%Y%m%dT%H%M%S) SCRIPT_DIR=$(dirname "${0}") LOCAL_PATH=$(readlink -f "$SCRIPT_DIR") +# Relative location inside the package for application related files. +# Application means Kubernetes application installed by Helm charts on ready cluster (e.g. onap). +APPLICATION_FILES_IN_PACKAGE="ansible/application" + # Relative location inside the package to place Helm charts to be available for # Ansible process to transfer them into machine (infra node) running Helm repository. # NOTE: This is quite hardcoded place to put them and agreement with Ansible code @@ -201,7 +190,7 @@ LOCAL_PATH=$(readlink -f "$SCRIPT_DIR") # This variable can be of course changed in package.conf if really needed if # corresponding ansible variable "app_helm_charts_install_directory" value # adjusted accordingly. -HELM_CHARTS_DIR_IN_PACKAGE="ansible/application/helm_charts" +HELM_CHARTS_DIR_IN_PACKAGE="${APPLICATION_FILES_IN_PACKAGE}/helm_charts" if [ "$#" -lt 3 ]; then echo "Missing some mandatory parameter!" @@ -241,13 +230,6 @@ rm -rf ${PACKAGING_TARGET_DIR} build_sw_artifacts create_sw_package create_resource_package - -# This part will create aux package which consists of -# artifacts which can be added into offline nexus during runtime -if [ "${PREPARE_AUX_PACKAGE}" == "true" ]; then - create_aux_package -else - echo "AUX package won't be created" -fi +create_aux_package popd |