Skip to content

Commit 6a6a5a9

Browse files
authored
Merge pull request #36 from infosiftr/archy
Add function to get architectures of parent images so each gcc image has the same set
2 parents cf8ed54 + 6fc3052 commit 6a6a5a9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

generate-stackbrew-library.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ dirCommit() {
3434
)
3535
}
3636

37+
getArches() {
38+
local repo="$1"; shift
39+
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
40+
41+
eval "declare -A -g parentRepoToArches=( $(
42+
find -name 'Dockerfile' -exec awk '
43+
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
44+
print "'"$officialImagesUrl"'" $2
45+
}
46+
' '{}' + \
47+
| sort -u \
48+
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
49+
) )"
50+
}
51+
getArches 'gcc'
52+
3753
cat <<-EOH
3854
# this file is generated via https://github.com/docker-library/gcc/blob/$(fileCommit "$self")/$self
3955
@@ -51,6 +67,9 @@ join() {
5167

5268
for version in "${versions[@]}"; do
5369
commit="$(dirCommit "$version")"
70+
parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
71+
# no arm32 for now: https://github.com/docker-library/gcc/issues/37
72+
arches="$(echo " ${parentRepoToArches[$parent]} " | sed -r 's/ arm32v[^ ]+ / /g')"
5473

5574
dockerfile="$(git show "$commit":"$version/Dockerfile")"
5675
fullVersion="$(echo "$dockerfile" | awk '$1 == "ENV" && $2 == "GCC_VERSION" { print $3; exit }')"
@@ -69,6 +88,7 @@ for version in "${versions[@]}"; do
6988
echo "$dockerfile" | grep -m1 '^# Last Modified: '
7089
cat <<-EOE
7190
Tags: $(join ', ' "${versionAliases[@]}")
91+
Architectures: $(join ', ' $arches)
7292
GitCommit: $commit
7393
Directory: $version
7494
EOE

0 commit comments

Comments
 (0)