blob: a7e68e1c7016006e528efa8235f1696a979b34c0 (
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/php/php-4.4.2.ebuild,v 1.11 2006/04/20 12:35:09 chtekk Exp $
IUSE="cgi cli discard-path force-cgi-redirect"
KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 s390 sh sparc x86"
# NOTE: Portage doesn't support setting PROVIDE based on the USE flags
# that have been enabled, so we have to PROVIDE everything for now
# and hope for the best
PROVIDE="virtual/php virtual/httpd-php"
# php package settings
SLOT="4"
MY_PHP_PV="${PV}"
MY_PHP_P="php-${MY_PHP_PV}"
PHP_PACKAGE=1
# php patch settings
PHP_PATCHSET_REV="1"
HARDENEDPHP_PATCH="hardening-patch-${MY_PHP_PV}-0.4.8-gentoo.patch.gz"
MULTILIB_PATCH="${MY_PHP_PV}/opt/php${MY_PHP_PV}-multilib-search-path.patch"
FASTBUILD_PATCH="${MY_PHP_PV}/opt/php${MY_PHP_PV}-fastbuild.patch"
inherit php4_4-sapi apache-module
want_apache
DESCRIPTION="The PHP language runtime engine."
DEPEND="${DEPEND} app-admin/php-toolkit"
RDEPEND="${RDEPEND} app-admin/php-toolkit"
# PHP patchsets
SRC_URI="${SRC_URI} http://gentoo.longitekk.com/php-patchset-${MY_PHP_PV}-r${PHP_PATCHSET_REV}.tar.bz2"
# Hardened-PHP patch
[[ -n "${HARDENEDPHP_PATCH}" ]] && SRC_URI="${SRC_URI} hardenedphp? ( http://gentoo.longitekk.com/${HARDENEDPHP_PATCH} )"
pkg_setup() {
PHPCONFUTILS_AUTO_USE=""
# make sure the user has specified a SAPI
einfo "Determining SAPI(s) to build"
phpconfutils_require_any " Enabled SAPI:" " Disabled SAPI:" cli cgi apache apache2
if useq apache2 ; then
if [[ "${APACHE_VERSION}" != "0" ]] ; then
if ! useq threads ; then
APACHE2_SAFE_MPMS="peruser prefork"
else
APACHE2_SAFE_MPMS="event leader metuxmpm perchild threadpool worker"
fi
ewarn
ewarn "If this package fails with a fatal error about Apache2 not having"
ewarn "been compiled with a compatible MPM, this is normally because you"
ewarn "need to toggle the 'threads' USE flag."
ewarn
ewarn "If 'threads' is off, try switching it on."
ewarn "If 'threads' is on, try switching it off."
ewarn
apache-module_pkg_setup
fi
fi
if useq fastbuild ; then
ewarn
ewarn "'fastbuild' attempts to build all SAPIs in a single pass."
ewarn "This is an experimental feature, which may fail to compile"
ewarn "and may produce PHP binaries which are broken."
ewarn
ewarn "Rebuild without 'fastbuild' and reproduce any bugs before filing"
ewarn "any bugs in Gentoo's Bugzilla or bugs.php.net."
ewarn
fi
php4_4-sapi_pkg_setup
}
php_determine_sapis() {
# holds the list of sapis that we want to build
PHPSAPIS=
if useq cli || phpconfutils_usecheck cli ; then
PHPSAPIS="${PHPSAPIS} cli"
fi
if useq cgi ; then
PHPSAPIS="${PHPSAPIS} cgi"
fi
# note - we can only build one apache sapi for now
# note - apache SAPI comes after the simpler cli/cgi sapis
if useq apache || useq apache2 ; then
if [[ "${APACHE_VERSION}" != "0" ]] ; then
PHPSAPIS="${PHPSAPIS} apache${APACHE_VERSION}"
fi
fi
}
src_compile() {
if useq fastbuild && [[ -n "${FASTBUILD_PATCH}" ]] ; then
src_compile_fastbuild
else
src_compile_normal
fi
}
src_compile_fastbuild() {
php_determine_sapis
build_cli=0
build_cgi=0
build_apache=0
for x in ${PHPSAPIS} ; do
case ${x} in
cli)
build_cli=1
;;
cgi)
build_cgi=1
;;
apache*)
build_apache=1
;;
esac
done
if [[ ${build_cli} = 1 ]] ; then
my_conf="${my_conf} --enable-cli"
else
my_conf="${my_conf} --disable-cli"
fi
if [[ ${build_cgi} = 1 ]] ; then
my_conf="${my_conf} --enable-cgi --enable-fastcgi"
phpconfutils_extension_enable "discard-path" "discard-path" 0
phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0
else
my_conf="${my_conf} --disable-cgi"
fi
if [[ ${build_apache} = 1 ]] ; then
my_conf="${my_conf} --with-apxs${USE_APACHE2}=/usr/sbin/apxs${USE_APACHE2}"
fi
# now we know what we are building, build it
php4_4-sapi_src_compile
# to keep the separate php.ini files for each SAPI, we change the
# build-defs.h and recompile
if [[ ${build_cli} = 1 ]] ; then
einfo
einfo "Building CLI SAPI"
einfo
sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php/cli-php4"|g;' -i main/build-defs.h
sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php/cli-php4/ext-active"|g;' -i main/build-defs.h
for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
[[ -f ${x} ]] && rm -f ${x}
done
make sapi/cli/php || die "Unable to make CLI SAPI"
cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI"
fi
if [[ ${build_cgi} = 1 ]] ; then
einfo
einfo "Building CGI SAPI"
einfo
sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php/cgi-php4"|g;' -i main/build-defs.h
sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php/cgi-php4/ext-active"|g;' -i main/build-defs.h
for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
[[ -f ${x} ]] && rm -f ${x}
done
make sapi/cgi/php || die "Unable to make CGI SAPI"
cp sapi/cgi/php php-cgi || die "Unable to copy CGI SAPI"
fi
if [[ ${build_apache} = 1 ]] ; then
einfo
einfo "Building apache${USE_APACHE2} SAPI"
einfo
sed -e "s|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH \"/etc/php/apache${APACHE_VERSION}-php4\"|g;" -i main/build-defs.h
sed -e "s|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR \"/etc/php/apache${APACHE_VERSION}-php4/ext-active\"|g;" -i main/build-defs.h
for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
[[ -f ${x} ]] && rm -f ${x}
done
make || die "Unable to build mod_php"
fi
}
src_compile_normal() {
php_determine_sapis
CLEAN_REQUIRED=0
for x in ${PHPSAPIS} ; do
if [[ "${CLEAN_REQUIRED}" = 1 ]] ; then
make clean
fi
PHPSAPI=${x}
case ${x} in
cli)
my_conf="--enable-cli --disable-cgi"
php4_4-sapi_src_compile
cp sapi/cli/php php-cli
;;
cgi)
my_conf="--disable-cli --enable-cgi --enable-fastcgi"
phpconfutils_extension_enable "discard-path" "discard-path" 0
phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0
php4_4-sapi_src_compile
cp sapi/cgi/php php-cgi
;;
apache*)
my_conf="--disable-cli --with-apxs${USE_APACHE2}=/usr/sbin/apxs${USE_APACHE2}"
php4_4-sapi_src_compile
;;
esac
CLEAN_REQUIRED=1
done
}
src_install() {
php_determine_sapis
destdir=/usr/$(get_libdir)/php4
# let the eclass do the heavy lifting
php4_4-sapi_src_install
einfo
einfo "Installing SAPI(s) ${PHPSAPIS}"
einfo
for x in ${PHPSAPIS} ; do
PHPSAPI=${x}
case ${x} in
cli)
einfo "Installing CLI SAPI"
into ${destdir}
newbin php-cli php || die "Unable to install ${x} sapi"
php4_4-sapi_install_ini
;;
cgi)
einfo "Installing CGI SAPI"
into ${destdir}
dobin php-cgi || die "Unable to install ${x} sapi"
php4_4-sapi_install_ini
;;
apache*)
einfo "Installing apache${USE_APACHE2} SAPI"
make INSTALL_ROOT="${D}" install-sapi || die "Unable to install ${x} SAPI"
if [[ -n "${USE_APACHE2}" ]] ; then
einfo "Installing Apache2 config file for PHP4 (70_mod_php.conf)"
insinto ${APACHE_MODULES_CONFDIR}
newins "${FILESDIR}/70_mod_php.conf-apache2" "70_mod_php.conf"
else
einfo "Installing Apache config file for PHP4 (70_mod_php.conf)"
insinto ${APACHE_MODULES_CONFDIR}
newins "${FILESDIR}/70_mod_php.conf-apache1" "70_mod_php.conf"
fi
php4_4-sapi_install_ini
;;
esac
done
}
pkg_postinst() {
# Output some general info to the user
if useq apache || useq apache2 ; then
APACHE1_MOD_DEFINE="PHP4"
APACHE1_MOD_CONF="70_mod_php"
APACHE2_MOD_DEFINE="PHP4"
APACHE2_MOD_CONF="70_mod_php"
apache-module_pkg_postinst
fi
php4_4-sapi_pkg_postinst
}
|