aboutsummaryrefslogtreecommitdiffstats
path: root/community/php7/APKBUILD
blob: fa7835b9be6c0feb4a7b5cfb7b8015eca37a8969 (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
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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Valery Kartel <valery.kartel@gmail.com>

# Bundled libraries
#
# Name      | License             | Location               | State
# ----------+---------------------+------------------------+---------
# bcmath    | LGPL-2.1-or-later   | ext/bcmath/libbcmath   | used
# date      | MIT                 | ext/date/lib           | used
# fileinfo  | BSD-2-Clause        | ext/fileinfo/libmagic  | used
# gd        | BSD                 | ext/gd/libgd           | used
# hash      | CC0-1.0             | ext/hash/sha3          | used
# libmbfl   | LGPL-2.1-only       | ext/mbstring/libmbfl   | used
# oniguruma | BSD-2-Clause        | ext/mbstring/oniguruma | used
# pcre      | BSD-3-Clause        | ext/pcre/pcrelib       | not used
# sqlite3   | Public              | ext/sqlite3/libsqlite  | not used
# libXMLRPC | BSD-3-Clause        | ext/xmlrpc/libxmlrpc   | used
# libzip    | BSD-3-Clause        | ext/zip/lib            | not used

# Static extensions
#
# Name      | Reason
# ----------+--------------------------------------------
# zlib      | https://bugs.alpinelinux.org/issues/8299

pkgname=php7
_pkgreal=php
pkgver=7.3.17
pkgrel=2
_apiver=20180731
_suffix=${pkgname#php}
# Is this package the default (latest) PHP version?
_default_php="yes"
pkgdesc="The PHP$_suffix language runtime engine"
url="https://www.php.net/"
arch="all"
license="PHP-3.01 BSD LGPL-2.0-or-later MIT Zend-2.0"
depends="$pkgname-common"
depends_dev="$pkgname=$pkgver-r$pkgrel autoconf pcre2-dev"
# Most dependencies between extensions is auto-discovered (see _extension()).
_depends_mysqlnd="$pkgname-openssl"
_depends_pdo_mysql="$pkgname-pdo $pkgname-mysqlnd"
_depends_phar="$pkgname"
# openssl is actually transitive dependency here, but we need to because of
# load index based on number of dependencies.
_depends_mysqli="$pkgname-mysqlnd $pkgname-openssl"
makedepends="
	$depends_dev
	apache2-dev
	argon2-dev
	aspell-dev
	bison
	bzip2-dev
	curl-dev
	db-dev
	enchant2-dev
	freetds-dev
	freetype-dev
	gdbm-dev
	gettext-dev
	gmp-dev
	icu-dev
	imap-dev
	krb5-dev
	libedit-dev
	libical-dev
	libjpeg-turbo-dev
	libpng-dev
	lmdb-dev
	openssl-dev
	libsodium-dev
	libwebp-dev
	libxml2-dev
	libxpm-dev
	libxslt-dev
	libzip-dev
	net-snmp-dev
	openldap-dev
	postgresql-dev
	re2c
	recode-dev
	sqlite-dev
	tidyhtml-dev
	unixodbc-dev
	zlib-dev
	"
provides="$pkgname-cli php-cli php"  # for backward compatibility
provider_priority=100
subpackages="$pkgname-static $pkgname-dev $pkgname-dbg $pkgname-doc
	$pkgname-phpdbg $pkgname-apache2
	$pkgname-embed $pkgname-litespeed $pkgname-cgi $pkgname-fpm
	$pkgname-pear::noarch
	"
source="https://php.net/distributions/$_pkgreal-$pkgver.tar.xz
	$pkgname-fpm.initd
	$pkgname-fpm.logrotate
	$pkgname-module.conf
	disabled-tests.list
	install-pear.patch
	includedir.patch
	sharedir.patch
	php7-fpm-version-suffix.patch
	allow-build-recode-and-imap-together.patch
	fix-tests-devserver.patch
	enchant-2.patch
	"
builddir="$srcdir/$_pkgreal-$pkgver"

_libdir="/usr/lib/$pkgname"
_extension_dir="$_libdir/modules"
_extension_confd="/etc/$pkgname/conf.d"

_extensions="
	bcmath
	bz2
	calendar
	ctype
	curl
	dba
	dom
	enchant
	exif
	fileinfo
	ftp
	gd
	gettext
	gmp
	iconv
	imap
	intl
	json
	ldap
	mbstring
	mysqli
	mysqlnd
	odbc
	opcache
	openssl
	pcntl
	pdo
	pdo_dblib
	pdo_mysql
	pdo_odbc
	pdo_pgsql
	pdo_sqlite
	pgsql
	phar
	posix
	pspell
	recode
	session
	shmop
	simplexml
	snmp
	soap
	sodium
	sockets
	sqlite3
	sysvmsg
	sysvsem
	sysvshm
	tidy
	tokenizer
	wddx
	xml
	xmlreader
	xmlrpc
	xmlwriter
	xsl
	zip
	"
for _ext in $_extensions; do
	case "$_ext" in
		phar) subpackages="$subpackages $pkgname-$_ext:$_ext";;
		*) subpackages="$subpackages $pkgname-$_ext:_extension";;
	esac
