-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate-stackbrew-library.sh
More file actions
executable file
·48 lines (39 loc) · 1.07 KB
/
generate-stackbrew-library.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.07 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
44
45
46
47
48
#!/usr/bin/env bash
set -Eeuo pipefail
self="$(readlink -f "$BASH_SOURCE")"
dir="$(dirname "$self")"
cd "$dir"
gitHubUrl='https://github.com/tianon/docker-brew-cirros'
gitFetch='refs/heads/dist'
commit="$(git ls-remote "$gitHubUrl.git" "$gitFetch" | cut -d$'\t' -f1)"
version="$(curl -fsSL "$gitHubUrl/raw/$commit/arches/version")"
arches="$(curl -fsSL "$gitHubUrl/raw/$commit/arches/supported-arches")"
# prints "$2$1$3$1...$N"
join() {
local sep="$1"; shift
local out; printf -v out "${sep//%/%%}%s" "$@"
echo "${out#$sep}"
}
selfCommit="$(git log --format='format:%H' -1 "$self")"
cat <<-EOH
# this file is generated via $gitHubUrl/blob/$selfCommit/$(basename "$self")
Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon)
GitRepo: $gitHubUrl.git
GitFetch: $gitFetch
GitCommit: $commit
Architectures: $(join ', ' $arches)
EOH
for arch in $arches; do
echo "$arch-Directory: arches/$arch"
done
tags=()
while [ "${version%[.-]*}" != "$version" ]; do
tags+=( $version )
version="${version%[.-]*}"
done
tags+=(
$version
latest
)
echo
echo "Tags: $(join ', ' "${tags[@]}")"