Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor multiarch support to go all the way to correct Architectures lines in "generate-stackbrew-library.sh" #121

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ dirCommit() {
)
}

getArches() {
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|microsoft\/[^:]+)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
}
getArches 'openjdk'

cat <<-EOH
# this file is generated via https://github.com/docker-library/openjdk/blob/$(fileCommit "$self")/$self

Expand Down Expand Up @@ -102,9 +118,13 @@ for version in "${versions[@]}"; do

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

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

echo
cat <<-EOE
Tags: $(join ', ' $(aliases "$javaVersion" "$javaType" "$fullVersion"))
Architectures: $(join ', ' $arches)
GitCommit: $commit
Directory: $version
EOE
Expand All @@ -122,9 +142,18 @@ for version in "${versions[@]}"; do

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

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

echo
cat <<-EOE
Tags: $(join ', ' $(aliases "$javaVersion" "$javaType" "$fullVersion" "$variant"))
Architectures: $(join ', ' $variantArches)
GitCommit: $commit
Directory: $dir
EOE
Expand Down