From d5270308d66ba8d632350e5c3e16362270097efd Mon Sep 17 00:00:00 2001 From: yuyr Date: Tue, 30 Jun 2026 17:24:36 +0800 Subject: [PATCH] fix installer image retag --- deploy/arm64-installer/scripts/common.sh | 39 ++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/deploy/arm64-installer/scripts/common.sh b/deploy/arm64-installer/scripts/common.sh index 58141a6..11008aa 100644 --- a/deploy/arm64-installer/scripts/common.sh +++ b/deploy/arm64-installer/scripts/common.sh @@ -342,21 +342,54 @@ install_docker_if_missing() { load_installer_images() { require_cmd docker shopt -s nullglob - local image + local image load_output desired_tag local found=0 for image in "$INSTALLER_ROOT"/images/*.tar "$INSTALLER_ROOT"/images/*.tar.gz; do found=1 log "loading docker image: $image" if [[ "$image" == *.gz ]]; then - gzip -dc "$image" | docker load + load_output="$(gzip -dc "$image" | docker load)" else - docker load -i "$image" + load_output="$(docker load -i "$image")" + fi + printf '%s\n' "$load_output" + desired_tag="" + case "$(basename "$image")" in + "${image_tar:-}") + desired_tag="${image_tag:-$RPKI_IMAGE}" + ;; + "${prometheus_image_tar:-}") + desired_tag="${prometheus_image:-$PROMETHEUS_IMAGE}" + ;; + "${grafana_image_tar:-}") + desired_tag="${grafana_image:-$GRAFANA_IMAGE}" + ;; + esac + if [[ -n "$desired_tag" ]]; then + ensure_loaded_image_tag "$desired_tag" "$load_output" "$image" fi done shopt -u nullglob (( found == 1 )) || warn "no image tar found under $INSTALLER_ROOT/images" } +ensure_loaded_image_tag() { + local desired_tag="$1" + local load_output="$2" + local image_path="$3" + if docker image inspect "$desired_tag" >/dev/null 2>&1; then + return 0 + fi + local loaded_ref="" + loaded_ref="$(printf '%s\n' "$load_output" | awk -F'Loaded image: ' '/Loaded image: / {print $2; exit}')" + if [[ -z "$loaded_ref" ]]; then + loaded_ref="$(printf '%s\n' "$load_output" | awk -F'Loaded image ID: ' '/Loaded image ID: / {print $2; exit}')" + fi + [[ -n "$loaded_ref" ]] || die "unable to determine loaded image reference for $image_path" + log "tagging loaded image for package use: source=$loaded_ref target=$desired_tag" + docker tag "$loaded_ref" "$desired_tag" +} + ensure_binfmt_if_needed() { require_cmd docker load_env