summaryrefslogtreecommitdiff
blob: bd20dff2b40ba9fff7cd790232feb5603dbb0c61 (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
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/pgbouncer/pgbouncer-1.5.1.ebuild,v 1.2 2012/06/04 06:45:39 zmedico Exp $

EAPI="4"

inherit eutils user

RESTRICT="test"

DESCRIPTION="Lightweight connection pooler for PostgreSQL"
HOMEPAGE="http://pgfoundry.org/projects/pgbouncer/"
SRC_URI="mirror://postgresql/projects/pgFoundry/${PN}/${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="debug"

DEPEND="dev-libs/libevent"
RDEPEND="${DEPEND}"

pkg_setup() {
	enewgroup pgbouncer
	enewuser pgbouncer -1 -1 -1 pgbouncer
}

src_prepare() {
	local rundir=""
	[[ ! -d /run ]] && rundir="/var"

	sed -i -e "s,${PN}.log,/var/log/${PN}/${PN}.log," \
		-e "s,${PN}.pid,/var/run/${PN}/${PN}.pid," \
		-e "s,etc/userlist.txt,/etc/userlist.txt," \
		-e "s,;unix_socket_dir = /tmp,unix_socket_dir = ${rundir}/run/${PN}.sock," \
		"${S}"/etc/pgbouncer.ini || die
}

src_configure() {
	# --enable-debug is only used to disable stripping
	econf \
		--enable-debug \
		$(use_enable debug cassert) \
		--docdir=/usr/share/doc/${PF}
}

src_install() {
	emake DESTDIR="${D}" install

	insinto /etc
	newins etc/pgbouncer.ini pgbouncer.conf
	newinitd "${FILESDIR}"/pgbouncer.initd "${PN}"

	dodoc README NEWS AUTHORS
	dodoc doc/*.txt

	dodir /var/log/pgbouncer/
	fowners pgbouncer:pgbouncer /var/log/pgbouncer/
}

pkg_postinst() {
	einfo "Please read the config.txt for Configuration Directives"
	einfo
	einfo "For Administration Commands, see:"
	einfo "    man pgbouncer"
	einfo
	einfo "By default, PgBouncer does not have access to any database."
	einfo "GRANT the permissions needed for your application and make sure that it"
	einfo "exists in PgBouncer's auth_file."

}