X-Git-Url: https://gerrit.nordix.org/gitweb?p=infra%2Fstack%2Fkubernetes.git;a=blobdiff_plain;f=playbooks%2Froles%2Fpackage%2Ffiles%2Fbuild.sh;fp=playbooks%2Froles%2Fpackage%2Ffiles%2Fbuild.sh;h=c28264decb59146dfe366fda69a79eee4eee4826;hp=0000000000000000000000000000000000000000;hb=20d34e772e021fabdee0aa9b50e9804a80d5108a;hpb=0ee637017774692ae73514e146f25c8973c3bffe diff --git a/playbooks/roles/package/files/build.sh b/playbooks/roles/package/files/build.sh new file mode 100755 index 0000000..c28264d --- /dev/null +++ b/playbooks/roles/package/files/build.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2019 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +set -o errexit +set -o nounset +set -o pipefail + +export OFFLINE_PKG_FOLDER="${OFFLINE_PKG_FOLDER:-/tmp/offline-package}" +export OFFLINE_PKG_FILE="${OFFLINE_PKG_FILE:-/tmp/offline-package.tgz}" + +# NOTE (fdegir): In order to package and test the change for offline deployment, +# we need to include the change/patch within the package since that is what should +# be used during the deployment phase. +# check if we are running as part of CI verify job +GERRIT_PROJECT="${GERRIT_PROJECT:-}" +if [[ "$GERRIT_PROJECT" == "infra/engine" ]]; then + REPO_GIT_URL="https://gerrit.nordix.org/infra/engine.git" + echo "Info : Running in CI - infra/engine patch will be packaged for testing." + echo " Checking out the change/patch $GERRIT_REFSPEC for $REPO_GIT_URL" + # navigate to the folder and checkout the patch + cd "$OFFLINE_PKG_FOLDER/git/engine" + git fetch "$REPO_GIT_URL" "$GERRIT_REFSPEC" && git checkout FETCH_HEAD +fi + +# compress & archive offline dependencies +tar -C "$OFFLINE_PKG_FOLDER" -czf "$OFFLINE_PKG_FILE" . + +# remove intermediate offline pkg folder +rm -rf "$OFFLINE_PKG_FOLDER" + +# create self extracting installer +cat /tmp/decompress.sh "$OFFLINE_PKG_FILE" > "$OFFLINE_INSTALLER_FILE" +chmod +x "$OFFLINE_INSTALLER_FILE" + +# remove intermediate offline pkg file +rm -rf "$OFFLINE_PKG_FILE" + +# vim: set ts=2 sw=2 expandtab: