This repository has been archived by the owner on Mar 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathgenerate-stackbrew-library.sh
executable file
·134 lines (118 loc) · 3.76 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
declare -A aliases
aliases=(
[$(cat latest)]='latest'
)
declare -A noVersion
noVersion=(
[oldstable]=1
[stable]=1
[testing]=1
[unstable]=1
[sid]=1
)
versions=( */ )
versions=( "${versions[@]%/}" )
cat <<-EOH
Maintainers: Tianon Gravi <[email protected]> (@tianon),
Paul Tagliamonte <[email protected]> (@paultag)
GitRepo: https://github.com/tianon/docker-brew-debian.git
EOH
branches=( dist-stable dist-unstable dist-oldstable master )
for branch in "${branches[@]}"; do
if [ "$branch" = 'master' ]; then
continue
fi
commitRange="master..$branch"
commitCount="$(git rev-list "$commitRange" --count 2>/dev/null || true)"
if [ "$commitCount" ] && [ "$commitCount" -gt 0 ]; then
echo
echo '# commits:' "($commitRange)"
git log --format=format:'- %h %s%n%w(0,2,2)%b' "$commitRange" | sed 's/^/# /'
fi
done
# prints "$2$1$3$1...$N"
join() {
local sep="$1"; shift
local out; printf -v out "${sep//%/%%}%s" "$@"
echo "${out#$sep}"
}
for version in "${versions[@]}"; do
tarball="$version/rootfs.tar.xz"
commit="$(git log -1 --format='format:%H' "${branches[@]}" -- "$tarball")"
if [ -z "$commit" ]; then
echo >&2 "warning: cannot determine commit for $tarball; skipping"
continue
fi
branch=
for b in "${branches[@]}"; do
if git merge-base --is-ancestor "$commit" "$b" &> /dev/null; then
branch="$b"
break
fi
done
if [ -z "$branch" ]; then
echo >&2 "error: cannot determine branch for $tarball (commit $commit)"
exit 1
fi
versionAliases=()
if [ -z "${noVersion[$version]}" ]; then
fullVersion="$(git show "$commit:$tarball" | tar -xvJ etc/debian_version --to-stdout 2>/dev/null || true)"
if [ -z "$fullVersion" ] || [[ "$fullVersion" == */sid ]]; then
fullVersion="$(eval "$(git show "$commit:$tarball" | tar -xvJ etc/os-release --to-stdout 2>/dev/null || true)" && echo "$VERSION" | cut -d' ' -f1)"
if [ -z "$fullVersion" ]; then
# lucid...
fullVersion="$(eval "$(git show "$commit:$tarball" | tar -xvJ etc/lsb-release --to-stdout 2>/dev/null || true)" && echo "$DISTRIB_DESCRIPTION" | cut -d' ' -f2)" # DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"
fi
else
while [ "${fullVersion%.*}" != "$fullVersion" ]; do
versionAliases+=( $fullVersion )
fullVersion="${fullVersion%.*}"
done
fi
if [ "$fullVersion" != "$version" ]; then
versionAliases+=( $fullVersion )
fi
fi
versionAliases+=( $version $(git show "$commit:$version/suite" 2>/dev/null || true) ${aliases[$version]} )
echo
cat <<-EOE
Tags: $(join ', ' "${versionAliases[@]}")
GitFetch: refs/heads/$branch
GitCommit: $commit
Directory: $version
EOE
for imageVariant in slim backports; do
if [ "$(git show "$commit:$version/$imageVariant/Dockerfile" 2>/dev/null || true)" ]; then
echo
cat <<-EOE
Tags: $version-$imageVariant
GitFetch: refs/heads/$branch
GitCommit: $commit
Directory: $version/$imageVariant
EOE
fi
done
done
dockerfilesBase='https://github.com/tianon/dockerfiles'
dockerfilesGit="$dockerfilesBase.git"
dockerfilesBranch='master'
dockerfiles="$dockerfilesBase/commits/$dockerfilesBranch/debian"
rcBuggyCommit="$(curl -fsSL "$dockerfiles/rc-buggy/Dockerfile.atom" | tac|tac | awk -F '[ \t]*[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')"
experimentalCommit="$(curl -fsSL "$dockerfiles/experimental/Dockerfile.atom" | tac|tac | awk -F '[ \t]*[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')"
cat <<-EOE
# sid + rc-buggy
Tags: rc-buggy
GitRepo: $dockerfilesGit
GitFetch: refs/heads/$dockerfilesBranch
GitCommit: $rcBuggyCommit
Directory: debian/rc-buggy
# unstable + experimental
Tags: experimental
GitRepo: $dockerfilesGit
GitFetch: refs/heads/$dockerfilesBranch
GitCommit: $experimentalCommit
Directory: debian/experimental
EOE