-
Notifications
You must be signed in to change notification settings - Fork 321
Expand file tree
/
Copy pathgenerate-stackbrew-library.sh
More file actions
executable file
·43 lines (36 loc) · 1.44 KB
/
generate-stackbrew-library.sh
File metadata and controls
executable file
·43 lines (36 loc) · 1.44 KB
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
self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
getArchesJson() {
local repo="$1"; shift
local oiBase="${BASHBREW_LIBRARY:-https://github.com/docker-library/official-images/raw/HEAD/library}/"
# grab supported architectures for each parent image, except self-referential
jq --raw-output \
--arg oiBase "$oiBase" \
--arg repo "$repo" '
[ $oiBase + .[].variants[].from | select(index($repo + ":") | not) ] | unique[]
' versions.json \
| xargs -r bashbrew cat --format '{ {{ join ":" .RepoName .TagName | json }}: {{ json .TagEntry.Architectures }} }' \
| jq --compact-output --slurp 'add'
}
parentArchesJson="$(getArchesJson 'ghost')"
# last commit that changed files related to a build context
commit="$(git log -1 --format='format:%H' HEAD -- '[^.]*/**')"
# generate the header
selfCommit="$(git log -1 --format='format:%H' HEAD -- "$self")"
cat <<-EOH
# this file is generated via https://github.com/docker-library/ghost/blob/$selfCommit/$self
Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon),
Joseph Ferguson <yosifkit@gmail.com> (@yosifkit),
Austin Burdine <austin@acburdine.me> (@acburdine)
GitRepo: https://github.com/docker-library/ghost.git
GitCommit: $commit
EOH
# generate the entries
exec jq \
--raw-output \
--argjson parentArches "$parentArchesJson" \
--from-file generate-stackbrew-library.jq \
versions.json \
--args -- "$@"