blob: c28264decb59146dfe366fda69a79eee4eee4826 [file] [log] [blame]
Fatih Degirmenci20d34e72020-05-19 08:13:26 +00001#!/bin/bash
2# ============LICENSE_START=======================================================
3# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# SPDX-License-Identifier: Apache-2.0
18# ============LICENSE_END=========================================================
19
20set -o errexit
21set -o nounset
22set -o pipefail
23
24export OFFLINE_PKG_FOLDER="${OFFLINE_PKG_FOLDER:-/tmp/offline-package}"
25export OFFLINE_PKG_FILE="${OFFLINE_PKG_FILE:-/tmp/offline-package.tgz}"
26
27# NOTE (fdegir): In order to package and test the change for offline deployment,
28# we need to include the change/patch within the package since that is what should
29# be used during the deployment phase.
30# check if we are running as part of CI verify job
31GERRIT_PROJECT="${GERRIT_PROJECT:-}"
32if [[ "$GERRIT_PROJECT" == "infra/engine" ]]; then
33 REPO_GIT_URL="https://gerrit.nordix.org/infra/engine.git"
34 echo "Info : Running in CI - infra/engine patch will be packaged for testing."
35 echo " Checking out the change/patch $GERRIT_REFSPEC for $REPO_GIT_URL"
36 # navigate to the folder and checkout the patch
37 cd "$OFFLINE_PKG_FOLDER/git/engine"
38 git fetch "$REPO_GIT_URL" "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
39fi
40
41# compress & archive offline dependencies
42tar -C "$OFFLINE_PKG_FOLDER" -czf "$OFFLINE_PKG_FILE" .
43
44# remove intermediate offline pkg folder
45rm -rf "$OFFLINE_PKG_FOLDER"
46
47# create self extracting installer
48cat /tmp/decompress.sh "$OFFLINE_PKG_FILE" > "$OFFLINE_INSTALLER_FILE"
49chmod +x "$OFFLINE_INSTALLER_FILE"
50
51# remove intermediate offline pkg file
52rm -rf "$OFFLINE_PKG_FILE"
53
54# vim: set ts=2 sw=2 expandtab: