e10c0a287d821ab3cb830bc5ea0387801fb60e58
[gentoo.git] / dev-db / pgbouncer / pgbouncer-1.10.0.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit user
7
8 DESCRIPTION="Lightweight connection pooler for PostgreSQL"
9 HOMEPAGE="https://pgbouncer.github.io"
10 SRC_URI="https://pgbouncer.github.io/downloads/files/${PV}/${P}.tar.gz"
11 LICENSE="BSD"
12 SLOT="0"
13 KEYWORDS="amd64 x86"
14 IUSE="+c-ares debug doc pam ssl -udns"
15
16 # At-most-one-of, one can be enabled but not both
17 REQUIRED_USE="?? ( c-ares udns )"
18
19 RDEPEND="
20         >=dev-libs/libevent-2.0
21         >=sys-libs/glibc-2.10
22         c-ares? ( >=net-dns/c-ares-1.10 )
23         ssl? ( >=dev-libs/openssl-1.0.1:=[-bindist] )
24         udns? ( >=net-libs/udns-0.1 )
25 "
26
27 DEPEND="${RDEPEND}"
28
29 pkg_setup() {
30         enewgroup postgres 70
31         enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
32
33         enewuser pgbouncer -1 -1 -1 postgres
34 }
35
36 src_prepare() {
37         eapply "${FILESDIR}/pgbouncer-1.8-dirs.patch"
38
39         default
40 }
41
42 src_configure() {
43         # --enable-debug is only used to disable stripping
44         econf \
45                 --docdir=/usr/share/doc/${PF} \
46                 --enable-debug \
47                 $(use_with c-ares cares) \
48                 $(use_enable debug cassert) \
49                 $(use_with pam) \
50                 $(use_with ssl openssl) \
51                 $(use_with udns)
52 }
53
54 src_test() {
55         cd "${S}/test"
56         emake
57 }
58
59 src_install() {
60         emake DESTDIR="${D}" install
61
62         dodoc AUTHORS
63         use doc && dodoc doc/*.rst
64
65         newconfd "${FILESDIR}/${PN}.confd-r1" "${PN}"
66         newinitd "${FILESDIR}/${PN}.initd-r2" "${PN}"
67
68         insinto /etc
69         doins etc/pgbouncer.ini
70
71         insinto /etc/logrotate.d
72         newins "${FILESDIR}/logrotate" pgbouncer
73 }
74
75 pkg_postinst() {
76         if [[ -z ${REPLACING_VERSIONS} ]] ; then
77                 einfo "Please read the config.txt for Configuration Directives"
78                 einfo
79                 einfo "For Administration Commands, see:"
80                 einfo "    man pgbouncer"
81                 einfo
82                 einfo "By default, PgBouncer does not have access to any database."
83                 einfo "GRANT the permissions needed for your application and make sure that it"
84                 einfo "exists in PgBouncer's auth_file."
85         fi
86 }