1
0
mirror of https://github.com/MariaDB/mariadb-docker.git synced 2025-04-19 06:02:18 +03:00
mariadb/.architectures-lib
Daniel Black 8eaa306576 generate architectures: ubi architectures cannot retreived with bashbrew
For the moment hard code it, but using docker manifest inspect is almost
there if something more automated is required.
2024-05-30 14:19:31 +10:00

49 lines
1.5 KiB
Bash

#!/usr/bin/env bash
hasBashbrewArch() {
local version="$1"; shift
local bashbrewArch="$1"; shift
local arches="$(grep -m1 'bashbrew-architectures:' "$version/Dockerfile" | cut -d':' -f2)"
[[ " $arches " == *" $bashbrewArch "* ]]
}
_generateParentRepoToArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
eval "declare -g -A parentRepoToArches=( $(
find . -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|.*\/.*)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
# could do, but returns arm64 rather than arm64v8
#readarray -t ubiarch < <(docker manifest inspect redhat/ubi9-minimal | jq '.manifests[].platform.architecture')
local ubiarch=(amd64 arm64v8 s390x ppc64le)
parentRepoToArches[redhat/ubi9-minimal]=${ubiarch[@]//\"/}
}
_generateParentRepoToArches 'mariadb'
parentArches() {
local version="$1"; shift # "1.8", etc
local parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
echo "${parentRepoToArches[$parent]:-}"
}
versionArches() {
local version="$1"; shift # "1.8", etc
local parentArches="$(parentArches "$version")"
local variantArches=()
for arch in $parentArches; do
if hasBashbrewArch "$version" "$arch"; then
variantArches+=( "$arch" )
fi
done
echo "${variantArches[*]}"
}