-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinstall_custom_pg
executable file
·67 lines (56 loc) · 2.31 KB
/
install_custom_pg
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
#!/bin/bash
set -eux
# exit early if a custom build is not needed
if [ -z "${USE_CUSTOM_PG:-}" ]; then
exit
fi
# if there is cached PostgreSQL build, just pull new updates, hopefuly
# there are no updates and we can skip the compiling PostgreSQL. Note
# that travis always creates caching directories. It will be just empty
# if there is no cache yet. We check whether the directory contains any
# files.
cd ~
if [ "$(ls -A postgresql)" ]; then
git -C postgresql pull
else
pgmajornum="${PGVERSION%%.*}"
if [ "${pgmajornum}" -gt '13' ]; then
# 13 is highest stable build; use master for higher
gitref="master"
elif [ "${pgmajornum}" -gt '9' ]; then
gitref="REL_${PGVERSION}_STABLE"
else
gitref="REL${PGVERSION//./_}_STABLE"
fi
git clone -b "${gitref}" --depth 1 git://git.postgresql.org/git/postgresql.git
# in order for other PostgreSQL packages to operate correctly, we need
# to ensure our build uses the same directories as the PGDG build; un-
# fortunately, not all can be specified by ./configure, so we apply the
# version-specific packaging patch used for the PGDG builds
debianscmurl='https://salsa.debian.org/postgresql/postgresql/raw'
patchurl="${debianscmurl}/${PGVERSION}/debian/patches/50-per-version-dirs.patch"
# apply patch
curl -sf "${patchurl}" | git -C postgresql apply
fi
# we will use this to parallelize PostgreSQL compilation
procs="$(nproc)"
mjobs="$((procs + 1))"
# configure, build, and install PostgreSQL
cd postgresql
./configure --enable-cassert --enable-debug --enable-depend --with-openssl \
--mandir="/usr/share/postgresql/${PGVERSION}/man" \
--docdir="/usr/share/doc/postgresql-doc-${PGVERSION}" \
--sysconfdir=/etc/postgresql-common \
--datarootdir=/usr/share/ \
--datadir="/usr/share/postgresql/${PGVERSION}" \
--bindir="/usr/lib/postgresql/${PGVERSION}/bin" \
--libdir=/usr/lib/x86_64-linux-gnu/ \
--libexecdir=/usr/lib/postgresql/ \
--includedir=/usr/include/postgresql/ \
make -j "${mjobs}" -s all
make -j "${mjobs}" -s -C src/test/isolation
make -j "${mjobs}" -s -C contrib/pg_stat_statements
sudo make install
sudo make -C contrib/pg_stat_statements install
# install postgresql-common to get psql wrappers, etc.
sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install postgresql-common