|
| 1 | +#!/usr/bin/env bash |
| 2 | +NEED_COMMIT=false |
| 3 | + |
| 4 | +set -euo pipefail |
| 5 | + |
| 6 | +echo "${PRIVATE_YML}" > postgres-release/config/private.yml |
| 7 | + |
| 8 | +get_old_blob_path() { |
| 9 | + local blobs_file="config/blobs.yml" |
| 10 | + if grep -q "^icu/" "$blobs_file"; then |
| 11 | + grep "^icu/" "$blobs_file" | head -1 | cut -f1 -d: |
| 12 | + else |
| 13 | + echo "" |
| 14 | + fi |
| 15 | +} |
| 16 | + |
| 17 | +pushd postgres-release |
| 18 | + CURRENT_BLOBS=$(bosh blobs) |
| 19 | + BLOB_PATH=$(echo ../icu-src/icu4c-*-sources.tgz) |
| 20 | + FILENAME=$(basename "${BLOB_PATH}") |
| 21 | + |
| 22 | + expected_sha512=$(awk -v fname="${FILENAME}" '$0 ~ ("\\*" fname "$") {print $1}' ../icu-src/SHASUM512.txt) |
| 23 | + actual_sha512=$(sha512sum "${BLOB_PATH}" | awk '{print $1}') |
| 24 | + if [ "$expected_sha512" != "$actual_sha512" ]; then |
| 25 | + echo "SHA-512 verification failed for ${FILENAME}" |
| 26 | + echo "Expected: $expected_sha512" |
| 27 | + echo "Actual: $actual_sha512" |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + echo "SHA-512 verified: $actual_sha512" |
| 31 | + |
| 32 | + OLD_BLOB_PATH=$(get_old_blob_path) |
| 33 | + |
| 34 | + if ! echo "${CURRENT_BLOBS}" | grep -q "${FILENAME}"; then |
| 35 | + NEED_COMMIT=true |
| 36 | + echo "adding ${FILENAME}" |
| 37 | + bosh add-blob --sha2 "${BLOB_PATH}" "icu/${FILENAME}" |
| 38 | + if [[ -n "${OLD_BLOB_PATH}" ]]; then |
| 39 | + bosh remove-blob "${OLD_BLOB_PATH}" |
| 40 | + fi |
| 41 | + bosh upload-blobs |
| 42 | + fi |
| 43 | + |
| 44 | + if [ "${NEED_COMMIT}" = "true" ]; then |
| 45 | + echo "-----> $(date): Creating git commit" |
| 46 | + git config user.name "$GIT_USER_NAME" |
| 47 | + git config user.email "$GIT_USER_EMAIL" |
| 48 | + git add . |
| 49 | + |
| 50 | + git --no-pager diff --cached |
| 51 | + if [[ "$( git status --porcelain )" != "" ]]; then |
| 52 | + git commit -am "Bump packages" |
| 53 | + fi |
| 54 | + fi |
| 55 | +popd |
0 commit comments