Skip to content

Commit

Permalink
fix: preserve unsigned image tag upon rebase (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsherman authored Oct 3, 2023
2 parents 6305410 + 8271032 commit 75fd78b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions files/etc/ublue-update.d/system/00-system-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
check_for_rebase() {
IMAGE_REF_FILE="$1"
if [ -f "$IMAGE_REF_FILE" ]; then
LOCAL_IMAGE_REF=$(rpm-ostree status --pending-exit-77 -b --json | jq -r '.deployments[0]["container-image-reference"]')
if [[ "$LOCAL_IMAGE_REF" == "null" ]]; then

STATUS_COMMAND="rpm-ostree status --pending-exit-77 -b --json"
LOCAL_IMAGE_REF=$($STATUS_COMMAND | jq -r '.deployments[0]["container-image-reference"]' | sed 's@ostree-unverified-registry:@ostree-unverified-image:docker://@g')

if ! $STATUS_COMMAND >/dev/null || [[ "$LOCAL_IMAGE_REF" == "null" ]]; then
# if jq failed to get the variable, or rpm-ostree had a nonzero exit code, return
return
fi

LOCAL_IMAGE_PREFIX=$(echo "$LOCAL_IMAGE_REF" | awk -F ":" '{print $1}')
LOCAL_IMAGE_REF_UNTAGGED=$(echo "$LOCAL_IMAGE_REF" | awk -F ":" '{print $1":"$2":"$3}')
LOCAL_IMAGE_REF_TAG=$(echo "$LOCAL_IMAGE_REF" | awk -F ":" '{print $4}')

IMAGE_REF=$(jq -r '."image-ref"' < "$IMAGE_REF_FILE")
IMAGE_TAG=$(jq -r '."image-tag"' < "$IMAGE_REF_FILE")

if [[ "$LOCAL_IMAGE_REF_UNTAGGED" != "$IMAGE_REF" ]]; then
if [[ "$LOCAL_IMAGE_PREFIX" == "ostree-unverified-image" ]]; then
# preserve image tags
IMAGE_TAG="$LOCAL_IMAGE_REF_TAG"
fi
/usr/bin/rpm-ostree rebase "$IMAGE_REF:$IMAGE_TAG"
exit
fi
Expand Down

0 comments on commit 75fd78b

Please sign in to comment.