From 885f7bfc25b5ddda0c94fb5502acd0292d56284b Mon Sep 17 00:00:00 2001 From: Zespre Chang Date: Thu, 18 Jan 2024 15:29:05 +0800 Subject: [PATCH] feat: add precedent image lists into iso image This will add all the previous versions' published image lists into the ISO image according to the upgrade matrix file in harvester repo Signed-off-by: Zespre Chang --- scripts/archive-images-lists.sh | 45 +++++++++++++++++++++++++++++++++ scripts/package-harvester-os | 3 +++ 2 files changed, 48 insertions(+) create mode 100755 scripts/archive-images-lists.sh diff --git a/scripts/archive-images-lists.sh b/scripts/archive-images-lists.sh new file mode 100755 index 000000000..02fec83bb --- /dev/null +++ b/scripts/archive-images-lists.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh +set -e + +UPGRADE_MATRIX_FILE=$1 +IMAGES_LISTS_DIR=$2 +RANCHERD_IMAGES_DIR=$3 +IMAGES_LISTS_ARCHIVE_DIR=$4 + +WORKING_DIR=$(mktemp -d) + +if [ ! -e "$UPGRADE_MATRIX_FILE" ]; then + echo "Could not find $UPGRADE_MATRIX_FILE, skip it" + exit 0 +fi + +# Add all the current version's images lists +mkdir -p "$IMAGES_LISTS_ARCHIVE_DIR"/current +find $IMAGES_LISTS_DIR -name "*.txt" -exec cat {} \; >> "$IMAGES_LISTS_ARCHIVE_DIR"/current/image_list_all.txt +find $RANCHERD_IMAGES_DIR -name "*.txt" -exec cat {} \; >> "$IMAGES_LISTS_ARCHIVE_DIR"/current/image_list_all.txt +cat "$IMAGES_LISTS_ARCHIVE_DIR"/current/image_list_all.txt | sort | uniq | tee "$IMAGES_LISTS_ARCHIVE_DIR"/current/image_list_all.txt + +# Add all the previous versions' images lists +previous_versions=$(yq e ".versions[].name" "$UPGRADE_MATRIX_FILE" | xargs) +for prev_ver in $(echo "$previous_versions"); do + ret=0 + + echo "Fetching $prev_ver image lists..." + + mkdir "$WORKING_DIR"/"$prev_ver" + + curl -fL https://releases.rancher.com/harvester/"$prev_ver"/image-lists.tar.gz -o "$WORKING_DIR"/image-lists.tar.gz || ret=$? + if [ "$ret" -ne 0 ]; then + echo "Cannot download image list tarball for version $prev_ver, skip it" + continue + fi + tar -zxvf "$WORKING_DIR"/image-lists.tar.gz -C "$WORKING_DIR"/"$prev_ver"/ + + prev_image_list="$WORKING_DIR"/image_list_all.txt + cat "$WORKING_DIR"/"$prev_ver"/image-lists/*.txt | sort | uniq > "$prev_image_list" + + mkdir -p "$IMAGES_LISTS_ARCHIVE_DIR"/"$prev_ver" + cp -a "$prev_image_list" "$IMAGES_LISTS_ARCHIVE_DIR"/"$prev_ver"/ + + rm -rf "$WORKING_DIR"/* +done diff --git a/scripts/package-harvester-os b/scripts/package-harvester-os index d3a8b8306..0ddaa157e 100755 --- a/scripts/package-harvester-os +++ b/scripts/package-harvester-os @@ -36,6 +36,9 @@ kubevirt: ${HARVESTER_KUBEVIRT_VERSION} minUpgradableVersion: '${HARVESTER_MIN_UPGRADABLE_VERSION}' EOF +# Collect all the previous versions' image lists +${SCRIPTS_DIR}/archive-images-lists.sh "${TOP_DIR}/../harvester/package/upgrade-matrix.yaml" "${IMAGES_LISTS_DIR}" "${RANCHERD_IMAGES_DIR}" "${BUNDLE_DIR}/harvester/images-lists-archive" + # Collect dependencies' versions ${SCRIPTS_DIR}/collect-deps.sh harvester-release.yaml