From 016e0d738031c00bb6cfa4a433e763413e14b757 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 8 Jun 2017 14:22:58 -0700 Subject: [PATCH] Add explicit multiarch support in "generate-stackbrew-library.sh" --- generate-stackbrew-library.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 23fb11bd..0db8152f 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -34,6 +34,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 'redis' + cat <<-EOH # this file is generated via https://github.com/docker-library/redis/blob/$(fileCommit "$self")/$self @@ -59,9 +75,13 @@ for version in "${versions[@]}"; do ${aliases[$version]:-} ) + parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")" + arches="${parentRepoToArches[$parent]}" + echo cat <<-EOE Tags: $(join ', ' "${versionAliases[@]}") + Architectures: $(join ', ' $arches) GitCommit: $commit Directory: $version EOE @@ -87,9 +107,19 @@ for version in "${versions[@]}"; do variantAliases=( "${versionAliases[@]/%/-$variant}" ) variantAliases=( "${variantAliases[@]//latest-/}" ) + case "$v" in + 32bit) variantArches='amd64' ;; + windows/*) variantArches='windows-amd64' ;; + *) + 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: $dir EOE