-
Notifications
You must be signed in to change notification settings - Fork 11
/
update_dockerfiles
executable file
·117 lines (93 loc) · 3.83 KB
/
update_dockerfiles
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
#!/bin/bash
# make bash behave
set -euo pipefail
IFS=$'\n\t'
pgversions='11 12 13 14 15 16'
topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dockerfiles_dir="${topdir}/dockerfiles"
templates_dir="${topdir}"/templates
badusage=64
function update_extra_repositories_and_packages {
os=$1
release=$2
extra_repositories=''
extra_packages=''
case ${os}+${release} in
centos+6|centos+7)
extra_repositories='epel-release centos-release-scl-rh'
extra_packages='llvm-toolset-7-clang llvm5.0 spectool curl'
;;
centos+8|almalinux+8)
extra_repositories='epel-release'
extra_packages='llvm-toolset ccache spectool curl'
;;
oraclelinux+6|oraclelinux+7)
extra_repositories=''
extra_packages='llvm-toolset-7-clang llvm5.0 spectool curl'
;;
oraclelinux+8)
extra_repositories='oracle-epel-release-el8'
extra_packages='llvm-toolset ccache spectool curl'
;;
# almalinux already has curl installed and installing it again causes conflicting installation error
almalinux+9)
extra_repositories='epel-release'
extra_packages='llvm-toolset ccache rpmdevtools krb5-devel'
;;
esac
}
function update_rpm_dockerfile {
os=$1
release=$2
pgversion=$3
pgshort=${pgversion//./}
target_subdir="${dockerfiles_dir}/${os}-${release}-pg${pgshort}"
if ! [[ "${os}" =~ centos|oraclelinux|almalinux ]]; then
echo "$0: unrecognized OS -- ${os}" >&2
exit $badusage
fi
rpm_url="download.postgresql.org/pub/repos/yum/reporpms/EL-${release}-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
mkdir -p "${target_subdir}"
template="${templates_dir}"/Dockerfile-rpm.tmpl
sed "$sed_cmd; s#%%rpm_url%%#${rpm_url}#g; s/%%pgshort%%/${pgshort}/g; s/%%pgversion%%/${pgversion}/g" \
"${template}" > "${target_subdir}/Dockerfile"
}
while read -r line; do
IFS=',' read -r os release <<< "$line"
update_extra_repositories_and_packages "${os}" "${release}"
sed_cmd='s/%%os%%/'"${os}"'/g;
s/%%release%%/'"${release}"'/g;
s/%%extra-repositories%%/'"${extra_repositories}"'/g;
s/%%extra-packages%%/'"${extra_packages}"'/g'
if [[ "${os}" = 'debian' ]] || [[ "${os}" = 'ubuntu' ]]; then
# debian variants have a single Dockerfile
target_subdir="${dockerfiles_dir}/${os}-${release}-all"
mkdir -p "${target_subdir}"
template="${templates_dir}"/Dockerfile-deb.tmpl
sed 's/%%os%%/'"${os}"'/g; s/%%release%%/'"${release}"'/g' \
"${template}" > "${target_subdir}/Dockerfile"
elif [[ "${os}" = 'centos' ]] || [[ "${os}" = 'fedora' ]] || [[ "${os}" = 'oraclelinux' ]] || \
[[ "${os}" = 'almalinux' ]]; then
# redhat variants need a Dockerfile for each PostgreSQL version
IFS=' '
for pgversion in ${pgversions}; do
if { [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]]; } && \
[[ "${release}" = '6' ]] && [[ "${pgversion}" = '13' ]]; then
# CentOS and OracleLinux 6 doesn't have pg13 packages yet.
# So skip building docker images for them.
continue
fi
update_rpm_dockerfile "${os}" "${release}" "${pgversion}"
done
elif [[ "${os}" = 'pgxn' ]]; then
# pgxn only needs a single build box
target_subdir="${dockerfiles_dir}/${os}-all"
mkdir -p "${target_subdir}"
template="${templates_dir}"/Dockerfile-pgxn.tmpl
sed 's/%%os%%/'"${os}"'/g; s/%%release%%/'"${release}"'/g' \
"${template}" > "${target_subdir}/Dockerfile"
else
echo "$0: unrecognized OS -- ${os}" >&2
exit $badusage
fi
done <"${topdir}/os-list.csv"