-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·116 lines (103 loc) · 3.94 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
#!/bin/bash
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
declare -A debianSuite=(
[9.2]='jessie'
[9.3]='jessie'
[9.4]='jessie'
[9.5]='jessie'
[9.6]='jessie'
[10]='stretch'
)
declare -A alpineVersion=(
[9.2]='3.5'
[9.3]='3.5'
[9.4]='3.5'
[9.5]='3.5'
[9.6]='3.5'
[10]='3.6'
)
packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/'
# https://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/?C=M;O=D
osspUuidVersion='1.6.2'
osspUuidHash='11a615225baa5f8bb686824423f50e4427acd3f70d394765bdff32801f0fd5b0'
declare -A suitePackageList
travisEnv=
for version in "${versions[@]}"; do
suite="${debianSuite[$version]}"
if [ -z "${suitePackageList["$suite"]:+isset}" ]; then
suitePackageList["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/main/binary-amd64/Packages.bz2" | bunzip2)"
fi
versionList="$(echo "${suitePackageList["$suite"]}"; curl -fsSL "${packagesBase}/${suite}-pgdg/${version}/binary-amd64/Packages.bz2" | bunzip2)"
fullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$version"'" { print $2; exit }' || true)"
(
set -x
cp docker-entrypoint.sh "$version/"
sed -e 's/%%PG_MAJOR%%/'"$version"'/g;' \
-e 's/%%PG_VERSION%%/'"$fullVersion"'/g' \
-e 's/%%DEBIAN_SUITE%%/'"$suite"'/g' \
Dockerfile-debian.template > "$version/Dockerfile"
if [ "$version" = '10' ]; then
# postgresql-contrib-10 package does not exist, but is provided by postgresql-10
# Packages.gz:
# Package: postgresql-10
# Provides: postgresql-contrib-10
sed -i -e '/postgresql-contrib-/d' "$version/Dockerfile"
fi
)
# TODO figure out what to do with odd version numbers here, like release candidates
srcVersion="${fullVersion%%-*}"
# change "10~beta1" to "10beta1" for ftp urls
tilde='~'
srcVersion="${srcVersion//$tilde/}"
srcSha256="$(curl -fsSL "https://ftp.postgresql.org/pub/source/v${srcVersion}/postgresql-${srcVersion}.tar.bz2.sha256" | cut -d' ' -f1)"
for variant in alpine; do
if [ ! -d "$version/$variant" ]; then
continue
fi
(
set -x
cp docker-entrypoint.sh "$version/$variant/"
sed -i 's/gosu/su-exec/g' "$version/$variant/docker-entrypoint.sh"
sed -e 's/%%PG_MAJOR%%/'"$version"'/g' \
-e 's/%%PG_VERSION%%/'"$srcVersion"'/g' \
-e 's/%%PG_SHA256%%/'"$srcSha256"'/g' \
-e 's/%%ALPINE-VERSION%%/'"${alpineVersion[$version]}"'/g' \
"Dockerfile-$variant.template" > "$version/$variant/Dockerfile"
if [ "${alpineVersion[$version]}" != '3.5' ]; then
# prove was moved out of the perl package and into perl-utils in 3.6
# https://pkgs.alpinelinux.org/contents?file=prove&path=&name=&branch=&repo=&arch=x86_64
sed -ri 's/(\s+perl)(\s+)/\1-utils\2/' "$version/$variant/Dockerfile"
fi
# TODO remove all this when 9.2 and 9.3 are EOL (2017-10-01 and 2018-10-01 -- from http://www.postgresql.org/support/versioning/)
case "$version" in
9.2|9.3)
uuidConfigFlag='--with-ossp-uuid'
sed -i \
-e 's/%%OSSP_UUID_ENV_VARS%%/ENV OSSP_UUID_VERSION '"$osspUuidVersion"'\nENV OSSP_UUID_SHA256 '"$osspUuidHash"'\n/' \
-e $'/%%INSTALL_OSSP_UUID%%/ {r ossp-uuid.template\n d}' \
"$version/$variant/Dockerfile"
# configure: WARNING: unrecognized options: --enable-tap-tests
sed -i '/--enable-tap-tests/d' "$version/$variant/Dockerfile"
;;
*)
uuidConfigFlag='--with-uuid=e2fs'
sed -i \
-e '/%%OSSP_UUID_ENV_VARS%%/d' \
-e '/%%INSTALL_OSSP_UUID%%/d' \
"$version/$variant/Dockerfile"
;;
esac
sed -i 's/%%UUID_CONFIG_FLAG%%/'"$uuidConfigFlag"'/' "$version/$variant/Dockerfile"
)
travisEnv="\n - VERSION=$version VARIANT=$variant$travisEnv"
done
travisEnv='\n - VERSION='"$version$travisEnv"
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml