aboutsummaryrefslogtreecommitdiffstats
path: root/main/postgresql/APKBUILD
blob: 72e4846daa9cf1e414d2e96e3a17ed17fdf24c83 (plain)
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: G.J.R. Timmer <gjr.timmer@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
pkgname=postgresql
pkgver=9.6.4
pkgrel=1
pkgdesc="A sophisticated object-relational DBMS"
url="http://www.postgresql.org/"
arch="all"
license="BSD"
depends="postgresql-client"
install="$pkgname.pre-upgrade"
pkgusers="postgres"
pkggroups="postgres"
depends_dev="libressl-dev"
makedepends="$depends_dev libedit-dev zlib-dev libxml2-dev util-linux-dev
	openldap-dev tcl-dev perl-dev python2-dev python3-dev"
subpackages="$pkgname-contrib $pkgname-dev $pkgname-doc libpq $pkgname-libs
	$pkgname-client $pkgname-pltcl
	$pkgname-plperl $pkgname-plperl-contrib:plperl_contrib
	$pkgname-plpython2 $pkgname-plpython2-contrib:plpython2_contrib
	$pkgname-plpython3 $pkgname-plpython3-contrib:plpython3_contrib"
source="ftp://ftp.$pkgname.org/pub/source/v$pkgver/$pkgname-$pkgver.tar.bz2
	initdb.patch
	perl-rpath.patch
	conf-unix_socket_directories.patch
	$pkgname.initd
	$pkgname.confd
	pg-restore.initd
	pg-restore.confd
	pltcl_create_tables.sql
	"
builddir="$srcdir/$pkgname-$pkgver"

# secfixes:
#   9.6.4-r0:
#   - CVE-2017-7546
#   - CVE-2017-7547
#   - CVE-2017-7548
#   9.6.3-r0:
#   - CVE-2017-7484
#   - CVE-2017-7485
#   - CVE-2017-7486

prepare() {
	default_prepare || return 1
	cd "$builddir"

	local file; for file in $pkgname.initd $pkgname.confd; do
		sed "s|@VERSION@|${pkgver%.*}|" "$srcdir"/$file > $file || return 1
	done

	cp -al "$builddir" "$builddir"~py3
}

# NOTE: plpython requires separate configure/build runs to build against
# python 2 versus python 3. Note that the installed Makefile.global will
# reflect the python 2 build, which seems appropriate since that's still
# considered the default plpython version.
build() {
	msg "Building plpython3"

	cd "$builddir"~py3
	export PYTHON=/usr/bin/python3

	_configure || return 1
	make -C src/backend submake-errcodes || return 1
	make -C src/pl/plpython all || return 1


	msg "Building all"

	cd "$builddir"
	export PYTHON=/usr/bin/python2

	_configure && make world || return 1

	unset PYTHON
}

_configure() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--with-ldap \
		--with-libedit-preferred \
		--with-libxml \
		--with-openssl \
		--with-uuid=e2fs \
		--disable-rpath \
		--with-perl \
		--with-python \
		--with-tcl
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" install install-docs || return 1

	install -d -m750 -o postgres -g postgres \
		"$pkgdir"/var/lib/postgresql \
		"$pkgdir"/var/log/$pkgname || return 1

	install -D -m755 postgresql.initd \
		"$pkgdir"/etc/init.d/postgresql || return 1
	install -D -m644 postgresql.confd \
		"$pkgdir"/etc/conf.d/postgresql || return 1

	install -D -m755 "$srcdir"/pg-restore.initd \
		"$pkgdir"/etc/init.d/pg-restore || return 1
	install -D -m644 "$srcdir"/pg-restore.confd \
		"$pkgdir"/etc/conf.d/pg-restore || return 1
}

dev() {
	default_dev || return 1

	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib/postgresql
	mv "$pkgdir"/usr/bin/pg_config \
		"$pkgdir"/usr/bin/ecpg \
		"$subpkgdir"/usr/bin/ || return 1
	mv "$pkgdir"/usr/lib/postgresql/pgxs \
		"$subpkgdir"/usr/lib/postgresql/ || return 1
}

libpq() {
	pkgdesc="PostgreSQL libraries"
	depends=""

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libpq.so.* "$subpkgdir"/usr/lib/
}

libs() {
	depends=""
	default_libs
}

client() {
	pkgdesc="PostgreSQL client"
	depends=""

	mkdir -p "$subpkgdir"/usr/bin
	mv \
		"$pkgdir"/usr/bin/clusterdb \
		"$pkgdir"/usr/bin/createdb \
		"$pkgdir"/usr/bin/createlang \
		"$pkgdir"/usr/bin/createuser \
		"$pkgdir"/usr/bin/dropdb \
		"$pkgdir"/usr/bin/droplang \
		"$pkgdir"/usr/bin/dropuser \
		"$pkgdir"/usr/bin/pg_basebackup \
		"$pkgdir"/usr/bin/pg_dump \
		"$pkgdir"/usr/bin/pg_dumpall \
		"$pkgdir"/usr/bin/pg_isready \
		"$pkgdir"/usr/bin/pg_receivexlog \
		"$pkgdir"/usr/bin/pg_recvlogical \
		"$pkgdir"/usr/bin/pg_restore \
		"$pkgdir"/usr/bin/psql \
		"$pkgdir"/usr/bin/reindexdb \
		"$pkgdir"/usr/bin/vacuumdb \
		"$subpkgdir"/usr/bin/
}

contrib() {
	pkgdesc="Extension modules distributed with PostgreSQL"
	depends=""

	cd "$builddir"

	# Avoid installing plperl and plpython extensions, these will be
	# installed into separate subpackages.
	sed -Ei -e 's/(.*_plperl)/#\1/' \
		-e 's/(.*_plpython)/#\1/' \
		contrib/Makefile || return 1

	make -C contrib DESTDIR="$subpkgdir" install || return 1

	mv "$subpkgdir"/usr/share/doc/postgresql/extension \
		"$pkgdir"/usr/share/doc/postgresql/ || return 1
	rmdir -p "$subpkgdir"/usr/share/doc/postgresql || true
}

pltcl() {
	pkgdesc="PL/Tcl procedural language for PostgreSQL"
	depends="pgtcl"

	cd "$pkgdir"
	_submv usr/bin/pltcl* \
		usr/lib/postgresql/pltcl.so \
		usr/share/postgresql/unknown.pltcl \
		usr/share/postgresql/extension/pltcl* || return 1

	install -m 644 "$srcdir"/pltcl_create_tables.sql \
		"$subpkgdir"/usr/share/postgresql/
}

plperl() {
	pkgdesc="PL/Perl procedural language for PostgreSQL"
	depends=""

	cd "$pkgdir"
	_submv usr/lib/postgresql/plperl.so \
		usr/share/postgresql/extension/plperl*
}

plperl_contrib() {
	_plcontrib plperl "PL/Perl"

	cd "$builddir"
	make -C contrib/hstore_plperl DESTDIR="$subpkgdir" install
}

plpython2() {
	pkgdesc="PL/Python2 procedural language for PostgreSQL"
	depends="python2"

	cd "$pkgdir"
	_submv usr/lib/postgresql/plpython2.so \
		usr/share/postgresql/extension/plpython*
}

plpython2_contrib() {
	_plcontrib plpython2 "PL/Python 2"

	cd "$builddir"
	make -C contrib/hstore_plpython DESTDIR="$subpkgdir" install || return 1
	make -C contrib/ltree_plpython DESTDIR="$subpkgdir" install || return 1

	rm "$subpkgdir"/usr/share/postgresql/extension/*plpython3*
}

plpython3() {
	pkgdesc="PL/Python3 procedural language for PostgreSQL"
	depends="python3"

	cd "$builddir"~py3
	make -C src/pl/plpython DESTDIR="$subpkgdir" install || return 1
	rm -R "$subpkgdir"/usr/include
}

plpython3_contrib() {
	_plcontrib plpython3 "PL/Python 3"

	cd "$builddir"~py3
	make -C contrib/hstore_plpython DESTDIR="$subpkgdir" install || return 1
	make -C contrib/ltree_plpython DESTDIR="$subpkgdir" install || return 1

	cd "$subpkgdir"/usr/share/postgresql/extension/
	rm *plpython2* *plpythonu*
}

_plcontrib() {
	local subname="$1"
	pkgdesc="$2 extension modules distributed with PostgreSQL"
	depends="$pkgname-$subname"
	install_if="$pkgname-$subname=$pkgver-r$pkgrel $pkgname-contrib=$pkgver-r$pkgrel"
}

_submv() {
	local path; for path in "$@"; do
		mkdir -p "$subpkgdir/${path%/*}"
		mv "$path" "$subpkgdir/$path" || return 1
	done
}

sha512sums="b0527efacce6efc09340b68c8c56483cd884676e01cb6bfb4f9ce63226a394bdb0bcf3d832f84e4dff5ceecf09ef4cf93e9fbd0ac453ec85efb11ac50a7dff39  postgresql-9.6.4.tar.bz2
0b88eee78380ed6cf543c851ac1cea5fc50bb6ef1bb51e03694003f43d2bf4e117ff06657f958d0e9c00ace3b8a6bab6ed0bd017d23f80cfd203dab33da81d46  initdb.patch
5f9d8bb4957194069d01af8ab3abc6d4d83a7e7f8bd7ebe1caae5361d621a3e58f91b14b952958138a794e0a80bc154fbb7e3e78d211e2a95b9b7901335de854  perl-rpath.patch
8439a6fdfdea0a4867daeb8bc23d6c825f30c00d91d4c39f48653f5ee77341f23282ce03a77aad94b5369700f11d2cb28d5aee360e59138352a9ab331a9f9d0f  conf-unix_socket_directories.patch
224e80f9e62843fd248e625abdd0d9fe477729ff3f9a64fc5c86dd37bb7176d3504107fbed7ce578e3a1db7f60b8cf2abf5fe4862c81f76b6d026e29ca495cfc  postgresql.initd
a6d9cba5c7270484b3a22083b2b37742faefb01b6643040050c92235840c601b2e206ebda32804937b729c6cf42c79a558b921900e52fc420df2a03b5f29e1f7  postgresql.confd
f5a1cba051e7d846c2d16703514601cb25729ed96b677c9bd0c199d64552120a8b14b238af01917fdb87106681e12dee6fff7447558155ba273e4f96be5e2892  pg-restore.initd
c14a5684e914abb3b0ee71bbf15eed71a9264deacaa404a6e3af6bfc330d93e7598624d0ed11a94263106cc660f7f54c8ff57e759033cf606a795f69ff6c1c7c  pg-restore.confd
5c9bfd9e295dcf678298bf0aa974347a7c311d6e7c2aa76a6920fcb751d01fd1ab77abbec11f3c672f927ad9deaa88e04e370c0b5cd1b60087554c474b748731  pltcl_create_tables.sql"