generated from version-fox/vfox-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall
executable file
·292 lines (238 loc) · 8.75 KB
/
install
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
289
290
291
292
#!/usr/bin/env bash
# This code is adapted from https://github.com/asdf-community/asdf-php/blob/master/bin/install
set -eo pipefail
install_php() {
local install_path=$1
local source_path="${install_path}_source"
local configure_options="$(construct_configure_options $install_path)"
local operating_system=$(uname -a)
if [[ $operating_system =~ "Darwin" ]]; then
exit_if_homebrew_not_installed
local bison_path=$(homebrew_package_path bison)
local icu4c_path=$(homebrew_package_path icu4c)
local krb5_path=$(homebrew_package_path krb5)
local libedit_path=$(homebrew_package_path libedit)
local libxml2_path=$(homebrew_package_path libxml2)
local libxslt_path=$(homebrew_package_path libxslt)
local openssl_path=$(homebrew_package_path [email protected])
if [ -n "$bison_path" ]; then
export "PATH=${bison_path}/bin:${PATH}"
fi
if [ -n "$icu4c_path" ]; then
export "PKG_CONFIG_PATH=${icu4c_path}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
if [ -n "$krb5_path" ]; then
export "PKG_CONFIG_PATH=${krb5_path}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
if [ -n "$libedit_path" ]; then
export "PKG_CONFIG_PATH=${libedit_path}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
if [ -n "$libxml2_path" ]; then
export "PKG_CONFIG_PATH=${libxml2_path}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
if [ -n "$libxslt_path" ]; then
export "PKG_CONFIG_PATH=${libxslt_path}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
if [ -n "$openssl_path" ]; then
export "PKG_CONFIG_PATH=${openssl_path}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
fi
# Running this in a subshell because we don't to disturb the current
# working directory.
(
mv $install_path $source_path
cd $source_path
# Target is OS-specific
# target=$(get_target)
# Build PHP
echo "Running buildconfig..."
./buildconf --force || exit 1
echo "Running ./configure $configure_options"
./configure $configure_options || exit 1
echo "Running make"
make || exit 1
echo "Running make install..."
# make test || exit 1
make install || exit 1
)
# it's not obvious where php.ini should be placed, let us make it easy for the user
mkdir -p $install_path/conf.d/
echo "# add system-wide php configuration options here" >$install_path/conf.d/php.ini
rm -rf $source_path
}
install_composer() {
local bin_path=$1/bin
local expected_signature="$(curl -sL https://composer.github.io/installer.sig)"
$bin_path/php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$bin_path/php -r "if (hash_file('sha384', 'composer-setup.php') === '${expected_signature}') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
$bin_path/php composer-setup.php --install-dir=$bin_path --filename=composer
$bin_path/php -r "unlink('composer-setup.php');"
}
construct_configure_options() {
local install_path=$1
# many options included below are not applicable to newer PHP versions
# including these will trigger a build warning, but will not b
global_config="--prefix=$install_path \
--enable-bcmath \
--enable-calendar \
--enable-dba \
--enable-exif \
--enable-fpm \
--enable-ftp \
--enable-gd \
--enable-gd-native-ttf \
--enable-intl \
--enable-mbregex \
--enable-mbstring \
--enable-mysqlnd \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-zip \
--sysconfdir=$install_path \
--with-config-file-path=$install_path \
--with-config-file-scan-dir=$install_path/conf.d \
--with-curl \
--with-external-gd \
--with-fpm-group=www-data \
--with-fpm-user=www-data \
--with-gd \
--with-mhash \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-xmlrpc \
--with-zip \
--with-zlib \
--without-snmp"
if [ "$PHP_CONFIGURE_OPTIONS" = "" ]; then
local configure_options="$(os_based_configure_options) $global_config"
else
local configure_options="$PHP_CONFIGURE_OPTIONS $global_config"
fi
if [ "${PHP_WITHOUT_PEAR:-no}" != "no" ]; then
configure_options="$configure_options --without-pear"
else
configure_options="$configure_options --with-pear"
fi
if [ "${PHP_WITHOUT_PCRE_JIT:-no}" != "no" ]; then
configure_options="$configure_options"
else
configure_options="$configure_options --without-pcre-jit"
fi
echo "$configure_options"
}
homebrew_package_path() {
local package_name=$1
if [ "$(brew ls --versions $package_name)" = "" ]; then
echo ""
else
echo "$(brew --prefix $package_name)"
fi
}
exit_if_homebrew_not_installed() {
if [ "$(brew --version 2>/dev/null)" = "" ]; then
echo "ERROR: Please install homebrew for OSX"
exit 1
fi
}
os_based_configure_options() {
local operating_system=$(uname -a)
local configure_options=""
if [[ $operating_system =~ "Darwin" ]]; then
exit_if_homebrew_not_installed
local bison_path=$(homebrew_package_path bison)
local bzip2_path=$(homebrew_package_path bzip2)
local freetype_path=$(homebrew_package_path freetype)
local gettext_path=$(homebrew_package_path gettext)
local iconv_path=$(homebrew_package_path libiconv)
local icu4c_path=$(homebrew_package_path icu4c)
local jpeg_path=$(homebrew_package_path jpeg)
local libedit_path=$(homebrew_package_path libedit)
local libpng_path=$(homebrew_package_path libpng)
local libxml2_path=$(homebrew_package_path libxml2)
local libxslt_path=$(homebrew_package_path libxslt)
local libzip_path=$(homebrew_package_path libzip)
local openssl_path=$(homebrew_package_path [email protected])
local readline_path=$(homebrew_package_path readline)
local webp_path=$(homebrew_package_path webp)
local zlib_path=$(homebrew_package_path zlib)
# optional
# if these packages exist they are included in the php compilation
local gmp_path=$(homebrew_package_path gmp)
local sodium_path=$(homebrew_package_path libsodium)
if [ -n "$gmp_path" ]; then
configure_options="--with-gmp=$gmp_path"
else
echo "gmp not found, not including in installation"
fi
if [ -n "$sodium_path" ]; then
configure_options="$configure_options --with-sodium=$sodium_path"
else
echo "sodium not found, not including in installation"
fi
if [ -n "$freetype_path" ]; then
configure_options="$configure_options --with-freetype-dir=$freetype_path"
fi
if [ -n "$gettext_path" ]; then
configure_options="$configure_options --with-gettext=$gettext_path"
fi
if [ -n "$icu4c_path" ]; then
configure_options="$configure_options --with-icu-dir=$icu4c_path"
fi
if [ -n "$jpeg_path" ]; then
configure_options="$configure_options --with-jpeg-dir=$jpeg_path"
fi
if [ -n "$webp_path" ]; then
configure_options="$configure_options --with-webp-dir=$webp_path"
fi
if [ -n "$libpng_path" ]; then
configure_options="$configure_options --with-png-dir=$libpng_path"
fi
if [ -n "$openssl_path" ]; then
configure_options="$configure_options --with-openssl=$openssl_path"
fi
if [ -n "$libxml2_path" ]; then
configure_options="$configure_options --with-libxml-dir=$libxml2_path"
fi
if [ -n "$libxslt_path" ]; then
configure_options="$configure_options --with-xsl=$libxslt_path"
fi
if [ -n "$zlib_path" ]; then
configure_options="$configure_options --with-zlib-dir=$zlib_path"
fi
if [ -n "$libzip_path" ]; then
configure_options="$configure_options --with-libzip=$libzip_path"
fi
if [ -n "$readline_path" ]; then
configure_options="$configure_options --with-readline=$readline_path"
fi
if [ -n "$libedit_path" ]; then
configure_options="$configure_options --with-libedit=$libedit_path"
fi
if [ -n "$bzip2_path" ]; then
configure_options="$configure_options --with-bz2=$bzip2_path"
fi
if [ -n "$iconv_path" ]; then
configure_options="$configure_options --with-iconv=$iconv_path"
fi
else
local jpeg_path=$(locate libjpeg.so | awk '{ print length(), $0 | "sort -n" }' | cut -d" " -f2- | head -n 1)
local libpng_path=$(locate libpng.so | awk '{ print length(), $0 | "sort -n" }' | cut -d" " -f2- | head -n 1)
configure_options="--with-openssl --with-curl --with-zlib --with-readline --with-gettext --with-xsl"
if [ -n "$jpeg_path" ]; then
configure_options="$configure_options --with-jpeg-dir=$jpeg_path --with-jpeg"
fi
if [ -n "$libpng_path" ]; then
configure_options="$configure_options --with-png-dir=$libpng_path --with-png"
fi
fi
echo $configure_options
}
install_php $1
install_composer $1