summaryrefslogtreecommitdiff
blob: df8a6bc685fc796d87751fa8d47e7b7c0aab6854 (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
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-www/mod_scgi/mod_scgi-1.2_alpha1-r2.ebuild,v 1.1 2003/12/03 23:51:18 robbat2 Exp $

detectapache() {
	local domsg=
	[ -n "$1" ] && domsg=1
	HAVE_APACHE1=
	HAVE_APACHE2=
	has_version '=net-www/apache-1*' && HAVE_APACHE1=1
	has_version '=net-www/apache-2*' && HAVE_APACHE2=1

	[ -n "${HAVE_APACHE1}" ] && APACHEVER=1
	[ -n "${HAVE_APACHE2}" ] && APACHEVER=2
	[ -n "${HAVE_APACHE1}" ] && [ -n "${HAVE_APACHE2}" ] && APACHEVER='both'

	case "${APACHEVER}" in
	1) [ -n "${domsg}" ] && einfo 'Apache1 only detected' ;;
	2) [ -n "${domsg}" ] && einfo 'Apache2 only detected';;
	both)
		if [ "`use apache2`" ]; then
			[ -n "${domsg}" ] && einfo "Multiple Apache versions detected, using Apache2 (USE=apache2)"
			APACHEVER=2
		else
			[ -n "${domsg}" ] && einfo 'Multiple Apache versions detected, using Apache1 (USE=-apache2)'
			APACHEVER=1
		fi ;;
	*) if [ -n "${domsg}" ]; then
			MSG="Unknown Apache version!"; eerror $MSG ; die $MSG
	   else
			APACHEVER=0
	   fi; ;;
	esac
}
detectapache
SLOT="${APACHEVER}"
[ "${APACHEVER}" -eq '2' ] && USE_APACHE2='2' || USE_APACHE2=''

MY_PN=${PN/mod_}
MY_PV=${PV/_alpha/a}
MY_P=${MY_PN}-${MY_PV}
S=${WORKDIR}/${MY_P}
DESCRIPTION="Apache module for a Replacement for the CGI protocol that is similar to FastCGI"
URI_BASE="http://www.mems-exchange.org/software"
HOMEPAGE="${URI_BASE}/scgi/"
SRC_URI="${URI_BASE}/files/${MY_PN}/${MY_P}.tar.gz"
LICENSE="CNRI"
KEYWORDS="~x86"
IUSE="apache2"
DEPEND="${DEPEND}
		net-www/scgi
		net-www/apache
		apache2? ( >=net-www/apache-2 )"

src_unpack() {
	unpack ${A}
	einfo "Fixing module name"
	for f in ${S}/apache[12]/Makefile; do
		sed -e 's/\(apxs[2]*\)/\1 -n mod_scgi/g' -i ${f}
	done
	for f in ${S}/apache[12]/mod_scgi.c; do
		sed -e 's/scgi_module/mod_scgi/g' -i ${f}
	done
}

src_compile() {
	detectapache true
	cd apache${APACHEVER}
	make || die "apache${APACHEVER} mod_scgi make failed"
}

src_install() {
	detectapache
	newdoc apache1/README README.apache1
	newdoc apache2/README README.apache2
	dodoc README PKG-INFO LICENSE.txt CHANGES
	exeinto /usr/lib/apache${APACHEVER}-extramodules
	doexe apache${APACHEVER}/.libs/${PN}.so
	insinto /etc/apache${APACHEVER}/conf/modules.d
	doins ${FILESDIR}/20_mod_scgi.conf
}

pkg_postinst() {
	detectapache
	if [ -n "${USE_APACHE2}" ] ; then
		einfo "Add '-D SCGI' to your APACHE2_OPTS in /etc/conf.d/apache2"
	else
		einfo "1. Execute the command:"
		einfo " \"ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config\""
		einfo "2. Edit /etc/conf.d/apache and add \"-D SCGI\" to APACHE_OPTS"
	fi
}

pkg_config() {
	detectapache
	if [ -n "${USE_APACHE2}" ] ; then
		einfo "Add '-D SCGI' to your APACHE2_OPTS in /etc/conf.d/apache2"
	else
		${ROOT}/usr/sbin/apacheaddmod \
		${ROOT}/etc/apache/conf/apache.conf \
		extramodules/mod_scgi.so mod_scgi.c scgi_module \
		before=perl define=SCGI addconf=conf/modules.d/20_mod_scgi.conf
		:;
	fi
}