-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp-install.sh
More file actions
503 lines (466 loc) · 14.5 KB
/
Copy pathphp-install.sh
File metadata and controls
503 lines (466 loc) · 14.5 KB
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
set -eu
apk add --no-cache sudo git libpng libjpeg libpq libxml2 libldap cyrus-sasl unixodbc file mysql-client openssh-client rsync patch bash imagemagick imagemagick-libs rabbitmq-c gettext icu
apk add --no-cache --virtual .build-deps unixodbc-dev brotli-dev gmp-dev yaml-dev samba-dev openldap-dev pcre-dev libxslt-dev imap-dev libzip-dev \
rabbitmq-c-dev mpdecimal-dev gettext-dev imagemagick-dev librdkafka-dev autoconf g++ make icu-dev libpng-dev libjpeg-turbo-dev postgresql-dev libxml2-dev bzip2-dev libmemcached-dev linux-headers pax-utils $PHPIZE_DEPS
case $PHP_VERSION in
8.1*|8.2*|8.3*|8.4*|8.5*|8.6*)
echo "Installing pie in place of pecl for PHP $PHP_VERSION"
curl -fsSL -o /usr/local/bin/pie https://github.com/php/pie/releases/latest/download/pie.phar
chmod +x /usr/local/bin/pie
# libtool is a build dependency for several extensions pie compiles from source.
apk add --no-cache libtool
;;
*)
pecl channel-update pecl.php.net
;;
esac
case $PHP_VERSION in
8.6*)
# todo: Temp workaround for PHP 8.6 (pie's requirement checker doesn't recognize this alpha release yet).
export BOX_REQUIREMENT_CHECKER=0
cat > /root/php86-pie-compat.h <<'EOC'
#ifndef EMPTY_SWITCH_DEFAULT_CASE
#define EMPTY_SWITCH_DEFAULT_CASE()
#endif
#ifndef INI_INT
#define INI_INT(name) ((zend_long) zend_ini_long((name), sizeof(name)-1, 0))
#endif
#ifndef INI_STR
#define INI_STR(name) zend_ini_string((name), sizeof(name)-1, 0)
#endif
#ifndef INI_FLT
#define INI_FLT(name) zend_ini_double((name), sizeof(name)-1, 0)
#endif
#ifndef ZEND_PARSE_PARAMS_THROW
#define ZEND_PARSE_PARAMS_THROW 0
#endif
EOC
export CFLAGS="${CFLAGS:-} -DXtOffsetOf=offsetof -Dzval_dtor=zval_ptr_dtor_nogc -include /root/php86-pie-compat.h"
;;
esac
case $PHP_VERSION in
7.4|8.0)
echo "yes" | pecl install mongodb-1.20.1
;;
8.5*|8.6*)
echo "Skipping mongo db driver for PHP $PHP_VERSION"
;;
8.1*|8.2*|8.3*|8.4*)
pie install mongodb/mongodb-extension
;;
*)
echo "yes" | pecl install mongodb
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
echo "Skipping mongodb for PHP $PHP_VERSION"
;;
8.1*|8.2*|8.3*|8.4*)
echo "mongodb already enabled by pie for PHP $PHP_VERSION"
;;
*)
docker-php-ext-enable mongodb
;;
esac
case $PHP_VERSION in
8.0*)
echo "" | pecl install swoole-5.1.7
docker-php-ext-enable swoole
;;
7.*)
echo "" | pecl install swoole-4.8.13
docker-php-ext-enable swoole
;;
8.1*)
pie install swoole/swoole:6.1.8
;;
8.5*|8.6*)
echo "Skipping swoole for PHP $PHP_VERSION"
;;
8.2*|8.3*|8.4*)
pie install swoole/swoole
;;
*)
echo "" | pecl install swoole
docker-php-ext-enable swoole
;;
esac
case $PHP_VERSION in
7.4|8.0|8.1)
# php-ds/ext-ds has no pie-installable release below PHP 8.2; keep pecl for 8.1.
yes | pecl install ds-1.6.0
;;
8.6*)
# php-ds/ext-ds calls the removed zend_parse_parameter() (the
# single-argument variant; zend_parse_parameters() is unrelated and
# still exists). Patch it to use the still-available
# zend_parse_arg_long() inline helper instead, which is what
# zend_parse_parameter() used internally for the "l" spec anyway.
php -m | grep -q '^ds$' || (
git clone --depth=1 https://github.com/php-ds/ext-ds.git /usr/src/ext-ds &&
cd /usr/src/ext-ds &&
sed -i 's/zend_parse_parameter(ZEND_PARSE_PARAMS_QUIET, 1, offset, "l", \&index) == FAILURE/!zend_parse_arg_long(offset, \&index, NULL, false, 1)/' src/php/handlers/php_seq_handlers.c &&
phpize && ./configure --enable-ds && make -j"$(nproc)" && make install &&
echo "extension=ds.so" > /usr/local/etc/php/conf.d/ds.ini
)
rm -rf /usr/src/ext-ds
;;
8.2*|8.3*|8.4*|8.5*)
pie install php-ds/ext-ds
;;
*)
# If we really need it.
php -m | grep -q '^ds$' || yes | pecl install ds
;;
esac
case $PHP_VERSION in
8.5*)
php -m | grep -q '^igbinary$' || (
git clone --depth=1 https://github.com/igbinary/igbinary.git /usr/src/igbinary &&
cd /usr/src/igbinary &&
phpize && ./configure && make -j"$(nproc)" && make install &&
echo "extension=igbinary.so" > /usr/local/etc/php/conf.d/igbinary.ini
)
rm -rf /usr/src/igbinary
;;
8.6*)
# PHP 8.6 also changed the unserialize_callback_func INI global from
# char* to zend_string*, breaking igbinary's two direct reads of it.
# Cherry-pick upstream's own fix (igbinary/igbinary#419) rather than
# patching it ourselves: their fix also takes its own owned copy of
# the string, since the naive fix is a use-after-free if the
# unserialize callback itself reassigns unserialize_callback_func.
php -m | grep -q '^igbinary$' || (
git clone --depth=1 https://github.com/igbinary/igbinary.git /usr/src/igbinary &&
cd /usr/src/igbinary &&
git fetch --depth=5 origin pull/419/head &&
git cherry-pick d4a6ded9ca6b3d7eec069de1891d03c5bc14c233 --no-commit &&
export CFLAGS="${CFLAGS:-} -DXtOffsetOf=offsetof -Dzval_dtor=zval_ptr_dtor_nogc" &&
phpize && ./configure && make -j"$(nproc)" && make install &&
echo "extension=igbinary.so" > /usr/local/etc/php/conf.d/igbinary.ini
)
rm -rf /usr/src/igbinary
;;
8.2*|8.3*|8.4*)
# igbinary/igbinary has no stable-tagged release PIE can resolve; use the PIE-compatible mirror instead
# (pie-extensions/igbinary requires PHP >= 8.2, so 8.1 falls through to pecl below).
pie install pie-extensions/igbinary
;;
*)
yes | pecl install igbinary
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
# Yknow if we really need it.
php -m | grep -q '^mailparse$' || (
git clone --depth=1 https://github.com/php/pecl-mail-mailparse.git /usr/src/mailparse &&
cd /usr/src/mailparse &&
phpize && ./configure && make -j"$(nproc)" && make install &&
echo "extension=mailparse.so" > /usr/local/etc/php/conf.d/mailparse.ini
)
rm -rf /usr/src/mailparse
;;
8.1*|8.2*|8.3*|8.4*)
pie install pecl/mailparse
;;
*)
yes | pecl install mailparse
;;
esac
case $PHP_VERSION in
8.6*)
# Confirmed still needed against 8.6.0beta1: apcu's latest tagged
# release still calls the removed php_verror() with the old
# 5-argument signature. Fixed upstream on the default branch
# (unreleased), so build from there instead.
php -m | grep -q '^apcu$' || (
git clone --depth=1 https://github.com/krakjoe/apcu.git /usr/src/apcu &&
cd /usr/src/apcu &&
phpize && ./configure --enable-apcu && make -j"$(nproc)" && make install &&
echo "extension=apcu.so" > /usr/local/etc/php/conf.d/apcu.ini
)
rm -rf /usr/src/apcu
;;
8.1*|8.2*|8.3*|8.4*|8.5*)
pie install apcu/apcu
;;
*)
yes | pecl install apcu
;;
esac
case $PHP_VERSION in
8.1*|8.2*|8.3*|8.4*|8.5*|8.6*)
pie install rdkafka/rdkafka
pie install pecl/yaml
pie install pecl/uuid
;;
*)
yes | pecl install rdkafka yaml uuid
;;
esac
case $PHP_VERSION in
8.6*)
# msgpack-php also reads unserialize_callback_func as a char* (now
# zend_string* on PHP 8.6). Unlike igbinary, it only reads the
# global once, before invoking the callback, so a plain ZSTR_VAL /
# ZVAL_STR_COPY swap is safe here -- no owned-copy dance needed.
php -m | grep -q '^msgpack$' || (
git clone --depth=1 https://github.com/msgpack/msgpack-php.git /usr/src/msgpack-php &&
cd /usr/src/msgpack-php &&
sed -i "s/(PG(unserialize_callback_func)\[0\] == '\\\\0')) {/(ZSTR_LEN(PG(unserialize_callback_func)) == 0)) {/" msgpack_unpack.c &&
sed -i 's/ZVAL_STRING(&user_func, PG(unserialize_callback_func));/ZVAL_STR_COPY(\&user_func, PG(unserialize_callback_func));/' msgpack_unpack.c &&
phpize && ./configure --with-msgpack && make -j"$(nproc)" && make install &&
echo "extension=msgpack.so" > /usr/local/etc/php/conf.d/msgpack.ini
)
rm -rf /usr/src/msgpack-php
;;
8.1*|8.2*|8.3*|8.4*|8.5*)
pie install msgpack/msgpack-php
;;
*)
yes | pecl install msgpack
;;
esac
case $PHP_VERSION in
7.4|8.0)
yes | pecl install decimal-1.5.3
;;
8.1*|8.2*|8.3*|8.4*|8.5*|8.6*)
pie install php-decimal/ext-decimal
;;
*)
yes | pecl install decimal
;;
esac
case $PHP_VERSION in
8.1*|8.2*|8.3*|8.4*|8.5*|8.6*)
pie install php-amqp/php-amqp
;;
*)
echo "" | pecl install amqp
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
echo "Skipping oauth extension for $PHP_VERSION"
;;
*)
yes | pecl install oauth
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
echo "Skipping memcached for PHP $PHP_VERSION"
;;
8.1*|8.2*|8.3*|8.4*)
pie install php-memcached/php-memcached
;;
*)
echo "" | pecl install memcached
docker-php-ext-enable memcached
;;
esac
case $PHP_VERSION in
7.4)
yes | pecl install sqlsrv-5.10.1 pdo_sqlsrv-5.10.1
;;
8.0)
yes | pecl install sqlsrv-5.11.1 pdo_sqlsrv-5.11.1
;;
8.1|8.2)
yes | pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0
;;
8.5*|8.6*)
echo "Skipping sqlsrv on $PHP_VERSION"
;;
*)
yes | pecl install sqlsrv pdo_sqlsrv
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
php -m | grep -q '^redis$' || (
git clone --depth=1 https://github.com/phpredis/phpredis.git /usr/src/phpredis &&
cd /usr/src/phpredis &&
phpize && ./configure && make -j"$(nproc)" && make install &&
echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini
)
rm -rf /usr/src/phpredis
;;
8.1*|8.2*|8.3*|8.4*)
pie install phpredis/phpredis
;;
8.*)
mkdir -p /usr/src/php/ext/redis && curl -fsSL https://pecl.php.net/get/redis | tar xvz -C "/usr/src/php/ext/redis" --strip 1 && docker-php-ext-install redis
;;
*)
yes | pecl install redis-3.1.1
docker-php-ext-enable redis
;;
esac
php -m | grep -q '^intl$' || docker-php-ext-configure intl
php -m | grep -q '^gettext$' || docker-php-ext-configure gettext
php -m | grep -q '^intl$' || docker-php-ext-install intl
php -m | grep -q '^gettext$' || docker-php-ext-install gettext
php -m | grep -q '^sockets$' || docker-php-ext-install sockets
case $PHP_VERSION in
8.1*)
echo "yaml, decimal, uuid, msgpack, and amqp were already enabled by pie, and mailparse by pie, for PHP $PHP_VERSION"
docker-php-ext-enable ds
;;
8.2*|8.3*|8.4*|8.5*|8.6*)
echo "ds, yaml, decimal, uuid, msgpack, and amqp were already enabled by pie, and mailparse by pie or its own install step, for PHP $PHP_VERSION"
;;
*)
docker-php-ext-enable ds yaml decimal uuid mailparse msgpack amqp
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
echo "Skipping sqlsrv pdo_sqlsrv oauth for PHP $PHP_VERSION"
;;
*)
docker-php-ext-enable sqlsrv pdo_sqlsrv oauth
;;
esac
# ftp is compiled into PHP in < 8.2.
case $PHP_VERSION in
8.4*|8.3|8.2)
docker-php-ext-install ftp
;;
*)
echo "ftp extension already present on $PHP_VERSION"
;;
esac
# gd has slightly different build arguments on newer PHP.
case $PHP_VERSION in
7.4|8.*)
apk add --no-cache --virtual .build-deps-gd oniguruma-dev
docker-php-ext-configure gd --with-jpeg=/usr
;;
*)
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr
;;
esac
case $PHP_VERSION in
8.0)
pecl install xmlrpc-1.0.0RC2
docker-php-ext-enable xmlrpc
;;
8.*|8.4*)
echo "skipping xmlrpc on PHP version $PHP_VERSION"
;;
*)
docker-php-ext-install xmlrpc
docker-php-ext-enable xmlrpc
;;
esac
case $PHP_VERSION in
8.6*)
php -m | grep -q '^imagick$' || (
git clone --depth=1 https://github.com/Imagick/imagick.git /usr/src/imagick &&
cd /usr/src/imagick &&
export CFLAGS="${CFLAGS:-} -DXtOffsetOf=offsetof" &&
phpize && ./configure && make -j"$(nproc)" && make install &&
echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini
)
rm -rf /usr/src/imagick
;;
8.1*|8.2*|8.3*|8.4*|8.5*)
pie install imagick/imagick
;;
*)
yes | pecl install imagick
;;
esac
case $PHP_VERSION in
8.1*|8.2*|8.3*|8.4*|8.5*|8.6*)
php -m | grep -q '^imagick$' || docker-php-ext-enable imagick
;;
*)
docker-php-ext-enable imagick
;;
esac
case $PHP_VERSION in
8.4*|8.5*)
apk add --no-cache --virtual .build-deps-imap krb5-dev
# If we really need it.
php -m | grep -q '^imap$' || yes | pecl install imap
docker-php-ext-enable imap
;;
8.6*)
echo "Skipping imap for PHP $PHP_VERSION (ext/imap no longer bundled, and pecl is unavailable)"
;;
*)
docker-php-ext-install imap
;;
esac
case $PHP_VERSION in
8.5*|8.6*)
echo "Skipping opcache for PHP $PHP_VERSION"
;;
*)
docker-php-ext-install opcache
;;
esac
docker-php-ext-install gmp ldap xsl mysqli calendar gd pdo_mysql pdo_pgsql zip bcmath soap exif bz2 pcntl
case $PHP_VERSION in
8.1*|8.2*|8.3*|8.4*|8.5*|8.6*)
echo "rdkafka was already enabled by pie, and apcu by pie or its own install step, for PHP $PHP_VERSION"
;;
*)
docker-php-ext-enable rdkafka apcu
;;
esac
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions 2>/dev/null \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"
if [ -n "$runDeps" ]; then
apk add --no-cache --virtual .phpexts-rundeps $runDeps
fi
extraBuildDeps=""
for extra in .build-deps-gd .build-deps-imap; do
if apk info -e "$extra" >/dev/null 2>&1; then
extraBuildDeps="$extraBuildDeps $extra"
fi
done
apk del --no-network .build-deps $extraBuildDeps
docker-php-source delete
mkdir ~/.ssh/
ssh-keyscan -t rsa git.drupal.org >> ~/.ssh/known_hosts
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
git clone https://github.com/FriendsOfPHP/security-advisories /root/.symfony/cache/security-advisories
git clone https://github.com/violinist-dev/drupal-contrib-sa /root/drupal-contrib-sa
machine=`uname -m 2>/dev/null || /usr/bin/uname -m`
case ${machine} in
arm|armv7*)
machine="arm"
;;
aarch64*|armv8*)
machine="arm64"
;;
i386)
machine="386"
;;
x86_64)
machine="amd64"
;;
*)
output " [ ] You architecture (${machine}) is not currently supported" "error"
exit 1
;;
esac
wget https://github.com/symfony/cli/releases/download/v4.16.3/symfony_linux_${machine}.gz -O /tmp/symfony.gz
gzip -d /tmp/symfony.gz
chmod 755 /tmp/symfony
mv /tmp/symfony /usr/local/bin/symfony
wget https://getcomposer.org/download/latest-2.2.x/composer.phar -O /tmp/composer22
chmod 755 /tmp/composer22
mv /tmp/composer22 /usr/local/bin/composer22