summaryrefslogtreecommitdiff
blob: 12b6e92067003e9d30ac236f37132c47b1b4f7e1 (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-proxy/oops/oops-1.5.24_pre20050503-r2.ebuild,v 1.4 2007/06/27 06:49:18 opfer Exp $

inherit eutils flag-o-matic toolchain-funcs

MY_P="${PN}-1.5.23"

DESCRIPTION="An advanced multithreaded caching web proxy"
HOMEPAGE="http://zipper.paco.net/~igor/oops.eng/"
SRC_URI="http://zipper.paco.net/~igor/oops/${MY_P}.tar.gz
	mirror://gentoo/${P}.patch.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 sparc x86"
IUSE=""

RDEPEND="dev-libs/libpcre
	>=sys-libs/db-3"
DEPEND="${RDEPEND}
	sys-devel/flex"

S="${WORKDIR}/${MY_P}"

pkg_setup() {
	enewgroup oops
	enewuser oops -1 -1 /var/lib/oops oops
}

src_unpack() {
	unpack ${A}

	cd "${S}"
	epatch "${WORKDIR}/${P}.patch"
	epatch "${FILESDIR}/${P/_*}-textrel.patch"
	epatch "${FILESDIR}/${P/_*}-pthread-rwlock.patch"
	epatch "${FILESDIR}/modules-as-needed.patch"
	epatch "${FILESDIR}/implicit-decl.patch"
	sed -i -e 's:/usr/local/lib/libpcre:/usr/lib/libpcre:g' configure
	sed -i -e 's:y\.tab\.h:y.tab.c:' src/Makefile.in
}

src_compile() {
	econf \
		--prefix=/usr \
		--libdir=/usr/$(get_libdir)/oops \
		--enable-oops-user=oops \
		--sysconfdir=/etc/oops \
		--sbindir=/usr/sbin \
		--with-regexp=pcre \
		--localstatedir=/var/run/oops \
		--enable-large-files \
		|| die "configure problem"

	sed -i -e '/STRERROR_R/d' src/config.h.in
	sed -i \
		-e "s|OOPS_LIBDIR = /usr/$(get_libdir)/oops|OOPS_LIBDIR = ${D}/usr/$(get_libdir)/oops|" \
		-e "s|OOPS_SBINDIR = /usr/sbin|OOPS_SBINDIR = ${D}/usr/sbin|" \
		-e "s|OOPS_SYSCONFDIR = /etc/oops|OOPS_SYSCONFDIR = ${D}/etc/oops|" \
		-e "s|OOPS_LOCALSTATEDIR = /var/run/oops|OOPS_LOCALSTATEDIR = ${D}/var/run/oops|" \
		-e "s|OOPSPATH=/usr/oops|OOPSPATH=${D}/usr/oops|" \
		src/Makefile
	sed -i \
		-e "s|^\(LDFLAGS *= *\)${LDFLAGS}|\1$(raw-ldflags)|" \
		src/modules/Makefile #modules makefile use ld directly

	emake || die "compile problem"
}

src_install() {
	dodir /usr/sbin
	einstall || die "install problem"

	newinitd "${FILESDIR}/oops.initd" oops
	diropts -m0750 -o root -g oops
	dodir /etc/oops
	insinto /etc/oops
	doins "${FILESDIR}/oops.cfg"

	diropts -m0755 -o oops -g oops
	keepdir /var/run/oops
	diropts -m0770 -o oops -g oops
	keepdir /var/log/oops
	keepdir /var/lib/oops/storage
	keepdir /var/lib/oops/db

	# cleanups
	rm -rf "${D}/usr/oops"
	rm -rf "${D}/usr/lib/oops/modules"
}

pkg_preinst() {
	pkg_setup # create oops user and group
}

pkg_postinst() {
	#Set proper owner/group if installed from binary package
	chgrp oops "${ROOT}/etc/oops"
	chown -R oops:oops "${ROOT}/var/run/oops" "${ROOT}/var/log/oops" "${ROOT}/var/lib/oops"
}