done
subpackages="$subpackages $pkgname-common::noarch"

# FIXME: tests fails on s390x and x86_64
case "$CARCH" in
	x86_64) options="$options !check";;
	s390x) options="$options !check";;
esac

# secfixes:
#   7.3.17-r0:
#     - CVE-2020-7067
#   7.3.16-r0:
#     - CVE-2020-7064
#     - CVE-2020-7065
#     - CVE-2020-7066
#   7.3.15-r0:
#     - CVE-2020-7061
#     - CVE-2020-7062
#     - CVE-2020-7063
#   7.3.14-r0:
#     - CVE-2020-7059
#     - CVE-2020-7060
#   7.3.13-r0:
#     - CVE-2019-11045
#     - CVE-2019-11047
#     - CVE-2019-11050
#   7.3.11-r0:
#     - CVE-2019-11043
#   7.3.9-r0:
#     - CVE-2019-13224
#   7.3.8-r0:
#     - CVE-2019-11041
#     - CVE-2019-11042
#   7.2.19-r0:
#     - CVE-2019-11039
#     - CVE-2019-11040
#   7.2.18-r0:
#     - CVE-2019-11036
#   7.2.17-r0:
#     - CVE-2019-11034
#     - CVE-2019-11035
#   7.2.16-r0:
#     - CVE-2019-9641
#     - CVE-2019-9640
#     - CVE-2019-9639
#     - CVE-2019-9638
#     - CVE-2019-9637
#   7.2.14-r0:
#     - CVE-2019-9024
#     - CVE-2019-9023
#     - CVE-2019-9022
#     - CVE-2019-9021
#     - CVE-2019-9020
#   7.2.13-r0:
#     - CVE-2018-20783
#   7.2.8-r0:
#     - CVE-2015-9253
#     - CVE-2018-12882
#     - CVE-2018-12883
#     - CVE-2018-14851
#   7.2.5-r0:
#     - CVE-2018-5712
#     - CVE-2018-10546
#     - CVE-2018-10547
#     - CVE-2018-10548
#     - CVE-2018-10549

prepare() {
	default_prepare
	update_config_sub

	local vapi=$(sed -n '/#define PHP_API_VERSION/{s/.* //;p}' main/php.h)
	if [ "$vapi" != "$_apiver" ]; then
		error "Upstream API version is now $vapi. Expecting $_apiver"
		error "After updating _apiver, all 3rd-party extensions must be rebuilt."
		return 1
	fi

	# https://bugs.php.net/63362 - Not needed but installed headers.
	# Drop some Windows specific headers to avoid installation,
	# before build to ensure they are really not needed.
	rm -f TSRM/tsrm_win32.h \
		TSRM/tsrm_config.w32.h \
		Zend/zend_config.w32.h \
		ext/mysqlnd/config-win.h \
		ext/standard/winver.h

	# Fix some bogus permissions.
	find . -name \*.[ch] -exec chmod 644 {} \;

	# XXX: Delete failing tests.
	sed -n '/^[^#]/p' "$srcdir"/disabled-tests.list | while read item; do
		rm -r $item  # do it in this way to apply globbing...
	done

	autoconf
}

