forked from postgis/docker-postgis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·201 lines (172 loc) · 8.53 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# Derived from https://github.com/docker-library/postgres/blob/master/update.sh
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */Dockerfile )
fi
versions=( "${versions[@]%/Dockerfile}" )
for optimized in debian alpine test; do
rm -f _dockerlists_${optimized}.md
echo " " > _dockerlists_${optimized}.md
echo "| DockerHub image | Dockerfile | OS | Postgres | PostGIS |" >> _dockerlists_${optimized}.md
echo "| --------------- | ---------- | -- | -------- | ------- |" >> _dockerlists_${optimized}.md
done
autogenerated='NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY.'
dockerhublink="https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name="
githubrepolink="https://github.com/postgis/docker-postgis/blob/master"
# sort version numbers with highest last (so it goes first in .travis.yml)
IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -V) ); unset IFS
defaultAlpinenSuite='3.20'
defaultDebianSuite='bullseye-slim'
declare -A debianSuite=(
# https://github.com/docker-library/postgres/issues/582
[11]='bullseye-slim'
[12]='bullseye-slim'
[13]='bullseye-slim'
[14]='bullseye-slim'
[15]='bullseye-slim'
[16]='bullseye-slim'
[17]='bullseye-slim'
)
defaultPostgisDebPkgNameVersionSuffix='3'
declare -A postgisDebPkgNameVersionSuffixes=(
[3.0]='3'
[3.1]='3'
[3.2]='3'
[3.3]='3'
[3.4]='3'
[3.5]='3'
)
packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/'
cgal5XGitHash="$(git ls-remote https://github.com/CGAL/cgal.git heads/5.6.x-branch | awk '{ print $1}')"
sfcgalGitHash="$(git ls-remote https://gitlab.com/SFCGAL/SFCGAL.git heads/master | awk '{ print $1}')"
projGitHash="$(git ls-remote https://github.com/OSGeo/PROJ.git heads/master | awk '{ print $1}')"
gdalGitHash="$(git ls-remote https://github.com/OSGeo/gdal.git refs/heads/master | grep '\srefs/heads/master' | awk '{ print $1}')"
geosGitHash="$(git ls-remote https://github.com/libgeos/geos.git heads/main | awk '{ print $1}')"
postgisGitHash="$(git ls-remote https://github.com/postgis/postgis.git heads/master | awk '{ print $1}')"
declare -A suitePackageList=() suiteArches=()
for version in "${versions[@]}"; do
IFS=- read postgresVersion postgisVersion <<< "$version"
echo " "
echo "---- generate Dockerfile for $version ----"
echo "postgresVersion=$postgresVersion"
echo "postgisVersion=$postgisVersion"
if [ "2.5" == "$postgisVersion" ]; then
# posgis 2.5 only in the stretch ; no bullseye version
tag='stretch-slim'
else
tag="${debianSuite[$postgresVersion]:-$defaultDebianSuite}"
fi
suite="${tag%%-slim}"
if [ -z "${suitePackageList["$suite"]:+isset}" ]; then
suitePackageList["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/main/binary-amd64/Packages.bz2" | bunzip2)"
fi
if [ -z "${suiteArches["$suite"]:+isset}" ]; then
suiteArches["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/Release" | awk -F ':[[:space:]]+' '$1 == "Architectures" { gsub(/[[:space:]]+/, "|", $2); print $2 }')"
fi
postgresVersionMain="$(echo "$postgresVersion" | awk -F 'alpha|beta|rc' '{print $1}')"
versionList="$(echo "${suitePackageList["$suite"]}"; curl -fsSL "${packagesBase}/${suite}-pgdg/${postgresVersionMain}/binary-amd64/Packages.bz2" | bunzip2)"
fullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$postgresVersionMain"'" { print $2; exit }' || true)"
if [ "$suite" = "bullseye" ]; then
boostVersion="1.74.0"
else
echo "Unknown debian version; stop"
exit 1
fi
optimized=""
if [[ "$version" =~ "alpha" || "$version" =~ "beta" || "$version" =~ "rc" || "$version" =~ "master" ]];
then
optimized="test"
else
optimized="debian"
fi
echo "optimized=$optimized"
debianPostgisMajMin=""
if [ "master" == "$postgisVersion" ]; then
postgisPackageName=""
postgisFullVersion="$postgisVersion"
postgisMajor=""
postgisDocSrc="development: postgis, geos, proj, gdal"
else
postgisMajMin="$( echo "${postgisVersion}" | cut -d. -f1 ).$( echo "${postgisVersion}" | cut -d. -f2 )"
echo "postgisMajMin=${postgisMajMin}"
postgisPackageName="postgresql-${postgresVersionMain}-postgis-${postgisDebPkgNameVersionSuffixes[${postgisMajMin}]}"
postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)"
echo "postgisPackageName=${postgisPackageName}"
echo "postgisFullVersion=${postgisFullVersion}"
debianPostgisMajMin="$( echo "${postgisFullVersion}" | cut -d. -f1 ).$( echo "${postgisFullVersion}" | cut -d. -f2 )"
if [ "$debianPostgisMajMin" == "$postgisMajMin" ]; then
echo "debian postgis version is OK "
postgisMajor="${postgisDebPkgNameVersionSuffixes[${postgisMajMin}]}"
postgisDocSrc="${postgisFullVersion%%+*}"
else
echo "debian postgis is not updated, different .. "
postgisFullVersion=""
postgisMajor=""
postgisDocSrc=""
fi
fi
if [ -z "$postgisFullVersion" ]
then
echo "SKIP debian version";
# debain version not found;
echo " # placeholder Dockerfile" > "$version/Dockerfile"
echo " # Debian version of postgis $postgisFullVersion is not detected!">> "$version/Dockerfile"
echo " # This is an autogenerated message of ./update.sh " >> "$version/Dockerfile"
rm -f "$version/*.sh"
rm -f "$version/*.md"
# use the default for the alpine version
postgisFullVersion=$postgisVersion
postgisDocSrc=$postgisVersion
else
(
set -x
cp -p initdb-postgis.sh update-postgis.sh "$version/"
if [ "master" == "$postgisVersion" ]; then
cat Dockerfile.master.template > "$version/Dockerfile"
else
cat Dockerfile.template > "$version/Dockerfile"
fi
sed -i 's/%%TXT_AUTOGENERATED%%/'"$autogenerated"'/g; s/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'$postgisMajor'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g; s/%%POSTGIS_GIT_HASH%%/'$postgisGitHash'/g; s/%%CGAL5X_GIT_HASH%%/'$cgal5XGitHash'/g; s/%%SFCGAL_GIT_HASH%%/'$sfcgalGitHash'/g; s/%%PROJ_GIT_HASH%%/'$projGitHash'/g; s/%%GDAL_GIT_HASH%%/'$gdalGitHash'/g; s/%%GEOS_GIT_HASH%%/'$geosGitHash'/g; s/%%BOOST_VERSION%%/'"$boostVersion"'/g; s/%%DEBIAN_VERSION%%/'"$suite"'/g;' "$version/Dockerfile"
echo "| [postgis/postgis:${version}](${dockerhublink}${version}) | [Dockerfile](${githubrepolink}/${version}/Dockerfile) | debian:${suite} | ${postgresVersion} | ${postgisDocSrc} |" >> _dockerlists_${optimized}.md
)
fi
if [ "master" == "$postgisVersion" ]; then
srcVersion=""
srcSha256=""
else
srcVersion="${postgisFullVersion%%+*}"
srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')"
fi
for variant in alpine; do
if [ ! -d "$version/$variant" ]; then
continue
fi
(
set -x
if [ "$optimized" != "test" ]; then
optimized="alpine"
fi
cp -p Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/"
mv "$version/$variant/Dockerfile.alpine.template" "$version/$variant/Dockerfile"
sed -i 's/%%TXT_AUTOGENERATED%%/'"$autogenerated"'/g; s/%%PG_MAJOR%%/'"$postgresVersion"'/g; s/%%POSTGIS_VERSION%%/'"$srcVersion"'/g; s/%%POSTGIS_SHA256%%/'"$srcSha256"'/g' "$version/$variant/Dockerfile"
echo "| [postgis/postgis:${version}-${variant}](${dockerhublink}${version}-${variant}) | [Dockerfile](${githubrepolink}/${version}/${variant}/Dockerfile) | alpine:${defaultAlpinenSuite} | ${postgresVersion} | ${postgisDocSrc} |" >> _dockerlists_${optimized}.md
)
done
done
echo "|-------------------------|"
echo "|- Generated images -|"
echo "|-------------------------|"
for optimized in debian alpine test; do
echo " "
echo "---- ${optimized} ----"
cat _dockerlists_${optimized}.md
done
echo " "
echo "Postprocessing todo:"
echo "- add the new versions to README.md ( manually )"
ls -la _dockerlists_*.md
echo " "
echo " - done - "