Skip to content

Commit

Permalink
Merge pull request #206 from infosiftr/archy
Browse files Browse the repository at this point in the history
Add explicit multiarch support in "generate-stackbrew-library.sh"
  • Loading branch information
tianon authored Jun 16, 2017
2 parents 6d31b8c + 8baafd1 commit 0be13f0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ dirCommit() {
)
}

getArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'

eval "declare -A -g parentRepoToArches=( $(
find -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
}
getArches 'python'

cat <<-EOH
# this file is generated via https://github.com/docker-library/python/blob/$(fileCommit "$self")/$self
Expand All @@ -53,6 +69,9 @@ join() {
for version in "${versions[@]}"; do
commit="$(dirCommit "$version")"

parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
arches="${parentRepoToArches[$parent]}"

fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "PYTHON_VERSION" { print $3; exit }')"

versionAliases=(
Expand All @@ -64,6 +83,7 @@ for version in "${versions[@]}"; do
echo
cat <<-EOE
Tags: $(join ', ' "${versionAliases[@]}")
Architectures: $(join ', ' $arches)
GitCommit: $commit
Directory: $version
EOE
Expand All @@ -82,9 +102,19 @@ for version in "${versions[@]}"; do
variantAliases=( "${versionAliases[@]/%/-$variant}" )
variantAliases=( "${variantAliases[@]//latest-/}" )

case "$v" in
windows/*) variantArches='windows-amd64' ;;
onbuild) variantArches="$arches" ;;
*)
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$v/Dockerfile")"
variantArches="${parentRepoToArches[$variantParent]}"
;;
esac

echo
cat <<-EOE
Tags: $(join ', ' "${variantAliases[@]}")
Architectures: $(join ', ' $variantArches)
GitCommit: $commit
Directory: $dir
EOE
Expand Down

0 comments on commit 0be13f0

Please sign in to comment.