# Notes:
# * gd-jis-conv breaks any non-latin font rendering (vakartel).
# * libxml cannot be build as shared.
# * Doesn't work with system-provided onigurama, some tests fail (invalid code
#   point); probably because bundled onigurama is version 5.x, but we have 6.x.
_build() {
	local without_pcre_jit
	[ "$CARCH" = "s390x" ] && without_pcre_jit="--without-pcre-jit"

	EXTENSION_DIR=$_extension_dir ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--program-suffix=$_suffix \
		--libdir=$_libdir \
		--datadir=/usr/share/$pkgname \
		--sysconfdir=/etc/$pkgname \
		--localstatedir=/var \
		--with-layout=GNU \
		--with-pic \
		--with-pear=/usr/share/$pkgname \
		--with-config-file-path=/etc/$pkgname \
		--with-config-file-scan-dir=$_extension_confd \
		--disable-short-tags \
		\
		--enable-bcmath=shared \
		--with-bz2=shared \
		--enable-calendar=shared \
		--enable-ctype=shared \
		--with-curl=shared \
		--enable-dba=shared \
			--with-db4 \
			--with-dbmaker=shared \
			--with-gdbm \
			--with-lmdb \
		--enable-dom=shared \
		--with-enchant=shared \
		--enable-exif=shared \
		--enable-fileinfo=shared \
		--enable-ftp=shared \
		--with-gd=shared \
			--with-freetype-dir=/usr \
			--disable-gd-jis-conv \
			--with-jpeg-dir=/usr \
			--with-png-dir=/usr \
			--with-webp-dir=/usr \
			--with-xpm-dir=/usr \
		--with-gettext=shared \
		--with-gmp=shared \
		--with-iconv=shared \
		--with-imap=shared \
			--with-imap-ssl \
		--with-icu-dir=/usr \
		--enable-intl=shared \
		--enable-json=shared \
		--with-kerberos \
		--with-ldap=shared \
			--with-ldap-sasl \
		--with-libedit \
		--enable-libxml \
			--with-libxml-dir=/usr \
		--enable-mbstring=shared \
		--with-mysqli=shared,mysqlnd \
			--with-mysql-sock=/run/mysqld/mysqld.sock \
		--enable-mysqlnd=shared \
		--enable-opcache=shared \
		--with-openssl=shared  \
			--with-system-ciphers \
		--with-password-argon2 \
		--enable-pcntl=shared \
		--with-pcre-regex=/usr \
			$without_pcre_jit \
		--enable-pdo=shared \
			--with-pdo-dblib=shared \
			--with-pdo-mysql=shared,mysqlnd \
			--with-pdo-odbc=shared,unixODBC,/usr \
			--with-pdo-pgsql=shared \
			--with-pdo-sqlite=shared,/usr \
		--with-pgsql=shared \
		--enable-phar=shared \
		--enable-posix=shared \
		--with-pspell=shared \
		--without-readline \
		--with-recode=shared \
		--enable-session=shared \
		--enable-shmop=shared \
		--enable-simplexml=shared \
		--with-snmp=shared \
		--enable-soap=shared \
		--with-sodium=shared \
		--enable-sockets=shared \
		--with-sqlite3=shared,/usr \
		--enable-sysvmsg=shared \
		--enable-sysvsem=shared \
		--enable-sysvshm=shared \
		--with-tidy=shared \
		--enable-tokenizer=shared \
		--with-unixODBC=shared,/usr \
		--enable-wddx=shared \
		--enable-xml=shared \
		--enable-xmlreader=shared \
		--with-xmlrpc=shared \
		--enable-xmlwriter=shared \
		--with-xsl=shared \
		--enable-zip=shared \
			--with-libzip=/usr \
		--with-zlib \
			--with-zlib-dir=/usr \
		$@
	make
}

build() {
	# phpdbg
	_build --enable-phpdbg \
		--enable-phpdbg-webhelper \
		--disable-cgi \
		--disable-cli

	# apache2 module
	_build --disable-phpdbg \
		--disable-cgi \
		--disable-cli \
		--with-apxs2
	mv libs/libphp$_suffix.so sapi/apache2handler/mod_php$_suffix.so

	# cgi, cli, fpm, embed, litespeed
	_build --disable-phpdbg \
		--enable-fpm \
		--enable-embed \
		--with-litespeed
}

