|
Line 0
Link Here
|
|
|
1 |
--- php-4.3.5/sapi/apache/mod_php4.c.old 2004-01-31 21:44:55.000000000 +0000 |
|
Line 0
Link Here
|
|
|
1 |
# Copyright 1999-2004 Gentoo Technologies, Inc. |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /home/cvsroot/gentoo-x86/dev-php/mod_php/mod_php-4.3.5.ebuild,v 1.1 2004/03/29 01:11:16 shawn Exp $ |
| 4 |
|
| 5 |
IUSE="${IUSE} apache2" |
| 6 |
|
| 7 |
DESCRIPTION="Apache module for PHP" |
| 8 |
KEYWORDS="~x86 ~ppc ~sparc ~alpha ~hppa ~ia64 ~amd64" |
| 9 |
|
| 10 |
detectapache() { |
| 11 |
local domsg= |
| 12 |
[ -n "$1" ] && domsg=1 |
| 13 |
HAVE_APACHE1= |
| 14 |
HAVE_APACHE2= |
| 15 |
has_version '=net-www/apache-1*' && HAVE_APACHE1=1 |
| 16 |
has_version '=net-www/apache-2*' && HAVE_APACHE2=1 |
| 17 |
|
| 18 |
[ -n "${HAVE_APACHE1}" ] && APACHEVER=1 |
| 19 |
[ -n "${HAVE_APACHE2}" ] && APACHEVER=2 |
| 20 |
[ -n "${HAVE_APACHE1}" ] && [ -n "${HAVE_APACHE2}" ] && APACHEVER='both' |
| 21 |
|
| 22 |
case "${APACHEVER}" in |
| 23 |
1) [ -n "${domsg}" ] && einfo 'Apache1 only detected' ;; |
| 24 |
2) [ -n "${domsg}" ] && einfo 'Apache2 only detected';; |
| 25 |
both) |
| 26 |
if [ "`use apache2`" ]; then |
| 27 |
[ -n "${domsg}" ] && einfo "Multiple Apache versions detected, using Apache2 (USE=apache2)" |
| 28 |
APACHEVER=2 |
| 29 |
else |
| 30 |
[ -n "${domsg}" ] && einfo 'Multiple Apache versions detected, using Apache1 (USE=-apache2)' |
| 31 |
APACHEVER=1 |
| 32 |
fi ;; |
| 33 |
*) if [ -n "${domsg}" ]; then |
| 34 |
MSG="Unknown Apache version!"; eerror $MSG ; die $MSG |
| 35 |
else |
| 36 |
APACHEVER=0 |
| 37 |
fi; ;; |
| 38 |
esac |
| 39 |
} |
| 40 |
|
| 41 |
detectapache |
| 42 |
|
| 43 |
SLOT="${APACHEVER}" |
| 44 |
[ "${APACHEVER}" -eq '2' ] && USE_APACHE2='2' || USE_APACHE2='' |
| 45 |
|
| 46 |
PHPSAPI="apache${APACHEVER}" |
| 47 |
|
| 48 |
# BIG FAT WARNING! |
| 49 |
# the php eclass requires the PHPSAPI setting! |
| 50 |
# In this case the PHPSAPI setting is dependant on the detectapache function |
| 51 |
# above this point as well! |
| 52 |
inherit php-sapi eutils |
| 53 |
|
| 54 |
DEPEND_EXTRA=">=net-www/apache-1.3.26-r2 |
| 55 |
apache2? ( >=net-www/apache-2.0.43-r1 )" |
| 56 |
DEPEND="${DEPEND} ${DEPEND_EXTRA}" |
| 57 |
RDEPEND="${RDEPEND} ${DEPEND_EXTRA}" |
| 58 |
|
| 59 |
# Add a 'return 0' as we DON'T want the return code checked |
| 60 |
pkg_setup() { |
| 61 |
use debug && einfo "Installing in SLOT=${SLOT}" |
| 62 |
return 0 |
| 63 |
} |
| 64 |
|
| 65 |
src_unpack() { |
| 66 |
multiinstwarn |
| 67 |
detectapache domsg |
| 68 |
php-sapi_src_unpack |
| 69 |
if [ "${ARCH}" == "amd64" ] ; then |
| 70 |
epatch ${FILESDIR}/${P}-amd64hack.diff |
| 71 |
fi |
| 72 |
|
| 73 |
# bug fix for security problem - bug #39952 |
| 74 |
epatch ${FILESDIR}/mod_php-4.3.5.diff |
| 75 |
} |
| 76 |
|
| 77 |
src_compile() { |
| 78 |
# Every Apache2 MPM EXCEPT prefork needs Zend Thread Safety |
| 79 |
if [ -n "${USE_APACHE2}" ]; then |
| 80 |
APACHE2_MPM="`apache2 -l |egrep 'worker|perchild|leader|threadpool|prefork'|cut -d. -f1|sed -e 's/^[[:space:]]*//g;s/[[:space:]]+/ /g;'`" |
| 81 |
einfo "Apache2 MPM: ${APACHE2_MPM}" |
| 82 |
case "${APACHE2_MPM}" in |
| 83 |
*prefork*) ;; |
| 84 |
*) myconf="${myconf} --enable-experimental-zts" ; ewarn "Enabling ZTS for Apache2 MPM" ;; |
| 85 |
esac; |
| 86 |
fi |
| 87 |
|
| 88 |
#use apache2 \ |
| 89 |
myconf="${myconf} --with-apxs${USE_APACHE2}=/usr/sbin/apxs${USE_APACHE2}" |
| 90 |
|
| 91 |
php-sapi_src_compile |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
src_install() { |
| 96 |
PHP_INSTALLTARGETS="install" |
| 97 |
php-sapi_src_install |
| 98 |
einfo "Adding extra symlink to php.ini for Apache${USE_APACHE2}" |
| 99 |
dodir /etc/apache${USE_APACHE2}/conf/ |
| 100 |
dodir ${PHPINIDIRECTORY} |
| 101 |
dosym ${PHPINIDIRECTORY}/${PHPINIFILENAME} /etc/apache${USE_APACHE2}/conf/${PHPINIFILENAME} |
| 102 |
|
| 103 |
einfo "Adding extra symlink to Apache${USE_APACHE2} extramodules for PHP" |
| 104 |
dosym /usr/lib/apache${USE_APACHE2}-extramodules ${PHPINIDIRECTORY}/lib |
| 105 |
exeinto /usr/lib/apache${USE_APACHE2}-extramodules |
| 106 |
einfo "Installing mod_php shared object now" |
| 107 |
doexe .libs/libphp4.so |
| 108 |
|
| 109 |
if [ -n "${USE_APACHE2}" ] ; then |
| 110 |
einfo "Installing a Apache2 config for PHP (70_mod_php.conf)" |
| 111 |
insinto /etc/apache2/conf/modules.d |
| 112 |
doins ${FILESDIR}/70_mod_php.conf |
| 113 |
else |
| 114 |
einfo "Installing a Apache config for PHP (mod_php.conf)" |
| 115 |
insinto /etc/apache/conf/addon-modules |
| 116 |
doins ${FILESDIR}/mod_php.conf |
| 117 |
dosym ${PHPINIDIRECTORY}/${PHPINIFILENAME} /etc/apache/conf/addon-modules/${PHPINIFILENAME} |
| 118 |
fi |
| 119 |
} |
| 120 |
|
| 121 |
apache2msg() { |
| 122 |
einfo "Edit /etc/conf.d/apache2 and add \"-D PHP4\" to APACHE2_OPTS" |
| 123 |
ewarn "This is a CHANGE from previous behavior, which was \"-D PHP\"" |
| 124 |
ewarn "This is for the upcoming PHP5 support. The ebuild will attempt" |
| 125 |
ewarn "to make this update between PHP and PHP4 automatically" |
| 126 |
} |
| 127 |
|
| 128 |
multiinstwarn() { |
| 129 |
ewarn "Due to some previous bloopers with PHP and slotting, you may have" |
| 130 |
ewarn "multiple instances of mod_php installed. Please look at the autoclean" |
| 131 |
ewarn "output at the end of the emerge and unmerge all but relevant" |
| 132 |
ewarn "instances." |
| 133 |
} |
| 134 |
|
| 135 |
apache2fix() { |
| 136 |
if egrep -q -- '-D PHP\>' /etc/conf.d/apache2; then |
| 137 |
einfo "Attemping to update /etc/conf.d/apache2 automatically for the PHP/PHP4 change." |
| 138 |
local oldfile="/etc/conf.d/apache2.old.`date +%Y%m%d%H%M%S`" |
| 139 |
cp /etc/conf.d/apache2 ${oldfile} |
| 140 |
sed -re 's,-D PHP\>,-D PHP4,g' ${oldfile} <${oldfile} >/etc/conf.d/apache2 |
| 141 |
fi |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
pkg_preinst() { |
| 146 |
multiinstwarn |
| 147 |
[ "${APACHEVER}" -eq '2' ] && apache2fix |
| 148 |
php-sapi_pkg_preinst |
| 149 |
} |
| 150 |
|
| 151 |
pkg_postinst() { |
| 152 |
php-sapi_pkg_postinst |
| 153 |
multiinstwarn |
| 154 |
einfo "To have Apache run php programs, please do the following:" |
| 155 |
if [ -n "${USE_APACHE2}" ]; then |
| 156 |
apache2msg |
| 157 |
else |
| 158 |
einfo "1. Execute the command:" |
| 159 |
einfo " \"ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config\"" |
| 160 |
einfo "2. Edit /etc/conf.d/apache and add \"-D PHP4\" to APACHE_OPTS" |
| 161 |
einfo "That will include the php mime types in your configuration" |
| 162 |
einfo "automagically and setup Apache to load php when it starts." |
| 163 |
fi |
| 164 |
} |
| 165 |
|
| 166 |
pkg_config() { |
| 167 |
multiinstwarn |
| 168 |
if [ -n "${USE_APACHE2}" ]; then |
| 169 |
apache2msg |
| 170 |
else |
| 171 |
${ROOT}/usr/sbin/apacheaddmod \ |
| 172 |
${ROOT}/etc/apache/conf/apache.conf \ |
| 173 |
extramodules/libphp4.so mod_php4.c php4_module \ |
| 174 |
before=perl define=PHP4 addconf=conf/addon-modules/mod_php.conf |
| 175 |
:; |
| 176 |
fi |
| 177 |
} |