From 5aa2d08644ac6e3f5e3b9afca213adce675afa0b Mon Sep 17 00:00:00 2001 From: Clement Verna Date: May 27 2022 07:31:04 +0000 Subject: sync-container: Fetch the fedora releases from Fedora QA maintained json Instead of having to manually update this script every time we GA a new release this change fetch the stable releases from a json file maintained by Fedora QA. We also use that info to validate the user input and exit the script for any non valid Fedora release number. Signed-off-by: Clement Verna --- diff --git a/scripts/sync-latest-container-base-image.sh b/scripts/sync-latest-container-base-image.sh index 63dc55b..319513b 100755 --- a/scripts/sync-latest-container-base-image.sh +++ b/scripts/sync-latest-container-base-image.sh @@ -30,21 +30,26 @@ EXAMPLE EOF } -if ! [[ "${1}" =~ [31|32|33|34|35|36] ]]; +if ! [[ "${1}" =~ [34|35|36] ]]; then ARCHES=("aarch64" "armhfp" "ppc64le" "s390x" "x86_64") else ARCHES=("aarch64" "ppc64le" "s390x" "x86_64") - fi + +#Get the list of all the stable releases, this json file is manually updated by Fedora QA +stable_releases=($(curl -s https://fedorapeople.org/groups/qa/metadata/release.json | jq -r '.[].stable[]')) # This is the release of Fedora that is currently stable, it will define if we # need to move the fedora:latest tag -current_stable="36" +current_stable=${stable_releases[-1]} # Define what is rawhide so we know to push that tag -current_rawhide="37" +current_rawhide="$(($current_stable+1))" +# Define all the valid releases (stable_releases + rawhide), +# it is used to validate the user input of this script +valid_releases=(${stable_releases[@]} $current_rawhide) + # Sanity checking -# FIXME - Have to update this regex every time we drop a new Fedora Release -if ! [[ "${1}" =~ [31|32|33|34|35|36|37] ]]; +if ! [[ "${valid_releases[@]}" =~ "${1}" ]]; then printf "ERROR: FEDORA_RELEASE missing or invalid\n" f_help @@ -71,14 +76,6 @@ fi if [[ ${1} -eq "$current_rawhide" ]]; then tagname="rawhide" fi -# -# Version should not be higher than rawhide -# Either there is a mistake or script is out of date -# -if [[ ${1} -gt "$current_rawhide" ]]; then - printf "ERROR: VERSION HIGHER THAN RAWHIDE" - exit(1) -fi minimal_build_name=$(koji -q latest-build --type=image f${1}-updates-candidate Fedora-Container-Minimal-Base | awk '{print $1}') if [[ -n ${build_name} ]]; then