check() {
	# PHP is so stupid that it's not able to resolve dependencies
	# between extensions and load them in correct order, so we must
	# help it...
	# opcache is Zend extension, it's handled specially in Makefile
	local php_modules=$(_extensions_by_load_order \
		| grep -vx opcache \
		| xargs -n 1 printf "'$builddir/modules/%s.la' ")
	sed -i "/^PHP_TEST_SHARED_EXTENSIONS/,/extension=/ \
		s|in \$(PHP_MODULES)\"*|in $php_modules|" Makefile

	# XXX: Few tests fail on the named platforms.
	# Ignore it for now and continue build even on test failures.
	local allow_fail='no'
	case "$CARCH" in
		x86 | arm* | aarch64 | ppc64le | mips*) allow_fail='yes'
	esac

	NO_INTERACTION=1 REPORT_EXIT_STATUS=1 \
		SKIP_SLOW_TESTS=1 SKIP_ONLINE_TESTS=1 TEST_TIMEOUT=10 \
		TZ= LANG= LC_ALL= \
		make test || [ "$allow_fail" = yes ]

	echo 'NOTE: We have skipped quite a lot tests, see disabled-tests.list.'
}

package() {
	make -j1 INSTALL_ROOT="$pkgdir" install

	install -Dm644 php.ini-production "$pkgdir"/etc/$pkgname/php.ini

	local file; for file in pear peardev pecl; do
		sed -i -e "s|/usr/bin/php|/usr/bin/php$_suffix|g" \
			-e "s|PHP=php|PHP=php$_suffix|" \
			"$pkgdir"/usr/bin/$file
	done

	find "$pkgdir" -name '.*' | xargs rm -rf
	rmdir "$pkgdir"/var/run

	if [ "$_default_php" = yes ]; then
		ln -s php$_suffix "$pkgdir"/usr/bin/php
	fi
}

dev() {
	default_dev
	replaces="php-dev"
	depends="$depends $pkgname-static"

	cd "$pkgdir"

	_mv usr/bin/php-config$_suffix \
		usr/bin/phpize$_suffix \
		"$subpkgdir"/usr/bin/

	_mv ./$_libdir/build "$subpkgdir"/$_libdir/

	if [ "$_default_php" = yes ]; then
		ln -s phpize$_suffix "$subpkgdir"/usr/bin/phpize
		ln -s php-config$_suffix "$subpkgdir"/usr/bin/php-config
	fi
}

doc() {
	default_doc

	cd "$builddir"

	mkdir -p "$subpkgdir"/usr/share/doc/$pkgname
	cp CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS \
		README* UPGRADING* \
		"$subpkgdir"/usr/share/doc/$pkgname/
}

apache2() {
	pkgdesc="PHP$_suffix Module for Apache2"
	depends="$depends apache2"
	provides="php-apache2"

	install -D -m 755 "$builddir"/sapi/apache2handler/mod_php$_suffix.so \
		"$subpkgdir"/usr/lib/apache2/mod_php$_suffix.so

	install -D -m 644 "$srcdir"/php$_suffix-module.conf \
		"$subpkgdir"/etc/apache2/conf.d/php$_suffix-module.conf
}

phpdbg() {
	pkgdesc="Interactive PHP$_suffix debugger"
	provides="php-phpdbg"

	install -Dm755 "$builddir"/sapi/phpdbg/phpdbg \
		"$subpkgdir"/usr/bin/phpdbg$_suffix

	if [ "$_default_php" = yes ]; then
		ln -s phpdbg$_suffix "$subpkgdir"/usr/bin/phpdbg
	fi
}

embed() {
	pkgdesc="PHP$_suffix Embedded Library"
	provides="php-embed"

	_mv "$pkgdir"/usr/lib/libphp*.so "$subpkgdir"/usr/lib/
}

litespeed() {
	pkgdesc="PHP$_suffix LiteSpeed SAPI"
	provides="php-lightspeed"

	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/lsphp$_suffix "$subpkgdir"/usr/bin

	if [ "$_default_php" = yes ]; then
		ln -s lsphp$_suffix "$subpkgdir"/usr/bin/lsphp
	fi
}

