-
Notifications
You must be signed in to change notification settings - Fork 18
/
generate-stackbrew-library.sh
executable file
·68 lines (58 loc) · 2.11 KB
/
generate-stackbrew-library.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -e
self="$(basename "$BASH_SOURCE")"
# get the most recent commit which modified any of "$@"
fileCommit() {
git log -1 --format='format:%H' HEAD -- "$@"
}
only_x86_64_branch() {
version=$1
branchLine=$(git ls-remote --heads origin $version\* | sort -r -k2 | head -n1)
branch=${branchLine: -12}
commit=${branchLine:0:40}
echo >> photon
echo "Tags: $version, $branch$latestTag" >> photon
echo "GitFetch: refs/heads/$branch" >> photon
echo "GitCommit: $commit" >> photon
latestTag=""
}
aarch64_branch() {
version=$1
x86_64branchLine=$(git ls-remote --heads origin x86_64\/$version\* | sort -r -k2 | head -n1)
x86_64branch=${x86_64branchLine: -12}
x86_64commit=${x86_64branchLine:0:40}
aarch64branchLine=$(git ls-remote --heads origin aarch64\/$version\* | sort -r -k2 | head -n1)
aarch64branch=${aarch64branchLine: -12}
aarch64commit=${aarch64branchLine:0:40}
if [ -n "$x86_64branch" -a -n "$aarch64branch" ] ; then
test "$x86_64branch" \> "$aarch64branch" && tag=$x86_64branch || tag=$aarch64branch
echo >> photon
echo "Tags: $version, $tag$latestTag" >> photon
echo "Architectures: amd64, arm64v8" >> photon
echo "GitFetch: refs/heads/x86_64/$x86_64branch" >> photon
echo "GitCommit: $x86_64commit" >> photon
echo "arm64v8-GitFetch: refs/heads/aarch64/$aarch64branch" >> photon
echo "arm64v8-GitCommit: $aarch64commit" >> photon
latestTag=""
fi
}
###################
# start from here #
###################
cat > photon << EOF
# this file is generated via https://github.com/vmware/photon-docker-image/blob/$(fileCommit "$self")/$self
Maintainers: Fabio Rapposelli <[email protected]> (@frapposelli),
Michelle Wang <[email protected]> (@michellew),
Alexey Makhalov <[email protected]> (@YustasSwamp)
GitRepo: https://github.com/vmware/photon-docker-image.git
Directory: docker
EOF
latestTag=", latest"
# Note: For new release branches, please put it in the first one.
# Then latest tag will be snapp at the new release branch
# 5.0 branch
aarch64_branch "5.0"
# 4.0 branch
aarch64_branch "4.0"
# 3.0 branch
aarch64_branch "3.0"