Skip to content

Commit

Permalink
fixing update script
Browse files Browse the repository at this point in the history
Signed-off-by: John Long <[email protected]>
  • Loading branch information
jlong49 committed Jan 22, 2024
1 parent c315870 commit d70465b
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions UBI/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,9 @@ generate_redhat() {
return
fi

ubi9_pg_x86_64=$(get_postgresql_version "${ubi9Release}" 'x86_64' "$version")
ubi9_pg_ppc64le=$(get_postgresql_version "${ubi9Release}" 'ppc64le' "$version")
ubi9_pg_s390x=$(get_postgresql_version "${ubi9Release}" 's390x' "$version")
ubi9_pg_arm64=$(get_postgresql_version "${ubi9Release}" 'aarch64' "$version")
if ! compare_architecture_pkgs "$ubi9_pg_x86_64" "$ubi9_pg_arm64" "$ubi9_pg_ppc64le" "$ubi9_pg_s390x"; then
return
fi

postgresqlVersion="${ubi8_pg_x86_64}"
if [ -z "$postgresqlVersion" ]; then
echo "Unable to retrieve latest PostgreSQL $version version"
postgresqlUBI8Version="${ubi8_pg_x86_64}"
if [ -z "$postgresqlUBI8Version" ]; then
echo "Unable to retrieve latest PostgreSQL $version version for UBI $ubi8Release"
return
fi

Expand Down Expand Up @@ -262,7 +254,7 @@ generate_redhat() {
echo "{}" > "${versionFile}"
record_version "${versionFile}" "UBI8_VERSION" "${ubi8Version}"
record_version "${versionFile}" "UBI9_VERSION" "${ubi9Version}"
record_version "${versionFile}" "POSTGRES_VERSION" "${postgresqlVersion}"
record_version "${versionFile}" "POSTGRES_VERSION" "${postgresqlUBI8Version}"
record_version "${versionFile}" "BARMAN_VERSION" "${barmanVersion}"
record_version "${versionFile}" "IMAGE_RELEASE_VERSION" "${imageReleaseVersion}"

Expand All @@ -275,13 +267,13 @@ generate_redhat() {
if [ "$oldUbi8Version" != "$ubi8Version" ]; then
echo "UBI changed from $oldUbi8Version to $ubi8Version"
newRelease="true"
record_version "${versionFile}" "UBI_VERSION" "${ubi8Version}"
record_version "${versionFile}" "UBI8_VERSION" "${ubi8Version}"
fi

if [ "$oldUbi9Version" != "$ubi9Version" ]; then
echo "UBI changed from $oldUbi9Version to $ubi9Version"
newRelease="true"
record_version "${versionFile}" "UBI_VERSION" "${ubi9Version}"
record_version "${versionFile}" "UBI9_VERSION" "${ubi9Version}"
fi

# Detect an update of Barman
Expand All @@ -292,9 +284,9 @@ generate_redhat() {
fi

# Detect an update of PostgreSQL
if [ "$oldPostgresqlVersion" != "$postgresqlVersion" ]; then
echo "PostgreSQL changed from $oldPostgresqlVersion to $postgresqlVersion"
record_version "${versionFile}" "POSTGRES_VERSION" "${postgresqlVersion}"
if [ "$oldPostgresqlVersion" != "$postgresqlUBI8Version" ]; then
echo "PostgreSQL changed from $oldPostgresqlVersion to $postgresqlUBI8Version"
record_version "${versionFile}" "POSTGRES_VERSION" "${postgresqlUBI8Version}"
record_version "${versionFile}" "IMAGE_RELEASE_VERSION" 1
imageReleaseVersion=1
elif [ "$newRelease" = "true" ]; then
Expand All @@ -307,7 +299,7 @@ generate_redhat() {
-e 's/%%UBI_MAJOR_VERSION%%/'"$ubi8Release"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlUBI8Version"'/g' \
-e 's/%%PGAUDIT_VERSION%%/'"$pgauditVersion"'/g' \
-e 's/%%IMAGE_RELEASE_VERSION%%/'"$imageReleaseVersion"'/g' \
Dockerfile.template \
Expand All @@ -317,7 +309,7 @@ generate_redhat() {
-e 's/%%UBI_MAJOR_VERSION%%/'"$ubi8Release"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlUBI8Version"'/g' \
-e 's/%%PGAUDIT_VERSION%%/'"$pgauditVersion"'/g' \
-e 's/%%IMAGE_RELEASE_VERSION%%/'"$imageReleaseVersion"'/g' \
Dockerfile-multilang.template \
Expand All @@ -327,7 +319,7 @@ generate_redhat() {
-e 's/%%UBI_MAJOR_VERSION%%/'"$ubi8Release"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlUBI8Version"'/g' \
-e 's/%%PGAUDIT_VERSION%%/'"$pgauditVersion"'/g' \
-e 's/%%IMAGE_RELEASE_VERSION%%/'"$imageReleaseVersion"'/g' \
Dockerfile-multiarch.template \
Expand All @@ -337,7 +329,7 @@ generate_redhat() {
-e 's/%%UBI_MAJOR_VERSION%%/'"$ubi9Release"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlUBI8Version"'/g' \
-e 's/%%PGAUDIT_VERSION%%/'"$pgauditVersion"'/g' \
-e 's/%%IMAGE_RELEASE_VERSION%%/'"$imageReleaseVersion"'/g' \
Dockerfile.template \
Expand All @@ -347,7 +339,7 @@ generate_redhat() {
-e 's/%%UBI_MAJOR_VERSION%%/'"$ubi9Release"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlUBI8Version"'/g' \
-e 's/%%PGAUDIT_VERSION%%/'"$pgauditVersion"'/g' \
-e 's/%%IMAGE_RELEASE_VERSION%%/'"$imageReleaseVersion"'/g' \
Dockerfile-multilang.template \
Expand All @@ -357,7 +349,7 @@ generate_redhat() {
-e 's/%%UBI_MAJOR_VERSION%%/'"$ubi9Release"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlUBI8Version"'/g' \
-e 's/%%PGAUDIT_VERSION%%/'"$pgauditVersion"'/g' \
-e 's/%%IMAGE_RELEASE_VERSION%%/'"$imageReleaseVersion"'/g' \
Dockerfile-multiarch.template \
Expand Down Expand Up @@ -432,7 +424,7 @@ generate_redhat_postgis() {
echo "$version: ${postgresqlVersion} - PostGIS ${postgisVersion}"

if [ -f "${versionFile}" ]; then
oldUbiVersion=$(jq -r '.UBI8_VERSION' "${versionFile}")
oldUbiVersion=$(jq -r '.UBI_VERSION' "${versionFile}")
oldPostgresqlVersion=$(jq -r '.POSTGRES_VERSION' "${versionFile}")
oldPostgisVersion=$(jq -r '.POSTGIS_VERSION' "${versionFile}")
oldBarmanVersion=$(jq -r '.BARMAN_VERSION' "${versionFile}")
Expand All @@ -442,7 +434,7 @@ generate_redhat_postgis() {
imageReleaseVersion=1

echo "{}" > "${versionFile}"
record_version "${versionFile}" "UBI8_VERSION" "${ubiVersion}"
record_version "${versionFile}" "UBI_VERSION" "${ubiVersion}"
record_version "${versionFile}" "POSTGRES_VERSION" "${postgresqlVersion}"
record_version "${versionFile}" "POSTGIS_VERSION" "${postgisVersion}"
record_version "${versionFile}" "BARMAN_VERSION" "${barmanVersion}"
Expand Down Expand Up @@ -492,6 +484,7 @@ generate_redhat_postgis() {
cp update-postgis.sh "$version/"

sed -e 's/%%UBI_VERSION%%/'"$ubiVersion"'/g' \
-e 's/%%UBI_MAJOR_VERSION%%/'"8"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
Expand All @@ -503,6 +496,7 @@ generate_redhat_postgis() {
>"$version/Dockerfile.postgis"

sed -e 's/%%UBI_VERSION%%/'"$ubiVersion"'/g' \
-e 's/%%UBI_MAJOR_VERSION%%/'"8"'/g' \
-e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%YUM_OPTIONS%%/'"${yumOptions}"'/g' \
-e 's/%%POSTGRES_VERSION%%/'"$postgresqlVersion"'/g' \
Expand All @@ -515,9 +509,7 @@ generate_redhat_postgis() {
}

update_requirements() {
echo "Updating requirements"
barmanVersion=$(get_latest_barman_version)
echo "Latest barman version: $barmanVersion"
# If there's a new version we need to recreate the requirements files
echo "barman[cloud,azure,snappy,google] == $barmanVersion" > requirements.in

Expand Down

0 comments on commit d70465b

Please sign in to comment.