cgi() {
	pkgdesc="PHP$_suffix Common Gateway Interface"
	provides="php-cgi"

	_mv "$pkgdir"/usr/bin/php-cgi$_suffix "$subpkgdir"/usr/bin/

	if [ "$_default_php" = yes ]; then
		ln -s php-cgi$_suffix "$subpkgdir"/usr/bin/php-cgi
	fi
}

fpm() {
	pkgdesc="PHP$_suffix FastCGI Process Manager"
	provides="php-fpm"

	cd "$pkgdir"

	_mv var "$subpkgdir"/
	_mv usr/share/$pkgname/fpm "$subpkgdir"/var/lib/$pkgname/
	_mv usr/sbin "$subpkgdir"/usr/
	_mv etc/$pkgname/php-fpm* "$subpkgdir"/etc/$pkgname/

	local file; for file in php-fpm.conf php-fpm.d/www.conf; do
		mv "$subpkgdir"/etc/$pkgname/$file.default \
			"$subpkgdir"/etc/$pkgname/$file
	done

	install -D -m 755 "$srcdir"/$pkgname-fpm.initd \
		"$subpkgdir"/etc/init.d/php-fpm$_suffix

	install -D -m 644 "$srcdir"/$pkgname-fpm.logrotate \
		"$subpkgdir"/etc/logrotate.d/php-fpm$_suffix

	mkdir -p "$subpkgdir"/var/log/$pkgname
}

pear() {
	pkgdesc="PHP$_suffix Extension and Application Repository"
	depends="$pkgname $pkgname-xml"
	provides="php-pear"

	cd "$pkgdir"

	mkdir -p "$subpkgdir"/usr/bin
	local file; for file in pecl pear peardev; do
		mv usr/bin/$file "$subpkgdir"/usr/bin/$file$_suffix
		if [ "$_default_php" = yes ]; then
			ln -s $file$_suffix "$subpkgdir"/usr/bin/$file
		fi
	done

	_mv etc/$pkgname/pear.conf "$subpkgdir"/etc/$pkgname/
	_mv usr/share "$subpkgdir"/usr/
}

common() {
	pkgdesc="$pkgdesc (common config)"
	provides="php-common $pkgname-zlib php-zlib"  # for backward compatibility
	depends=""

	cd "$pkgdir"

	_mv usr/lib "$subpkgdir"/usr/
	_mv etc "$subpkgdir"/
	mkdir -p "$subpkgdir"/$_extension_confd
}

phar() {
	_extension

	cd "$pkgdir"

	mkdir -p "$subpkgdir"/usr/bin
	mv usr/bin/phar.phar "$subpkgdir"/usr/bin/phar.phar$_suffix

	rm usr/bin/phar
	ln -s phar.phar$_suffix "$subpkgdir"/usr/bin/phar$_suffix

	if [ "$_default_php" = yes ]; then
		ln -s phar.phar$_suffix "$subpkgdir"/usr/bin/phar.phar
		ln -s phar.phar$_suffix "$subpkgdir"/usr/bin/phar
	fi
}

_extension() {
	local extname="${subpkgname#$pkgname-}"
	local extdepends="$(eval "echo \$_depends_$extname")"
	local extdesc="$(head -n1 "$builddir"/ext/$extname/CREDITS 2>/dev/null ||:)"
	pkgdesc="PHP$_suffix extension: ${extdesc:-$extname}"
	provides="php-$extname"

	: ${extdepends:=$(_resolve_extension_deps "$extname")}
	depends="$depends $extdepends"

	local load_order=$(_extension_load_order "$extname")

	# extension prefix
	local prefix=
	[ "$extname" != "opcache" ] || prefix="zend_"

	_mv "$pkgdir"/$_extension_dir/$extname.so \
		"$subpkgdir"/$_extension_dir/

	mkdir -p "$subpkgdir"/$_extension_confd
	echo "${prefix}extension=$extname.so" \
		> "$subpkgdir"/$_extension_confd/$(printf %02d $load_order)_$extname.ini
}

