forked from docker-library/official-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_bashbrew-cat-sorted.sh
executable file
·43 lines (36 loc) · 975 Bytes
/
_bashbrew-cat-sorted.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -Eeuo pipefail
# a mimic of "bashbrew cat" which should sort slightly more deterministically (so even full-order-changing PRs should have reasonable diffs)
images="$(
bashbrew list --repos --uniq "$@" \
| sort -uV \
| xargs -r bashbrew list --repos --uniq --build-order
)"
set -- $images
declare -A seenGlobal=()
first=1
for img; do
if [ -n "$first" ]; then
first=
else
echo; echo
fi
if [ "$#" -gt 1 ]; then
echo "# $img"
fi
repo="${img%:*}"
if [ -z "${seenGlobal["$repo"]:-}" ]; then
bashbrew cat --format '{{ printf "%s\n" (.Manifest.Global.ClearDefaults defaults) }}' "$img"
seenGlobal["$repo"]="$img"
else
echo "# (see also ${seenGlobal["$repo"]} above)"
fi
bashbrew list --uniq "$img" \
| sort -V \
| xargs -r bashbrew list --uniq --build-order \
| xargs -r bashbrew cat --format '
{{- range $e := .TagEntries -}}
{{- printf "\n%s\n" ($e.ClearDefaults $.Manifest.Global) -}}
{{- end -}}
'
done