blob: c28264decb59146dfe366fda69a79eee4eee4826 [file] [log] [blame]
#!/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: