summaryrefslogtreecommitdiff
blob: fb0897b0eedfbfa4952ecf11b5b8986d70cf78cf (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

RESTRICT="test"

DESCRIPTION="Lightweight connection pooler for PostgreSQL"
HOMEPAGE="http://pgfoundry.org/projects/pgbouncer/"
SRC_URI="http://pgfoundry.org/frs/download.php/2912/${P}.tgz"

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

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

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

src_prepare() {
	sed -i -e "s,pgbouncer.log,/var/log/pgbouncer/pgbouncer.log," \
		-e "s,pgbouncer.pid,/var/run/pgbouncer/pgbouncer.pid," \
		-e "s,etc/userlist.txt,/etc/userlist.txt," 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 || die "Install failed"

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

	dodoc README NEWS AUTHORS || die "Install failed"
	if use doc ; then
		dodoc doc/*.txt || die "Install failed"
	fi

	dodir /var/{run,log}/pgbouncer/
	fperms 0700 /var/{run,log}/pgbouncer/
	fowners pgbouncer:pgbouncer /var/{run,log}/pgbouncer/
}

pkg_postinst() {
	einfo "Please read the config.txt for Configuration Directives"
	einfo
	einfo "See 'man pgbouncer' for Administration Commands"
	einfo
	einfo "By default, PgBouncer does not have access to any databases."
	einfo "Create on with permissions needed for your application and"
	einfo "make sure that it exists in pgbouncer's auth_file."
}