|
|
@@ -13,6 +13,52 @@ if [ "$#" -eq 0 ]; then
|
|
|
set -- '--all'
|
|
|
fi
|
|
|
|
|
|
+_is_naughty() {
|
|
|
+ local from="$1"; shift
|
|
|
+
|
|
|
+ case "$BASHBREW_ARCH=$from" in
|
|
|
+ # a few explicitly permissible exceptions to Santa's naughty list
|
|
|
+ *=scratch \
|
|
|
+ | amd64=docker.elastic.co/elasticsearch/elasticsearch:* \
|
|
|
+ | amd64=docker.elastic.co/kibana/kibana:* \
|
|
|
+ | amd64=docker.elastic.co/logstash/logstash:* \
|
|
|
+ | windows-*=mcr.microsoft.com/windows/nanoserver:* \
|
|
|
+ | windows-*=mcr.microsoft.com/windows/servercore:* \
|
|
|
+ | windows-*=microsoft/nanoserver:* \
|
|
|
+ | windows-*=microsoft/windowsservercore:* \
|
|
|
+ ) return 1 ;;
|
|
|
+
|
|
|
+ # "x/y" and not an approved exception
|
|
|
+ */*) return 0 ;;
|
|
|
+ esac
|
|
|
+
|
|
|
+ # must be some other official image AND support our current architecture
|
|
|
+ local archSupported
|
|
|
+ if archSupported="$(bashbrew cat --format '{{ .TagEntry.HasArchitecture arch | ternary arch "" }}' "$from")" && [ -n "$archSupported" ]; then
|
|
|
+ return 1
|
|
|
+ fi
|
|
|
+
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
+_arches() {
|
|
|
+ bashbrew cat --format '
|
|
|
+ {{- range .TagEntries -}}
|
|
|
+ {{- .Architectures | join "\n" -}}
|
|
|
+ {{- "\n" -}}
|
|
|
+ {{- end -}}
|
|
|
+ ' "$@" | sort -u
|
|
|
+}
|
|
|
+
|
|
|
+_froms() {
|
|
|
+ bashbrew cat --format '
|
|
|
+ {{- range .TagEntries -}}
|
|
|
+ {{- $.DockerFrom . -}}
|
|
|
+ {{- "\n" -}}
|
|
|
+ {{- end -}}
|
|
|
+ ' "$@" | sort -u
|
|
|
+}
|
|
|
+
|
|
|
declare -A naughtyFromsArches=(
|
|
|
#[img:tag=from:tag]='arch arch ...'
|
|
|
)
|
|
|
@@ -20,10 +66,11 @@ naughtyFroms=()
|
|
|
|
|
|
tags="$(bashbrew list --uniq "$@" | sort -u)"
|
|
|
for img in $tags; do
|
|
|
- for BASHBREW_ARCH in $(bashbrew cat --format '{{ join " " .TagEntry.Architectures }}' "$img"); do
|
|
|
+ arches="$(_arches "$img")"
|
|
|
+ for BASHBREW_ARCH in $arches; do
|
|
|
export BASHBREW_ARCH
|
|
|
|
|
|
- if ! from="$(bashbrew cat --format '{{ $.DockerFrom .TagEntry }}' "$img" 2>/dev/null)"; then
|
|
|
+ if ! froms="$(_froms "$img" 2>/dev/null)"; then
|
|
|
# if we can't fetch the tags from their real locations, let's try the warehouse
|
|
|
refsList="$(
|
|
|
bashbrew list --uniq "$img" \
|
|
|
@@ -37,30 +84,21 @@ for img in $tags; do
|
|
|
fetch --no-tags --quiet \
|
|
|
https://github.com/docker-library/commit-warehouse.git \
|
|
|
$refsList
|
|
|
- from="$(bashbrew cat --format '{{ $.DockerFrom .TagEntry }}' "$img")"
|
|
|
+ froms="$(_froms "$img")"
|
|
|
fi
|
|
|
|
|
|
- case "$BASHBREW_ARCH=$from" in
|
|
|
- # a few explicitly permissible exceptions to Santa's naughty list
|
|
|
- *=scratch \
|
|
|
- | amd64=docker.elastic.co/elasticsearch/elasticsearch:* \
|
|
|
- | amd64=docker.elastic.co/kibana/kibana:* \
|
|
|
- | amd64=docker.elastic.co/logstash/logstash:* \
|
|
|
- | windows-*=mcr.microsoft.com/windows/nanoserver:* \
|
|
|
- | windows-*=mcr.microsoft.com/windows/servercore:* \
|
|
|
- | windows-*=microsoft/nanoserver:* \
|
|
|
- | windows-*=microsoft/windowsservercore:* \
|
|
|
- ) continue ;;
|
|
|
- esac
|
|
|
-
|
|
|
- if ! listOutput="$(bashbrew cat --format '{{ .TagEntry.HasArchitecture arch | ternary arch "" }}' "$from")" || [ -z "$listOutput" ]; then
|
|
|
- if [ -z "${naughtyFromsArches["$img=$from"]:-}" ]; then
|
|
|
- naughtyFroms+=( "$img=$from" )
|
|
|
- else
|
|
|
- naughtyFromsArches["$img=$from"]+=', '
|
|
|
+ [ -n "$froms" ] # rough sanity check
|
|
|
+
|
|
|
+ for from in $froms; do
|
|
|
+ if _is_naughty "$from"; then
|
|
|
+ if [ -z "${naughtyFromsArches["$img=$from"]:-}" ]; then
|
|
|
+ naughtyFroms+=( "$img=$from" )
|
|
|
+ else
|
|
|
+ naughtyFromsArches["$img=$from"]+=', '
|
|
|
+ fi
|
|
|
+ naughtyFromsArches["$img=$from"]+="$BASHBREW_ARCH"
|
|
|
fi
|
|
|
- naughtyFromsArches["$img=$from"]+="$BASHBREW_ARCH"
|
|
|
- fi
|
|
|
+ done
|
|
|
done
|
|
|
done
|
|
|
|