forked from tianon/docker-brew-ubuntu-core
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate-stackbrew-library.sh
executable file
·61 lines (52 loc) · 1.74 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
#!/bin/bash
set -e
declare -A aliases
aliases=(
[trusty]='latest'
)
declare -A noVersion
noVersion=(
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( */ )
versions=( "${versions[@]%/}" )
url='git://github.com/tianon/docker-brew-ubuntu-core'
cat <<-'EOH'
# maintainer: Tianon Gravi <tianon@debian.org> (@tianon)
# proxy for upstream's official builds
# see https://partner-images.canonical.com/core/
# see also https://wiki.ubuntu.com/Releases#Current
EOH
commitRange='master..dist'
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
arch="$(dpkg --print-architecture)"
for version in "${versions[@]}"; do
commit="$(git log -1 --format='format:%H' -- "$version")"
serial="$(awk -F '=' '$1 == "SERIAL" { print $2 }' "$version/build-info.txt")"
versionAliases=()
if [ -z "${noVersion[$version]}" ]; then
tarball="$version/ubuntu-$version-core-cloudimg-$arch-root.tar.gz"
fullVersion="$(tar -xvf "$tarball" etc/debian_version --to-stdout 2>/dev/null)"
if [ -z "$fullVersion" ] || [[ "$fullVersion" == */sid ]]; then
fullVersion="$(eval "$(tar -xvf "$tarball" etc/os-release --to-stdout 2>/dev/null)" && echo "$VERSION" | cut -d' ' -f1)"
fi
if [ "$fullVersion" ]; then
versionAliases+=( $fullVersion )
if [ "${fullVersion%.*.*}" != "$fullVersion" ]; then
# three part version like "12.04.4"
versionAliases+=( ${fullVersion%.*} )
fi
fi
fi
versionAliases+=( $version-$serial $version ${aliases[$version]} )
echo
echo "# $serial"
for va in "${versionAliases[@]}"; do
echo "$va: ${url}@${commit} $version"
done
done