Fatih Degirmenci | 990daf9 | 2020-06-25 12:35:16 +0000 | [diff] [blame] | 1 | #!/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 | |
| 20 | set -o errexit |
| 21 | set -o nounset |
| 22 | set -o pipefail |
| 23 | |
| 24 | export OFFLINE_PKG_FOLDER="${OFFLINE_PKG_FOLDER:-/tmp/offline-package}" |
| 25 | export 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 |
| 31 | GERRIT_PROJECT="${GERRIT_PROJECT:-}" |
| 32 | if [[ "$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 |
| 39 | fi |
| 40 | |
| 41 | # compress & archive offline dependencies |
| 42 | tar -C "$OFFLINE_PKG_FOLDER" -czf "$OFFLINE_PKG_FILE" . |
| 43 | |
| 44 | # remove intermediate offline pkg folder |
| 45 | rm -rf "$OFFLINE_PKG_FOLDER" |
| 46 | |
| 47 | # create self extracting installer |
| 48 | cat /tmp/decompress.sh "$OFFLINE_PKG_FILE" > "$OFFLINE_INSTALLER_FILE" |
| 49 | chmod +x "$OFFLINE_INSTALLER_FILE" |
| 50 | |
| 51 | # remove intermediate offline pkg file |
| 52 | rm -rf "$OFFLINE_PKG_FILE" |
| 53 | |
| 54 | # vim: set ts=2 sw=2 expandtab: |