Skip to content

Commit

Permalink
feat: add precedent image lists into iso image (#687)
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 885f7bf)

Co-authored-by: Zespre Chang <[email protected]>
  • Loading branch information
mergify[bot] and starbops authored Mar 28, 2024
1 parent 8604faf commit c3fff7f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
45 changes: 45 additions & 0 deletions scripts/archive-images-lists.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions scripts/package-harvester-os
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c3fff7f

Please sign in to comment.