# Resolves dependencies of the given extension name (without $pkgname- prefix)
# on other extensions in $_extensions and prints them with $pkgname- prefix.
_resolve_extension_deps() {
	local name="$1"

	# We use config.w32 just because it's more accurate than config.m4.
	local config="$builddir/ext/$name/config.w32"
	[ -f "$config" ] || return 0

	cat "$config" \
		| sed -En "s/.*ADD_EXTENSION_DEP\('$name', ([^)]+)\).*/\1/p" \
		| tr -d "'," | tr ' ' '\n' \
		| sort -u \
		| while read dep; do
			if echo "$_extensions" | grep -qw "$dep"; then
				echo "$pkgname-$dep"
			fi
		done
}

# Prints a load order (0-based integer) for the given extension name. Extension
# with lower load order should be loaded before exts with higher load order.
# It's based on number of dependencies of the extension (with exception for
# "imap"), which is flawed, but simple and good enough for now.
_extension_load_order() {
	local name="$1"
	local deps=$(eval "echo \$_depends_$name")

	case "$name" in
		# XXX: This must be loaded after recode, even though it does
		# not depend on it. So we must use this hack...
		imap) echo 1;;
		*) echo "${deps:=$(_resolve_extension_deps $name)}" | wc -w;;
	esac
}

# Prints $_extensions sorted by load order and name.
_extensions_by_load_order() {
	local deps list name

	for name in $_extensions; do
		list="$list $(_extension_load_order $name);$name"
	done
	printf '%s\n' $list | sort -t ';' -k 1 | sed -E 's/\d+;//'
}

_mv() {
	local dest; for dest; do true; done  # get last argument
	mkdir -p "$dest"
	mv $@
}

sha512sums="ac99a645a7442c322b8334cb4d091474bb0486b5efe11f8ffc16e4a2c0ecf8dbb5d958206372617350ec70b579dd4756f4d166c2863f3892db480e9bfbd14837  php-7.3.17.tar.xz
1c708de82d1086f272f484faf6cf6d087af7c31750cc2550b0b94ed723961b363f28a947b015b2dfc0765caea185a75f5d2c2f2b099c948b65c290924f606e4f  php7-fpm.initd
cacce7bf789467ff40647b7319e3760c6c587218720538516e8d400baa75651f72165c4e28056cd0c1dc89efecb4d00d0d7823bed80b29136262c825ce816691  php7-fpm.logrotate
274bd7b0b2b7002fa84c779640af37b59258bb37b05cb7dd5c89452977d71807f628d91b523b5039608376d1f760f3425d165242ca75ee5129b2730e71c4e198  php7-module.conf
6593accfe1ef0d9d28d257b2825823afdbfaa72bbf2e09e4ed689b644571a0d085cd4d6c92ffdff6ca9d0bb6d31cf84e5db5c4a4d88f192bba3f95a0c9b1dfd7  disabled-tests.list
f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505  install-pear.patch
ebf571c5e595221b9944d7e840807ebb68c1be38bf117186e19a3bd1070310ece5918bcaa5f941679f3371a2108ad57bf179c3f90e612a5a2b982db941172859  includedir.patch
2128eb8e7e44e4f45909f2aa83c071bf7677f5c96e29a0182ac59d5850c7b3437e4b1b67c1a20f14d65f4b370985f838ea061541690ebcfbc9cb21d64744bc7a  sharedir.patch
fc680157c9bfaa600a82da0b2b8b96c9515eda653479bc9a9424e96683ea7c983190af0e54dcaf34256646069924df55f3f2d9a97fb11e971463a60f6df0e90f  php7-fpm-version-suffix.patch
a07f6f54a298be6f10caa0ce68cebdf1c7cd1404ddb6a0f2c3a77fb7af3c4172bc4474ffc784f3dc92514e4da2639e558aca6dc1cffcc2e55af0743eaad7de47  allow-build-recode-and-imap-together.patch
695ce980ea659575ba26b8443051620e83dc806e04b3bbace791f14af5c581ae4329e2c6326b554c60dab1a13f6b7c3fde49f20032540e53f80ecfade88c5b94  fix-tests-devserver.patch
b9b63a5fab6844cf98b7220948c94ea967b8bc9b6d76236e3b74e69f06513dd9e7c6684cda90f203adbb243c5bdfa5a51bd8dbab1bd0e266f0443480db9e31ed  enchant-2.patch"