|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -euo pipefail |
| 17 | + |
| 18 | +SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" |
| 19 | +UPSTREAM_DIR="${SCRIPT_ROOT}/../upstream" |
| 20 | +STABLE_DIR="${SCRIPT_ROOT}/../stable" |
| 21 | +BUILD_DIR="${SCRIPT_ROOT}/../build/upstream" |
| 22 | + |
| 23 | +rm -rf "${BUILD_DIR}" |
| 24 | +mkdir -p "${BUILD_DIR}" |
| 25 | + |
| 26 | +for chart_dir in "${UPSTREAM_DIR}"/*/; do |
| 27 | + chart_name=$(basename "${chart_dir}") |
| 28 | + git_tag=$(cat "${chart_dir}/GIT_TAG" | tr -d '[:space:]') |
| 29 | + repo=$(cat "${chart_dir}/REPO" | tr -d '[:space:]') |
| 30 | + chart_path=$(cat "${chart_dir}/CHART_PATH" | tr -d '[:space:]') |
| 31 | + |
| 32 | + echo "Preparing ${chart_name} from ${repo}@${git_tag}" |
| 33 | + git clone --depth 1 --branch "${git_tag}" "${repo}" "${BUILD_DIR}/${chart_name}" 2>/dev/null |
| 34 | + cp -r "${BUILD_DIR}/${chart_name}/${chart_path}" "${STABLE_DIR}/${chart_name}" |
| 35 | + |
| 36 | + if [ -d "${chart_dir}/patches" ]; then |
| 37 | + for patch in "${chart_dir}"/patches/*.patch; do |
| 38 | + [ -f "${patch}" ] || continue |
| 39 | + echo " Applying patch: $(basename ${patch})" |
| 40 | + cd "${STABLE_DIR}/${chart_name}" |
| 41 | + patch -p3 < "${patch}" |
| 42 | + cd - >/dev/null |
| 43 | + done |
| 44 | + fi |
| 45 | +done |
| 46 | + |
| 47 | +rm -rf "${BUILD_DIR}" |
| 48 | +echo "✅ Upstream charts prepared" |
0 commit comments