Dockerfile: variant support in frozen-images stage

using TARGETVARIANT in frozen-images stage implies changes in
`download-frozen-image-v2.sh` script to add support for variants
so we are able to build against more platforms.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-09-08 16:13:41 +02:00
parent d806d0760d
commit 25dc760162
2 changed files with 12 additions and 3 deletions

View File

@@ -261,6 +261,10 @@ get_target_arch() {
echo amd64
}
get_target_variant() {
echo "${TARGETVARIANT:-}"
}
while [ $# -gt 0 ]; do
imageTag="$1"
shift
@@ -311,11 +315,13 @@ while [ $# -gt 0 ]; do
found=""
targetArch="$(get_target_arch)"
targetVariant="$(get_target_variant)"
# parse first level multi-arch manifest
for i in "${!layers[@]}"; do
layerMeta="${layers[$i]}"
maniArch="$(echo "$layerMeta" | jq --raw-output '.platform.architecture')"
if [ "$maniArch" = "${targetArch}" ]; then
maniVariant="$(echo "$layerMeta" | jq --raw-output '.platform.variant')"
if [[ "$maniArch" = "${targetArch}" ]] && [[ -z "${targetVariant}" || "$maniVariant" = "${targetVariant}" ]]; then
digest="$(echo "$layerMeta" | jq --raw-output '.digest')"
# get second level single manifest
submanifestJson="$(
@@ -332,7 +338,7 @@ while [ $# -gt 0 ]; do
fi
done
if [ -z "$found" ]; then
echo >&2 "error: manifest for $maniArch is not found"
echo >&2 "error: manifest for ${targetArch}${targetVariant:+/${targetVariant}} is not found"
exit 1
fi
;;