blob: cde42656067c187dbcd61ff8a8e5b8bf1e6c13f8 [file] [log] [blame]
Michal Ptacek5a269d22019-01-28 13:03:16 +00001#! /usr/bin/env bash
2
3# COPYRIGHT NOTICE STARTS HERE
4#
5# Copyright 2018 © Samsung Electronics Co., Ltd.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19# COPYRIGHT NOTICE ENDS HERE
20
21# This simple script should be used during build / packaging process
22# and it should be referenced in BuildGuide.
23# Patching of helm charts is the only way for OOM charts to be compatible
24# with this offline installer. This will become obsolete once native
25# solution is implemented in charts themselves and which is tracked
26# in OOM-1610
27
28# fail fast
29set -e
30
31# colours
32_R='\033[0;31;1m' #Red
33_G='\033[0;32;1m' #Green
34_Y='\033[0;33;1m' #Yellow
35C_='\033[0m' #Color off
36
37usage () {
38 echo "Usage:"
39 echo -e "./$(basename $0) <helm charts repo> <commit/tag/branch> <patchfile> <target_dir>\n"
40 echo "Example: ./$(basename $0) https://gerrit.onap.org/r/oom 3.0.0-ONAP /root/offline-installer/patches/casablanca_3.0.0.patch /root/offline-installer/ansible/application/helm_charts"
41}
42
43if [ "$#" -ne 4 ]; then
44 echo "This script should get exactly 4 arguments!"
45 echo -e "Wrong number of parameters provided\n"
46 usage
47 exit 1
48fi
49
50# main
51# git and patch tools are preconditions for this to work
52CURR=1
53TOTAL=5
Milan Verespejc9ea08f2019-02-06 12:29:00 +010054PATCH_FILE=$(realpath "${3}")
Michal Ptacek5a269d22019-01-28 13:03:16 +000055
56echo -e "${_G}[Step $((CURR++))/${TOTAL} cloning repo with charts to be patched]${C_}"
57git clone "${1}" "${4}"
58
59echo -e "${_G}[Step $((CURR++))/${TOTAL} setting working dir to ${4}]${C_}"
60pushd "${4}"
61
62echo -e "${_G}[Step $((CURR++))/${TOTAL} git-checkout to correct base]${C_}"
63git checkout "${2}"
64
65echo -e "${_G}[Step $((CURR++))/${TOTAL} patching charts]${C_}"
Milan Verespejc9ea08f2019-02-06 12:29:00 +010066git apply "${PATCH_FILE}"
Michal Ptacek5a269d22019-01-28 13:03:16 +000067
68echo -e "${_G}[Step $((CURR++))/${TOTAL} returning to original working directory]${C_}"
69popd
70