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 23, 2024
1 parent c315870 commit 9f9d663
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions UBI/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ generate_redhat() {

# cache the result
echo "Getting latest UBI versions"
echo "the ubi releases are $ubi8Release and $ubi9Release"
# get_latest_ubi_base $ubi8Release >/dev/null
# get_latest_ubi_base $ubi9Release >/dev/null
# get_latest_barman_version >/dev/null
Expand All @@ -212,17 +211,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 All @@ -248,21 +239,19 @@ generate_redhat() {
echo "$version: ${postgresqlVersion}"

if [ -f "${versionFile}" ]; then
echo "versionFile exists"
oldUbi8Version=$(jq -r '.UBI8_VERSION' "${versionFile}")
oldUbi9Version=$(jq -r '.UBI9_VERSION' "${versionFile}")
oldPostgresqlVersion=$(jq -r '.POSTGRES_VERSION' "${versionFile}")
oldBarmanVersion=$(jq -r '.BARMAN_VERSION' "${versionFile}")
oldImageReleaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")
imageReleaseVersion=$oldImageReleaseVersion
else
echo "versionFile does not exist"
imageReleaseVersion=1

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 +264,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 +281,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 +296,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 +306,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 +316,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 +326,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 +336,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 +346,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 +421,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 +431,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 +481,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 +493,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 +506,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 9f9d663

Please sign in to comment.