forked from nginxinc/docker-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·169 lines (141 loc) · 4.16 KB
/
update.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env bash
set -Eeuo pipefail
shopt -s nullglob
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
declare branches=(
"stable"
"mainline"
)
# Current nginx versions
# Remember to update pkgosschecksum when changing this.
declare -A nginx=(
[mainline]='1.21.6'
[stable]='1.20.2'
)
# Current njs versions
declare -A njs=(
[mainline]='0.7.2'
[stable]='0.7.0'
)
# Current package patchlevel version
# Remember to update pkgosschecksum when changing this.
declare -A pkg=(
[mainline]=1
[stable]=1
)
declare -A debian=(
[mainline]='bullseye'
[stable]='bullseye'
)
declare -A alpine=(
[mainline]='3.15'
[stable]='3.14'
)
# When we bump njs version in a stable release we don't move the tag in the
# mercurial repo. This setting allows us to specify a revision to check out
# when building alpine packages on architectures not supported by nginx.org
# Remember to update pkgosschecksum when changing this.
declare -A rev=(
[mainline]='${NGINX_VERSION}-${PKG_RELEASE}'
[stable]='${NGINX_VERSION}-${PKG_RELEASE}'
#[stable]='500'
)
# Holds SHA512 checksum for the pkg-oss tarball produced by source code
# revision/tag in the previous block
# Used in alpine builds for architectures not packaged by nginx.org
declare -A pkgosschecksum=(
[mainline]='29ec1c635da36b7727953544e1a20e9d75bd9d2050e063b9f81f88ca07bb7ea0b65cef46d0f3cb7134b38ce9b94ecada631619f233231845a3d8a16b6ad0db82'
[stable]='af6e7eb25594dffe2903358f7a2c5c956f5b67b8df3f4e8237c30b63e50ce28e6eada3ed453687409beef8f3afa8f551cb20df2f06bd5e235eb66df212ece2ed'
)
get_packages() {
local distro="$1"
shift
local branch="$1"
shift
local perl=
local r=
local sep=
case "$distro:$branch" in
alpine*:*)
r="r"
sep="."
;;
debian*:*)
sep="+"
;;
esac
case "$distro" in
*-perl)
perl="nginx-module-perl"
;;
esac
echo -n ' \\\n'
for p in nginx nginx-module-xslt nginx-module-geoip nginx-module-image-filter $perl; do
echo -n ' '"$p"'=${NGINX_VERSION}-'"$r"'${PKG_RELEASE} \\\n'
done
for p in nginx-module-njs; do
echo -n ' '"$p"'=${NGINX_VERSION}'"$sep"'${NJS_VERSION}-'"$r"'${PKG_RELEASE} \\'
done
}
get_packagerepo() {
local distro="${1%-perl}"
shift
local branch="$1"
shift
[ "$branch" = "mainline" ] && branch="$branch/" || branch=""
echo "https://nginx.org/packages/${branch}${distro}/"
}
get_packagever() {
local distro="${1%-perl}"
shift
local branch="$1"
shift
local suffix=
[ "${distro}" = "debian" ] && suffix="~${debianver}"
echo ${pkg[$branch]}${suffix}
}
generated_warning() {
cat <<__EOF__
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
__EOF__
}
for branch in "${branches[@]}"; do
for variant in \
alpine{,-perl} \
debian{,-perl}; do
echo "$branch: $variant"
dir="$branch/$variant"
variant="$(basename "$variant")"
[ -d "$dir" ] || continue
template="Dockerfile-${variant%-perl}.template"
{
generated_warning
cat "$template"
} >"$dir/Dockerfile"
debianver="${debian[$branch]}"
alpinever="${alpine[$branch]}"
nginxver="${nginx[$branch]}"
njsver="${njs[${branch}]}"
revver="${rev[${branch}]}"
pkgosschecksumver="${pkgosschecksum[${branch}]}"
packagerepo=$(get_packagerepo "$variant" "$branch")
packages=$(get_packages "$variant" "$branch")
packagever=$(get_packagever "$variant" "$branch")
sed -i \
-e 's,%%ALPINE_VERSION%%,'"$alpinever"',' \
-e 's,%%DEBIAN_VERSION%%,'"$debianver"',' \
-e 's,%%NGINX_VERSION%%,'"$nginxver"',' \
-e 's,%%NJS_VERSION%%,'"$njsver"',' \
-e 's,%%PKG_RELEASE%%,'"$packagever"',' \
-e 's,%%PACKAGES%%,'"$packages"',' \
-e 's,%%PACKAGEREPO%%,'"$packagerepo"',' \
-e 's,%%REVISION%%,'"$revver"',' \
-e 's,%%PKGOSSCHECKSUM%%,'"$pkgosschecksumver"',' \
"$dir/Dockerfile"
cp -a entrypoint/*.sh "$dir/"
done
done