forked from nodejs/docker-node
-
Notifications
You must be signed in to change notification settings - Fork 4
/
generate-stackbrew-library.sh
executable file
·96 lines (80 loc) · 2.05 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
#!/bin/bash
set -e
set -o pipefail
# Generate library file.
# $1 : device type
# $2 : distribution
# $3 : variants
function generate_library(){
if [ $2 == 'debian' ]; then
lib_name="$1-node"
else
lib_name="$1-$2-node"
fi
path="$1/$2"
# Don't export rpi-alpine-node library
if [ $1 == 'rpi' ] && [ $2 == 'alpine' ]; then
continue
fi
# Export armhf-alpine-node instead of armv7hf-alpine-node
if [ $1 == 'armv7hf' ] && [ $2 == 'alpine' ]; then
lib_name="armhf-alpine-node"
fi
cd $path
versions=( */ )
versions=( "${versions[@]%/}" )
cd -
url='git://github.com/resin-io-library/docker-node'
echo '# maintainer: Joyent Image Team <[email protected]> (@joyent)' > $lib_name
echo '# maintainer: Trong Nghia Nguyen - resin.io <[email protected]>' >> $lib_name
for version in "${versions[@]}"; do
commit="$(git log -1 --format='format:%H' -- "$path/$version/slim")"
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$path/$version/slim/Dockerfile" | cut -d' ' -f3)"
if [ $version == 'default' ]; then
versionAliases=( $fullVersion )
else
versionAliases=( $fullVersion $version ${aliases[$fullVersion]} )
fi
echo >> $lib_name
for variant in $3; do
commit="$(git log -1 --format='format:%H' -- "$path/$version/$variant")"
echo >> $lib_name
for va in "${versionAliases[@]}"; do
if [ "$va" = 'latest' ]; then
va="$variant"
else
va="$va-$variant"
fi
echo "$va: ${url}@${commit} $path/$version/$variant" >> $lib_name
done
done
done
}
declare -A aliases
aliases=(
[6.5.0]='6 latest'
)
defaultVersion='0.10.22'
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
repo=${PWD##*/}
devices=( "$@" )
if [ ${#devices[@]} -eq 0 ]; then
devices=( */ )
fi
devices=( "${devices[@]%/}" )
for device in "${devices[@]}"; do
cd $device
distros=( */ )
distros=( "${distros[@]%/}" )
cd ..
for distro in "${distros[@]}"; do
# Debian
if [ $distro == 'debian' ]; then
generate_library "$device" "$distro" "slim"
fi
# Alpine
if [ $distro == 'alpine' ]; then
generate_library "$device" "$distro" "slim"
fi
done
done