|
|
|
|
@ -11,11 +11,59 @@ fi
|
|
|
|
|
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
repoDir="$dir/../$repo"
|
|
|
|
|
|
|
|
|
|
# if we haven't set BASHBREW_LIBRARY explicitly (like Jenkins does, for example), don't trust the local library
|
|
|
|
|
if [ -z "${BASHBREW_LIBRARY:-}" ]; then
|
|
|
|
|
repo="https://github.com/docker-library/official-images/raw/master/library/$repo"
|
|
|
|
|
fi
|
|
|
|
|
# prints "$2$1$3$1...$N"
|
|
|
|
|
join() {
|
|
|
|
|
local sep="$1"; shift
|
|
|
|
|
local out; printf -v out "${sep//%/%%}%s" "$@"
|
|
|
|
|
echo "${out#$sep}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commaJoin() {
|
|
|
|
|
local items=( $(xargs -n1 <<<"$1" | sort -u) ); shift
|
|
|
|
|
sep=', '
|
|
|
|
|
case "${#items[@]}" in
|
|
|
|
|
0)
|
|
|
|
|
return
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
echo "$items"
|
|
|
|
|
return
|
|
|
|
|
;;
|
|
|
|
|
2)
|
|
|
|
|
sep=' '
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
items[-1]="or ${items[-1]}"
|
|
|
|
|
join "$sep" "${items[@]}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tagFiles() {
|
|
|
|
|
local tag="$1"; shift
|
|
|
|
|
local tagUltimate="${tag##*-}" # 3.6-stretch -> stretch
|
|
|
|
|
local tagPenultimate="${tag%-*}" # 2.7.15-windowsservercore-1803 -> 2.7.15-windowsservercore
|
|
|
|
|
tagPenultimate="${tagPenultimate##*-}" # 2.7.15-windowsservercore -> windowsservercore
|
|
|
|
|
|
|
|
|
|
echo \
|
|
|
|
|
"$repoDir/variant-$tag.md" \
|
|
|
|
|
"$repoDir/variant-$tagUltimate.md" \
|
|
|
|
|
"$repoDir/variant-$tagPenultimate.md" \
|
|
|
|
|
"$dir/variant-$tag.md" \
|
|
|
|
|
"$dir/variant-$tagUltimate.md" \
|
|
|
|
|
"$dir/variant-$tagPenultimate.md"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_repo() {
|
|
|
|
|
local repo=$1; shift
|
|
|
|
|
# if we haven't set BASHBREW_LIBRARY explicitly (like Jenkins does, for example), don't trust the local library
|
|
|
|
|
if [ -z "${BASHBREW_LIBRARY:-}" ]; then
|
|
|
|
|
repo="https://github.com/docker-library/official-images/raw/master/library/$repo"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "$repo"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bbRepo="$(_repo "$repo")"
|
|
|
|
|
IFS=$'\n'
|
|
|
|
|
tags=( $(bashbrew cat -f '
|
|
|
|
|
{{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}}
|
|
|
|
|
@ -24,16 +72,13 @@ tags=( $(bashbrew cat -f '
|
|
|
|
|
{{- join "\n" .Tags -}}
|
|
|
|
|
{{- "\n" -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
' "$repo") )
|
|
|
|
|
' "$bbRepo") )
|
|
|
|
|
unset IFS
|
|
|
|
|
|
|
|
|
|
text=
|
|
|
|
|
declare -A includedFiles=()
|
|
|
|
|
for tag in "${tags[@]}"; do
|
|
|
|
|
for f in \
|
|
|
|
|
"$repoDir/variant-$tag.md" "$repoDir/variant-${tag##*-}.md" \
|
|
|
|
|
"$dir/variant-$tag.md" "$dir/variant-${tag##*-}.md" \
|
|
|
|
|
; do
|
|
|
|
|
for f in $(tagFiles "$tag"); do
|
|
|
|
|
if [ -n "${includedFiles[$f]}" ]; then
|
|
|
|
|
# make sure we don't duplicate variant sections
|
|
|
|
|
break
|
|
|
|
|
@ -52,25 +97,63 @@ for tag in "${tags[@]}"; do
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ "$text" ]; then
|
|
|
|
|
buildpacks=
|
|
|
|
|
potentialTags="$(bashbrew list --uniq "$repo" | cut -d: -f2)"
|
|
|
|
|
default="$([ -f "$repoDir/variant.md" ] && cat "$repoDir/variant.md" || cat "$dir/variant.md")"
|
|
|
|
|
default+=$'\n' # parameter expansion eats the trailing newline
|
|
|
|
|
|
|
|
|
|
# buildpack-deps text
|
|
|
|
|
potentialTags="$(bashbrew list --uniq "$bbRepo" | cut -d: -f2)"
|
|
|
|
|
for tag in $potentialTags; do
|
|
|
|
|
baseImage="$(bashbrew cat -f '{{ .ArchDockerFrom (.TagEntry.Architectures | first) .TagEntry }}' "$repo:$tag")"
|
|
|
|
|
baseImage="$(bashbrew cat -f '{{ .ArchDockerFrom (.TagEntry.Architectures | first) .TagEntry }}' "$bbRepo:$tag")"
|
|
|
|
|
case "$baseImage" in
|
|
|
|
|
buildpack-deps:*-*) ;; # "scm", "curl" -- not large images
|
|
|
|
|
buildpack-deps:*) buildpacks=1; break ;;
|
|
|
|
|
buildpack-deps:*)
|
|
|
|
|
default+=$'\n' # give a little space
|
|
|
|
|
default+="$(< "$dir/variant-default-buildpack-deps.md")"
|
|
|
|
|
default+=$'\n' # parameter expansion eats the trailing newline
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo
|
|
|
|
|
if [ "$repo" != 'debian' ] && [ "$repo" != 'ubuntu' ]; then
|
|
|
|
|
# what is 'jessie', 'stretch' and 'sid'
|
|
|
|
|
# https://github.com/docker-library/python/issues/343
|
|
|
|
|
debian=( $(bashbrew list --uniq "$(_repo 'debian')" | grep -vE 'stable|slim|backports|experimental|testing' | cut -d: -f2) )
|
|
|
|
|
ubuntu=( $(bashbrew list "$(_repo 'ubuntu')" | grep -vE 'devel|latest|[0-9]' | cut -d: -f2) )
|
|
|
|
|
foundDebianTags=
|
|
|
|
|
foundUbuntuTags=
|
|
|
|
|
for tag in ${tags[@]}; do
|
|
|
|
|
for suite in "${debian[@]}"; do
|
|
|
|
|
case "$tag" in
|
|
|
|
|
*-"$suite" | "$suite"-* | *-"$suite"-* | "$suite" )
|
|
|
|
|
foundDebianTags+=" $suite"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
for suite in "${ubuntu[@]}"; do
|
|
|
|
|
case "$tag" in
|
|
|
|
|
*-"$suite" | "$suite"-* | *-"$suite"-* | "$suite" )
|
|
|
|
|
foundUbuntuTags+=" $suite"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ -n "$buildpacks" ]; then
|
|
|
|
|
f='variant-buildpacks.md'
|
|
|
|
|
else
|
|
|
|
|
f='variant.md'
|
|
|
|
|
if [ -n "$foundDebianTags" ]; then
|
|
|
|
|
default+=$'\n' # give a little space
|
|
|
|
|
default+="$( sed -e 's/%%DEB-SUITES%%/'"$(commaJoin "$foundDebianTags")"'/' "$dir/variant-default-debian.md" )"
|
|
|
|
|
default+=$'\n' # parameter expansion eats the trailing newline
|
|
|
|
|
fi
|
|
|
|
|
if [ -n "$foundUbuntuTags" ]; then
|
|
|
|
|
default+=$'\n' # give a little space
|
|
|
|
|
default+="$( sed -e 's/%%DEB-SUITES%%/'"$(commaJoin "$foundUbuntuTags")"'/' "$dir/variant-default-ubuntu.md" )"
|
|
|
|
|
default+=$'\n' # parameter expansion eats the trailing newline
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
[ -f "$repoDir/$f" ] && cat "$repoDir/$f" || cat "$dir/$f"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
echo -n "$default"
|
|
|
|
|
echo "$text"
|
|
|
|
|
fi
|
|
|
|
|
|