From 48ad4b7d1c2d581ab2426b460e331a5ea023425a Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Thu, 15 Jun 2017 15:49:20 -0700 Subject: [PATCH] Add explicit multiarch support in "generate-stackbrew-library.sh" --- generate-stackbrew-library.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index f6535b329..e94e9e081 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -33,6 +33,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 'ruby' + cat <<-EOH # this file is generated via https://github.com/docker-library/ruby/blob/$(fileCommit "$self")/$self @@ -51,6 +67,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 == "RUBY_VERSION" { print $3; exit }')" versionAliases=( @@ -62,6 +81,7 @@ for version in "${versions[@]}"; do echo cat <<-EOE Tags: $(join ', ' "${versionAliases[@]}") + Architectures: $(join ', ' $arches) GitCommit: $commit Directory: $version EOE @@ -74,9 +94,18 @@ for version in "${versions[@]}"; do variantAliases=( "${versionAliases[@]/%/-$variant}" ) variantAliases=( "${variantAliases[@]//latest-/}" ) + case "$variant" in + onbuild) variantArches="$arches" ;; + *) + variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")" + variantArches="${parentRepoToArches[$variantParent]}" + ;; + esac + echo cat <<-EOE Tags: $(join ', ' "${variantAliases[@]}") + Architectures: $(join ', ' $variantArches) GitCommit: $commit Directory: $version/$variant EOE