blob: 5000dbf5799c0689a8e34de123ae3976e1bc0b7e [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
54
55echo -e "${_G}[Step $((CURR++))/${TOTAL} cloning repo with charts to be patched]${C_}"
56git clone "${1}" "${4}"
57
58echo -e "${_G}[Step $((CURR++))/${TOTAL} setting working dir to ${4}]${C_}"
59pushd "${4}"
60
61echo -e "${_G}[Step $((CURR++))/${TOTAL} git-checkout to correct base]${C_}"
62git checkout "${2}"
63
64echo -e "${_G}[Step $((CURR++))/${TOTAL} patching charts]${C_}"
65patch -p0 < "${3}"
66
67echo -e "${_G}[Step $((CURR++))/${TOTAL} returning to original working directory]${C_}"
68popd
69