Skip to content

Commit 74857f4

Browse files
authored
Merge pull request docker-library#298 from infosiftr/multiarch
Add proper Architectures entries in "generate-stackbrew-library.sh"
2 parents 2b0f642 + d1c4c70 commit 74857f4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

generate-stackbrew-library.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ dirCommit() {
3636
)
3737
}
3838

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

57-
fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "PG_VERSION" { gsub(/-.*$/, "", $3); gsub(/~/, "-", $3); print $3; exit }')"
73+
pgdgVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "PG_VERSION" { print $3; exit }')"
74+
fullVersion="${pgdgVersion%%-*}"
75+
fullVersion="${fullVersion//'~'/-}"
5876

5977
versionAliases=()
6078
while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do
@@ -66,9 +84,19 @@ for version in "${versions[@]}"; do
6684
${aliases[$version]:-}
6785
)
6886

87+
versionParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
88+
versionArches=()
89+
# http://apt.postgresql.org/pub/repos/apt/dists/jessie-pgdg/main/
90+
for arch in amd64 i386 ppc64le; do
91+
if [[ " ${parentRepoToArches[$versionParent]} " =~ " $arch " ]]; then
92+
versionArches+=( "$arch" )
93+
fi
94+
done
95+
6996
echo
7097
cat <<-EOE
7198
Tags: $(join ', ' "${versionAliases[@]}")
99+
Architectures: $(join ', ' "${versionArches[@]}")
72100
GitCommit: $commit
73101
Directory: $version
74102
EOE
@@ -81,9 +109,13 @@ for version in "${versions[@]}"; do
81109
variantAliases=( "${versionAliases[@]/%/-$variant}" )
82110
variantAliases=( "${variantAliases[@]//latest-/}" )
83111

112+
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")"
113+
variantArches="${parentRepoToArches[$variantParent]}"
114+
84115
echo
85116
cat <<-EOE
86117
Tags: $(join ', ' "${variantAliases[@]}")
118+
Architectures: $(join ', ' $variantArches)
87119
GitCommit: $commit
88120
Directory: $version/$variant
89121
EOE

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy