0
|
1 |
#!/usr/bin/ksh93
|
|
2 |
#
|
|
3 |
# CDDL HEADER START
|
|
4 |
#
|
|
5 |
# The contents of this file are subject to the terms of the
|
|
6 |
# Common Development and Distribution License (the "License").
|
|
7 |
# You may not use this file except in compliance with the License.
|
|
8 |
#
|
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
10 |
# or http://www.opensolaris.org/os/licensing.
|
|
11 |
# See the License for the specific language governing permissions
|
|
12 |
# and limitations under the License.
|
|
13 |
#
|
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each
|
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
16 |
# If applicable, add the following below this CDDL HEADER, with the
|
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying
|
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner]
|
|
19 |
#
|
|
20 |
# CDDL HEADER END
|
|
21 |
#
|
|
22 |
#
|
198
|
23 |
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
|
0
|
24 |
#
|
198
|
25 |
#pragma ident "@(#)install-php5 1.17 11/02/07 SMI"
|
0
|
26 |
|
|
27 |
set -o errexit
|
|
28 |
|
|
29 |
# use builtin commands (faster)
|
|
30 |
builtin cp
|
|
31 |
builtin rm
|
|
32 |
builtin mv
|
|
33 |
builtin chmod
|
|
34 |
|
|
35 |
source "${SRC}/tools/install.subr"
|
|
36 |
source "${SRC}/cmd/apache2/apache.build.env"
|
|
37 |
|
|
38 |
CWD=$(pwd)
|
|
39 |
|
|
40 |
PHP_VER=$(grep "^VERSION:" METADATA | awk '{print $2}')
|
|
41 |
PHP_REL=$(grep "^PHP_REL=" Makefile.sfw | sed s/PHP_REL=//)
|
|
42 |
PHPDIR=php-${PHP_VER}
|
|
43 |
PHPCGI=${PHPDIR}-cgi
|
6
|
44 |
PHPNSAPI=${PHPDIR}-nsapi
|
|
45 |
|
|
46 |
PHP_ROOT_CONF=/etc/php/${PHP_REL}
|
|
47 |
PHP_ROOT_NSAPI_CONF=/etc/php/${PHP_REL}/nsapi
|
|
48 |
PHP_ROOT_MODULES_CONF=/etc/php/${PHP_REL}/conf.d
|
|
49 |
PHP_ROOT_ZTS_MODULES_CONF=/etc/php/${PHP_REL}/zts-conf.d
|
0
|
50 |
|
|
51 |
PHP_ROOT=/usr/php/${PHP_REL}
|
|
52 |
PHP_ROOT_BIN=${PHP_ROOT}/bin
|
|
53 |
PHP_ROOT_LIB=${PHP_ROOT}/lib
|
|
54 |
PHP_ROOT_INC=${PHP_ROOT}/include/php
|
|
55 |
PHP_ROOT_EXT=${PHP_ROOT}/modules
|
6
|
56 |
PHP_ROOT_ZTS_EXT=${PHP_ROOT}/zts-modules
|
0
|
57 |
|
|
58 |
LOCAL_CONFDIR=${CWD}/config/extensions
|
6
|
59 |
|
0
|
60 |
CONFDIR=${ROOT}/etc/php/${PHP_REL}
|
6
|
61 |
NSAPI_CONFDIR=${ROOT}/etc/php/${PHP_REL}/nsapi
|
|
62 |
MODULES_CONFDIR=${CONFDIR}/conf.d
|
|
63 |
ZTS_MODULES_CONFDIR=${CONFDIR}/zts-conf.d
|
|
64 |
|
0
|
65 |
TOPDIR=${ROOT}/usr/php/${PHP_REL}
|
|
66 |
BINDIR=${TOPDIR}/bin
|
|
67 |
LIBDIR=${TOPDIR}/lib
|
|
68 |
DOCDIR=${TOPDIR}/doc
|
|
69 |
MANDIR=${TOPDIR}/man/man1
|
|
70 |
INCDIR=${TOPDIR}/include/php
|
|
71 |
EXTDIR=${TOPDIR}/modules
|
6
|
72 |
ZTS_EXTDIR=${TOPDIR}/zts-modules
|
0
|
73 |
|
|
74 |
SCRIPTS_DIR=${TOPDIR}/samples/scripts
|
|
75 |
|
|
76 |
PEAR_TOPDIR=${ROOT}/var/php/${PHP_REL}/pear
|
|
77 |
SESSION_TOPDIR=${ROOT}/var/php/${PHP_REL}/sessions
|
|
78 |
|
|
79 |
APACHE2_SAMPLES_CONFDIR=${ROOT}/${APACHE_ETC_PREFIX}/samples-conf.d
|
|
80 |
APACHE2_CONFDIR=${ROOT}/${APACHE_ETC_PREFIX}/conf.d
|
|
81 |
APACHE2_EXTDIR=${ROOT}/${APACHE_USR_PREFIX}/libexec
|
|
82 |
|
|
83 |
COPYRIGHT_TMPL=${CWD}/Solaris/copyright.tmpl
|
|
84 |
|
|
85 |
# ----- Common Utility Functions -----
|
|
86 |
|
|
87 |
# Handle the glue to Apache 2 HTTP Server.
|
|
88 |
#
|
|
89 |
add_apache2_module_support() {
|
|
90 |
_install N ${CWD}/Solaris/php${PHP_REL}.conf $APACHE2_CONFDIR/php${PHP_REL}.conf 644
|
|
91 |
_install D $APACHE2_EXTDIR/libphp5.so $APACHE2_EXTDIR/mod_php${PHP_REL}.so 555
|
|
92 |
(cd $APACHE2_EXTDIR/ && _install L mod_php${PHP_REL}.so mod_php5.so)
|
|
93 |
rm -f $APACHE2_EXTDIR/libphp5.so
|
|
94 |
chmod 750 "${SESSION_TOPDIR}"
|
|
95 |
}
|
|
96 |
|
6
|
97 |
add_nsapi_module_support() {
|
|
98 |
mkdir -p $TOPDIR/nsapi
|
|
99 |
_install D $PHPNSAPI/libs/libphp5.so $TOPDIR/nsapi/libphp5.so 555
|
|
100 |
}
|
|
101 |
|
0
|
102 |
# handle all configuration related manipulations.
|
|
103 |
#
|
|
104 |
fix_config_files() {
|
6
|
105 |
mkdir -p ${NSAPI_CONFDIR} ${MODULES_CONFDIR} ${ZTS_MODULES_CONFDIR}
|
0
|
106 |
|
|
107 |
# Ship a default php.ini to simplify ease of use.
|
|
108 |
(cd ${CWD}/php-${PHP_VER} && \
|
|
109 |
gpatch -p1 -o php.ini-patched -i ${CWD}/patches/php_ini.patch && \
|
|
110 |
cat php.ini-patched | sed -e "s#<<VERSION>>#${PHP_REL}#g" > php.ini )
|
|
111 |
_install N ${CWD}/php-${PHP_VER}/php.ini ${CONFDIR}/php.ini 644
|
|
112 |
|
6
|
113 |
# Ship a default php.ini for NSAPI module.
|
|
114 |
(cd ${CWD}/${PHPNSAPI} && \
|
|
115 |
cat ${CONFDIR}/php.ini | \
|
|
116 |
sed -e "s,extension_dir = \(.*\),extension_dir=$PHP_ROOT_ZTS_EXT," > php.ini )
|
|
117 |
_install N ${CWD}/${PHPNSAPI}/php.ini ${NSAPI_CONFDIR}/php.ini 644
|
|
118 |
|
0
|
119 |
# Prepare configuration files for each extension
|
|
120 |
# By default, disable following 3rd party extensions:
|
|
121 |
# xdebug suhosin
|
|
122 |
for module in ${EXTDIR}/*.so; do
|
|
123 |
module=${module%.so}
|
|
124 |
ext=${module##*/}
|
|
125 |
cat ${COPYRIGHT_TMPL} | sed -e s@\#@\;@ > ${ext}.ini
|
3
|
126 |
echo "extension=${ext}.so" >> ${ext}.ini
|
6
|
127 |
_install N ${ext}.ini ${MODULES_CONFDIR}/${ext}.ini 644
|
|
128 |
_install N ${ext}.ini ${ZTS_MODULES_CONFDIR}/${ext}.ini 644
|
0
|
129 |
rm ${ext}.ini
|
|
130 |
done
|
|
131 |
for each in ${LOCAL_CONFDIR}/*.ini; do
|
|
132 |
ext=${each##*/}
|
6
|
133 |
_install N $each $MODULES_CONFDIR/${ext} 644
|
|
134 |
cat $each | \
|
|
135 |
sed -e "s,zend_extension=$PHP_ROOT_EXT,zend_extension=$PHP_ROOT_ZTS_EXT," > tmp
|
|
136 |
_install N tmp $ZTS_MODULES_CONFDIR/${ext} 644
|
|
137 |
rm tmp
|
0
|
138 |
done
|
|
139 |
}
|
|
140 |
|
|
141 |
# scripts in the bin directory have paths to the build environment
|
|
142 |
# wired into them - need to fix these
|
|
143 |
#
|
|
144 |
fix_bin_scripts() {
|
|
145 |
# Adjust scripts for building extensions
|
|
146 |
mkdir -p ${BINDIR}
|
|
147 |
cd ${CWD}
|
|
148 |
cat ${PHPDIR}/scripts/phpize | \
|
|
149 |
sed -e "s#^prefix=.*#prefix=${PHP_ROOT}#" | \
|
|
150 |
sed -e "s#^exec_prefix=.*#exec_prefix=${PHP_ROOT}#" | \
|
|
151 |
sed -e "s#^includedir=.*#includedir=${PHP_ROOT_INC}#" | \
|
|
152 |
sed -e "s#^phpdir=.*#phpdir=${PHP_ROOT_LIB}/build#" | \
|
|
153 |
sed -e "s#^php_binary=.*#php_binary=${PHP_ROOT_BIN}/php#" | \
|
|
154 |
sed -e "s#^extension_dir=.*#extension_dir=${PHP_ROOT_EXT}#" \
|
|
155 |
> phpize
|
|
156 |
|
|
157 |
cat ${PHPDIR}/scripts/php-config | \
|
|
158 |
sed -e "s#^prefix=.*#prefix=${PHP_ROOT}#" | \
|
|
159 |
sed -e "s#^exec_prefix=.*#exec_prefix=${PHP_ROOT}#" | \
|
|
160 |
sed -e "s#^includedir=.*#includedir=${PHP_ROOT_INC}#" | \
|
|
161 |
sed -e "s#^phpdir=.*#phpdir=${PHP_ROOT}#" | \
|
|
162 |
sed -e "s#^php_binary=.*#php_binary=${PHP_ROOT_BIN}/php#" | \
|
|
163 |
sed -e "s#^extension_dir=.*#extension_dir=${PHP_ROOT_EXT}#" \
|
|
164 |
> php-config
|
|
165 |
|
|
166 |
# Ensure basic file permissions.
|
|
167 |
_install S php-config ${BINDIR}/php-config 555
|
|
168 |
_install S phpize ${BINDIR}/phpize 555
|
|
169 |
|
|
170 |
_install E ${PHPDIR}/sapi/cli/php ${BINDIR}/php 555
|
|
171 |
_install E ${PHPCGI}/sapi/cgi/php-cgi ${BINDIR}/php-cgi 555
|
|
172 |
}
|
|
173 |
|
|
174 |
# doc related
|
|
175 |
install_docs() {
|
|
176 |
mkdir -p ${DOCDIR}
|
|
177 |
cd ${DOCDIR};
|
|
178 |
cat ${CWD}/Solaris/php_manual_en_20090130.tar.gz | gunzip | tar xf - ;
|
|
179 |
}
|
|
180 |
|
|
181 |
# samples related
|
|
182 |
install_samples() {
|
|
183 |
mkdir -p $APACHE2_SAMPLES_CONFDIR $SCRIPTS_DIR
|
|
184 |
_install N ${CWD}/Solaris/php-apc-stats.conf $APACHE2_SAMPLES_CONFDIR/php-apc-stats.conf 644
|
|
185 |
_install N ${CWD}/Solaris/php-memcache-stats.conf $APACHE2_SAMPLES_CONFDIR/php-memcache-stats.conf 644
|
6
|
186 |
cat ${CWD}/Solaris/configure-sun-webserver | \
|
|
187 |
sed -e "s,<<INSTALL_DIR>>,$PHP_ROOT," | \
|
|
188 |
sed -e "s,<<CONF_DIR>>,$PHP_ROOT_CONF," | \
|
|
189 |
sed -e "s,<<NSAPI_CONF_DIR>>,$PHP_ROOT_NSAPI_CONF," | \
|
|
190 |
sed -e "s,<<MODULES_CONF_DIR>>,$PHP_ROOT_MODULES_CONF," | \
|
|
191 |
sed -e "s,<<ZTS_MODULES_CONF_DIR>>,$PHP_ROOT_ZTS_MODULES_CONF," > tmp
|
|
192 |
_install N tmp $SCRIPTS_DIR/configure-sun-webserver 555
|
|
193 |
rm tmp
|
|
194 |
(cd $ROOT/$PHP_ROOT_BIN && _install L ../samples/scripts/configure-sun-webserver configure-webserver7 555)
|
0
|
195 |
}
|
|
196 |
|
|
197 |
# configure man pages
|
|
198 |
install_man() {
|
|
199 |
cd ${CWD};
|
|
200 |
_install N Solaris/php.1.sunman ${ROOT}/usr/share/man/man1/php.1 444
|
|
201 |
}
|
|
202 |
|
|
203 |
# patch installation to support pear installation.
|
|
204 |
install_pear() {
|
|
205 |
cd ${BINDIR};
|
|
206 |
|
|
207 |
# Ensure basic file permissions.
|
|
208 |
chmod u+w pecl php-config;
|
7
|
209 |
gpatch -i ${CWD}/patches/pear_pecl.patch;
|
|
210 |
gpatch -i ${CWD}/patches/pear_php_config.patch;
|
0
|
211 |
chmod u-w pear peardev pecl php-config;
|
|
212 |
|
|
213 |
cd ${LIBDIR}/build;
|
7
|
214 |
gpatch --no-backup-if-mismatch -i ${CWD}/patches/pear_Makefile_global.patch;
|
0
|
215 |
|
|
216 |
cd ${PEAR_TOPDIR};
|
7
|
217 |
gpatch -p0 -i ${CWD}/patches/pear_Builder_php.patch;
|
0
|
218 |
|
|
219 |
# Ship default PEAR registry files as generated registry files
|
|
220 |
# are corrupted by default.
|
|
221 |
cp ${CWD}/config/pear/*.reg ${PEAR_TOPDIR}/.channels/
|
|
222 |
chmod 0644 ${PEAR_TOPDIR}/.channels/*.reg
|
|
223 |
|
|
224 |
# clean up directories unwanted for packages.
|
|
225 |
if [ -d "${ROOT}/var/tmp/pear/cache" ]; then
|
|
226 |
rm -rf ${ROOT}/var/tmp
|
|
227 |
fi
|
|
228 |
}
|
|
229 |
|
|
230 |
|
|
231 |
# Create symbolic links
|
|
232 |
create_symlinks() {
|
|
233 |
cd ${ROOT}/usr/php;
|
|
234 |
_install L ./${PHP_REL}/bin bin;
|
|
235 |
_install L ./${PHP_REL}/lib lib;
|
|
236 |
_install L ./${PHP_REL}/include include;
|
|
237 |
_install L ./${PHP_REL}/modules modules;
|
|
238 |
_install L ./${PHP_REL}/doc doc;
|
|
239 |
_install L ./${PHP_REL}/man man;
|
|
240 |
}
|
|
241 |
|
|
242 |
fix_php_perms() {
|
|
243 |
cd ${ROOT}/${PHP_ROOT};
|
|
244 |
find . -type d -exec chmod 755 {} \;
|
|
245 |
find . -type f -exec chmod ugo-w {} \;
|
|
246 |
}
|
|
247 |
|
|
248 |
# Final cleanup
|
|
249 |
cleanup() {
|
|
250 |
cd ${ROOT};
|
|
251 |
/bin/rm -rf .lock .depdb .filemap .depdblock .channels .registry
|
|
252 |
}
|
|
253 |
|
|
254 |
# ----- START HERE - actual script processing starts here -----
|
|
255 |
|
|
256 |
# Even though this is called "install-php5", it doesn't really
|
|
257 |
# install the whole thing. Much of php itself is installed by
|
|
258 |
# make install - we need to fix only permissions. What we install here
|
|
259 |
# are stuffs that php won't install as part of its normal build.
|
|
260 |
# Each install task is a function, so it's relatively easy to add new
|
|
261 |
# stuff.
|
|
262 |
#
|
|
263 |
add_apache2_module_support
|
6
|
264 |
add_nsapi_module_support
|
0
|
265 |
fix_config_files
|
|
266 |
fix_bin_scripts
|
|
267 |
install_docs
|
|
268 |
install_man
|
|
269 |
create_symlinks
|
|
270 |
install_pear
|
|
271 |
install_samples
|
|
272 |
fix_php_perms
|
|
273 |
cleanup
|
|
274 |
|
|
275 |
exit 0
|