From: Mark Beierl Date: Wed, 12 Jul 2023 18:06:04 +0000 (-0400) Subject: Use highest base for charms X-Git-Tag: v14.0.1~7 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=d9c560c4b7578f1a6bdd485024e9519d49549d5a;p=osm%2Fdevops.git Use highest base for charms Updates to check if the charm being promoted uses 22.04 as its base, and promote that one instead of 20.04 Change-Id: Ia5e34419729b1a2969eb4c10981aeeecc76fe544 Signed-off-by: Mark Beierl (cherry picked from commit 2dc01891e9c90760f7e421b53f7b63a89b5ce403) --- diff --git a/tools/promote-charms-and-snaps.sh b/tools/promote-charms-and-snaps.sh index a83001d6..1ace0dc9 100755 --- a/tools/promote-charms-and-snaps.sh +++ b/tools/promote-charms-and-snaps.sh @@ -59,16 +59,25 @@ for charm in \ echo "${charm}" charmcraft status $charm --format json > ${charm}.json - isCharm=$(grep architecture ${charm}.json | wc -l) + isCharm=$(grep architecture ${charm}.json | wc -l 2>/dev/null) resourceArgument="" if [ $isCharm -gt 0 ]; then - SOURCE_REV=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .version"|head -1) - TARGET_REV=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$CHANNEL/$TARGET\")| .version"|head -1) + base=20.04 + is2204=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"22.04\")"|wc -l) + if [ $is2204 -gt 0 ]; then + base=22.04 + fi + + + SOURCE_REV=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .version"|head -1) + TARGET_REV=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$TARGET\")| .version"|head -1) + + index=0 while [ $index -lt 5 ]; do - resourceName=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .resources[$index].name"|head -1) - resourceRevs=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .resources[$index].revision"|head -1) + resourceName=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .resources[$index].name"|head -1) + resourceRevs=$(cat ${charm}.json | jq -r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .resources[$index].revision"|head -1) if [ "$resourceName" != "null" ] ; then resourceArgument=" $resourceArgument --resource ${resourceName}:${resourceRevs}" else