Michal Ptacek | 5a269d2 | 2019-01-28 13:03:16 +0000 | [diff] [blame^] | 1 | #! /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 |
| 29 | set -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 |
| 35 | C_='\033[0m' #Color off |
| 36 | |
| 37 | usage () { |
| 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 | |
| 43 | if [ "$#" -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 |
| 48 | fi |
| 49 | |
| 50 | # main |
| 51 | # git and patch tools are preconditions for this to work |
| 52 | CURR=1 |
| 53 | TOTAL=5 |
| 54 | |
| 55 | echo -e "${_G}[Step $((CURR++))/${TOTAL} cloning repo with charts to be patched]${C_}" |
| 56 | git clone "${1}" "${4}" |
| 57 | |
| 58 | echo -e "${_G}[Step $((CURR++))/${TOTAL} setting working dir to ${4}]${C_}" |
| 59 | pushd "${4}" |
| 60 | |
| 61 | echo -e "${_G}[Step $((CURR++))/${TOTAL} git-checkout to correct base]${C_}" |
| 62 | git checkout "${2}" |
| 63 | |
| 64 | echo -e "${_G}[Step $((CURR++))/${TOTAL} patching charts]${C_}" |
| 65 | patch -p0 < "${3}" |
| 66 | |
| 67 | echo -e "${_G}[Step $((CURR++))/${TOTAL} returning to original working directory]${C_}" |
| 68 | popd |
| 69 | |