Skip to content

Commit efbcd4f

Browse files
committed
Refactor multiarch support to go all the way to correct Architectures lines in "generate-stackbrew-library.sh"
1 parent e3c5865 commit efbcd4f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

generate-stackbrew-library.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ dirCommit() {
3737
)
3838
}
3939

40+
getArches() {
41+
local repo="$1"; shift
42+
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
43+
44+
eval "declare -g -A parentRepoToArches=( $(
45+
find -name 'Dockerfile' -exec awk '
46+
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
47+
print "'"$officialImagesUrl"'" $2
48+
}
49+
' '{}' + \
50+
| sort -u \
51+
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
52+
) )"
53+
}
54+
getArches 'openjdk'
55+
4056
cat <<-EOH
4157
# this file is generated via https://github.com/docker-library/openjdk/blob/$(fileCommit "$self")/$self
4258
@@ -102,9 +118,13 @@ for version in "${versions[@]}"; do
102118

103119
fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "JAVA_VERSION" { gsub(/~/, "-", $3); print $3; exit }')"
104120

121+
parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
122+
arches="${parentRepoToArches[$parent]}"
123+
105124
echo
106125
cat <<-EOE
107126
Tags: $(join ', ' $(aliases "$javaVersion" "$javaType" "$fullVersion"))
127+
Architectures: $(join ', ' $arches)
108128
GitCommit: $commit
109129
Directory: $version
110130
EOE
@@ -122,9 +142,18 @@ for version in "${versions[@]}"; do
122142

123143
fullVersion="$(git show "$commit":"$dir/Dockerfile" | awk '$1 == "ENV" && $2 == "JAVA_VERSION" { gsub(/~/, "-", $3); print $3; exit }')"
124144

145+
case "$v" in
146+
windows/*) variantArches='windows-amd64' ;;
147+
*)
148+
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$v/Dockerfile")"
149+
variantArches="${parentRepoToArches[$variantParent]}"
150+
;;
151+
esac
152+
125153
echo
126154
cat <<-EOE
127155
Tags: $(join ', ' $(aliases "$javaVersion" "$javaType" "$fullVersion" "$variant"))
156+
Architectures: $(join ', ' $variantArches)
128157
GitCommit: $commit
129158
Directory: $dir
130159
EOE

0 commit comments

Comments
 (0)