APKBUILD 12.6 KB
Newer Older
1
# Contributor: Andy Blyler <andy@blyler.cc>
2
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
3
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
4
# Maintainer: Matt Smith <mcs@darkregion.net>
5
pkgname=php5
6
pkgver=5.6.30
7
pkgrel=3
Carlo Landmeter's avatar
Carlo Landmeter committed
8 9
pkgdesc="The PHP language runtime engine"
url="http://www.php.net/"
10
arch="all"
Carlo Landmeter's avatar
Carlo Landmeter committed
11
license="PHP-3"
12
depends="$pkgname-cli"
13
depends_dev="$pkgname-cli pcre-dev"
14
install="$pkgname.post-upgrade"
15
provides="php"
16
makedepends="
17
	$depends_dev
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
	apache2-dev
	apr-dev
	apr-util-dev
	aspell-dev
	bzip2-dev
	curl-dev
	db-dev
	enchant-dev
	expat-dev
	freetds-dev
	freetype-dev
	gdbm-dev
	gettext-dev
	gmp-dev
	icu-dev
	imap-dev
	libevent-dev
	libgcrypt-dev
	libjpeg-turbo-dev
	libmcrypt-dev
	libpng-dev
	libtool
	libxml2-dev
	libxslt-dev
42
	mariadb-dev
43 44
	net-snmp-dev
	openldap-dev
45
	libressl-dev
46 47 48 49 50
	postgresql-dev
	readline-dev
	sqlite-dev
	unixodbc-dev
	zlib-dev
51
	autoconf
52
	bison
53
	"
54
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-common::noarch $pkgname-cgi
55
	$pkgname-cli $pkgname-fpm $pkgname-apache2 $pkgname-embed
Natanael Copa's avatar
Natanael Copa committed
56 57
	$pkgname-phpdbg

58
	$pkgname-pear::noarch
59 60 61
	$pkgname-bcmath
	$pkgname-bz2
	$pkgname-calendar
62
	$pkgname-ctype
63
	$pkgname-curl:_curl
64
	$pkgname-dba
65
	$pkgname-dom
66
	$pkgname-enchant
67 68 69 70 71 72 73
	$pkgname-exif
	$pkgname-ftp
	$pkgname-gd
	$pkgname-gettext
	$pkgname-gmp
	$pkgname-iconv
	$pkgname-imap
74
	$pkgname-intl
75 76 77 78 79 80 81
	$pkgname-json
	$pkgname-ldap
	$pkgname-mcrypt
	$pkgname-mysql
	$pkgname-mysqli
	$pkgname-odbc
	$pkgname-openssl
82
	$pkgname-pcntl
83 84 85 86 87 88
	$pkgname-pdo
	$pkgname-pdo_mysql
	$pkgname-pdo_odbc
	$pkgname-pdo_pgsql
	$pkgname-pdo_sqlite
	$pkgname-pgsql
89
	$pkgname-phar
90 91 92 93 94 95
	$pkgname-posix
	$pkgname-pspell
	$pkgname-shmop
	$pkgname-snmp
	$pkgname-soap
	$pkgname-sockets
96
	$pkgname-sqlite3
97 98 99
	$pkgname-sysvmsg
	$pkgname-sysvsem
	$pkgname-sysvshm
100
	$pkgname-xml
101
	$pkgname-xmlreader
102 103 104 105
	$pkgname-xmlrpc
	$pkgname-xsl
	$pkgname-zip
	$pkgname-zlib
106 107
	$pkgname-mssql
	$pkgname-pdo_dblib
108
	$pkgname-wddx
109
	$pkgname-opcache
110 111
	"

112
source="http://php.net/distributions/php-$pkgver.tar.bz2
113
	php-fpm.initd
114
	php5-module.conf
115
	php-install-pear-xml.patch
116
	gd-iconv.patch
117
	"
Carlo Landmeter's avatar
Carlo Landmeter committed
118

119
_apiver="20131106"
120 121 122 123 124 125
_extdir="/usr/lib/$pkgname/modules"
_srcdir="$srcdir"/php-$pkgver
_confdir=/etc/$pkgname

# seems like pear hardcode /usr/share/pear directory
_peardir=/usr/share/pear
126

127
prepare() {
128
	cd "$_srcdir"
129
	update_config_sub
130 131 132 133 134
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
135

136 137 138 139 140 141
	# safty check for api changes
	local vapi=$(sed -n '/#define PHP_API_VERSION/{s/.* //;p}' main/php.h)
	if [ "$vapi" != "$_apiver" ]; then
		error "Upstreram API version is now $vapi. Expecting $_vapi"
		return 1
	fi
142
	autoconf
143
}
144

145 146 147 148 149 150
_do_build() {
	local _flavor="$1"
	shift
	local _builddir="$srcdir"/build-$_flavor
	mkdir -p "$_builddir"
	cd "$_builddir"
151
	export EXTENSION_DIR=$_extdir
152
	export PEAR_INSTALLDIR="$_peardir"
153 154 155 156 157
	"$_srcdir"/configure $@ || return 1
	sed -ri "s/^(EXTRA_LDFLAGS[ ]*\=.*)/\1 -lpthread/" Makefile  # see #183
	make || return 1
}

158
build() {
159 160 161
	_phpconfig="\
		--build=$CBUILD \
		--host=$CHOST \
162
		--prefix=/usr \
163
		--sysconfdir=$_confdir \
Natanael Copa's avatar
Natanael Copa committed
164
		--localstatedir=/var \
165
		--with-layout=GNU \
166 167
		--with-config-file-path=$_confdir \
		--with-config-file-scan-dir=$_confdir/conf.d \
168 169 170 171 172 173
		--enable-inline-optimization \
		--disable-debug \
		--disable-rpath \
		--disable-static \
		--enable-shared \
		--mandir=/usr/share/man \
174
		--with-pic \
175
		--program-suffix=5 \
176 177
		"

178 179 180
	_phpextensions=" \
		--enable-bcmath=shared \
		  --with-bz2=shared \
181
		--enable-calendar=shared \
182 183 184
		  --with-cdb \
		--enable-ctype=shared \
		  --with-curl=shared \
185
		--enable-dba=shared \
186
		  --with-db4=shared \
187
		--enable-dom=shared \
188
		  --with-enchant=shared \
189
		--enable-exif=shared \
190
		  --with-freetype-dir=shared,/usr \
191
		--enable-ftp=shared \
192
		  --with-gd=shared \
193
		--enable-gd-native-ttf \
194 195 196 197 198 199 200
		  --with-gdbm=shared \
		  --with-gettext=shared \
		  --with-gmp=shared \
		  --with-iconv=shared \
		  --with-icu-dir=/usr \
		  --with-imap=shared \
		  --with-imap-ssl=shared \
201
		--enable-intl=shared \
202
		  --with-jpeg-dir=shared,/usr \
203
		--enable-json=shared \
204
		  --with-ldap=shared \
205
		--enable-libxml=shared \
206
		--enable-mbregex \
207 208 209 210 211 212 213
		--enable-mbstring=all \
		  --with-mcrypt=shared \
		  --with-mysql=shared,mysqlnd \
		  --with-mysql-sock=/var/run/mysqld/mysqld.sock \
		  --with-mysqli=shared,mysqlnd \
		  --with-openssl=shared \
		  --with-pcre-regex=/usr \
214
		--enable-pcntl=shared \
215
		--enable-pdo=shared \
216 217 218 219 220
		  --with-pdo-mysql=shared,mysqlnd \
		  --with-pdo-odbc=shared,unixODBC,/usr \
		  --with-pdo-pgsql=shared \
		  --with-pdo-sqlite=shared,/usr \
		  --with-pgsql=shared \
221
		--enable-phar=shared \
222
		  --with-png-dir=shared,/usr \
223
		--enable-posix=shared \
224 225
		  --with-pspell=shared \
		  --with-regex=php \
226
		--enable-session \
227
		--enable-shmop=shared \
228
		  --with-snmp=shared \
229
		--enable-soap=shared \
230
		--enable-sockets=shared \
231
		  --with-sqlite3=shared,/usr \
232 233 234
		--enable-sysvmsg=shared \
		--enable-sysvsem=shared \
		--enable-sysvshm=shared \
235
		  --with-unixODBC=shared,/usr \
236
		--enable-xml=shared \
237 238 239
		--enable-xmlreader=shared \
		  --with-xmlrpc=shared \
		  --with-xsl=shared \
240
		--enable-wddx=shared \
241
		--enable-zip=shared \
242
		  --with-zlib=shared \
243 244 245 246
		--without-db1 \
		--without-db2 \
		--without-db3 \
		--without-qdbm \
247 248
		--with-mssql=shared \
		--with-pdo-dblib=shared \
249
		--enable-opcache \
250
		"
251

252
	# cgi, fcgi, cli, pear and extensions
253 254
	_do_build cgi \
		${_phpconfig} \
255
		--disable-cli \
256
		--enable-cgi \
257
		--enable-cli \
258
		--with-pear \
259
		--with-readline \
Natanael Copa's avatar
Natanael Copa committed
260
		--enable-phpdbg \
261 262
		${_phpextensions} \
		|| return 1
263

264
	# fpm
265 266 267
	cp -a "$srcdir"/build-cgi "$srcdir"/build-fpm
	_do_build fpm \
		${_phpconfig} \
268
		--disable-cli \
269
		--enable-fpm \
270 271
		${_phpextensions} \
		|| return 1
272

273
	# apache2
274 275 276
	cp -a "$srcdir"/build-cgi "$srcdir"/build-apache2
	_do_build apache2 \
		${_phpconfig} \
277
		--disable-cli \
278
		--with-apxs2 \
279 280
		${_phpextensions} \
		|| return 1
281 282

	# embed
283 284 285
	cp -a "$srcdir"/build-cgi "$srcdir"/build-embed
	_do_build embed \
		${_phpconfig} \
286 287
		--disable-cli \
		--enable-embed=shared \
288 289
		${_phpextensions} \
		|| return 1
290 291 292
}

package() {
293
	cd "$srcdir"/build-cgi
294 295 296 297 298
	# install php-cgi, cli, pear and modules
	make -j1 install install-pear INSTALL_ROOT="$pkgdir" || return 1

	# cleanup after pear
	find "$pkgdir" -name '.*' | xargs rm -rf || return 1
299

300 301 302 303 304
	# install embed
	install -D -m755 "$srcdir"/build-embed/libs/libphp5.so \
		"$pkgdir"/usr/lib/libphp5.so || return 1
	install -D -m644 "$_srcdir"/sapi/embed/php_embed.h \
		"$pkgdir"/usr/include/php/sapi/embed/php_embed.h || return 1
305 306
}

307
dev() {
308 309
	default_dev || return 1

310
	mkdir -p "$subpkgdir"/usr/lib/php "$subpkgdir"/usr/bin
311 312
	mv "$pkgdir"/usr/lib/php/build \
		"$subpkgdir"/usr/lib/php/ || return 1
313
	mv "$pkgdir"/usr/bin/php-config5 "$subpkgdir"/usr/bin/
314 315
}

316 317
doc() {
	# man pages
318
	default_doc || return 1
319
	cd "$srcdir"/php-$pkgver
320 321 322

	# doc files
	_docs="CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS \
323
	UPGRADING UPGRADING.INTERNALS"
324
	for _doc in $_docs README.*; do
325
		install -Dm644 "$srcdir"/php-$pkgver/$_doc \
326 327 328 329
			"$subpkgdir"/usr/share/doc/$pkgname/$_doc || return 1
	done
}

330 331
common() {
	pkgdesc="PHP Common Files"
332
	depends=""
333

334
	cd "$srcdir"/php-$pkgver
335

336
	install -D -m644 php.ini-production "$subpkgdir"$_confdir/php.ini
337 338 339 340
	sed -ri -e "s:^; extension_dir = \"./\":extension_dir = \"$_extdir\":" \
		-e 's/;(date.timezone =)/\1 UTC/' \
		-e "s~^([;]*cgi\.rfc2616_headers.*)$~\1\n\n\; If this is enabled, the PHP CGI binary can safely be placed outside of the\n; web tree and people will not be able to circumvent .htaccess security.\ncgi\.discard_path = 1~" \
		"$subpkgdir"$_confdir/php.ini
341 342
}

343 344
cgi() {
	pkgdesc="PHP Common Gateway Interface (CGI)"
345
	depends="$pkgname-common"
346
	mkdir -p "$subpkgdir"/usr/bin
347
	mv "$pkgdir"/usr/bin/php-cgi* "$subpkgdir"/usr/bin/
348 349
}

350 351
cli() {
	pkgdesc="PHP Command Line Interface (CLI)"
352
	depends="$pkgname-common"
353
	mkdir -p "$subpkgdir"/usr/bin
354
	mv "$pkgdir"/usr/bin/php5 "$subpkgdir"/usr/bin/ || return 1
355
	# provide phpize here instead of -dev due to pecl command
356
	mv "$pkgdir"/usr/bin/phpize* "$subpkgdir"/usr/bin/ || return 1
357 358
}

359
fpm() {
360
	pkgdesc="PHP FastCGI Process Manager (FPM)"
361 362
	depends="$pkgname-common"
	mkdir -p "$subpkgdir"$_confdir/fpm.d
363
	install -D -m755 "$srcdir"/build-fpm/sapi/fpm/php-fpm \
364
		"$subpkgdir"/usr/bin/php-fpm5 || return 1
365
	install -D -m644 "$srcdir"/build-fpm/sapi/fpm/php-fpm.conf \
366
		"$subpkgdir"$_confdir/php-fpm.conf || return 1
367 368 369
	install -D -m755 "$srcdir"/php-fpm.initd "$subpkgdir"/etc/init.d/php-fpm
	# enable some default options
	sed -ri	-e "s~^;(error_log)(.*)~\1 = /var/log/php-fpm.log~" \
370
		-e "s~^;(include)(.*)~\1 = $_confdir/fpm.d/*.conf~" \
371 372 373
		-e "s/^;(pm.start_servers)/\1/" \
		-e "s/^;(pm.min_spare_servers)/\1/" \
		-e "s/^;(pm.max_spare_servers)/\1/" \
374
		"$subpkgdir"$_confdir/php-fpm.conf || return 1
375
}
376

377 378
apache2() {
	pkgdesc="PHP Module for Apache2"
379
	depends="$pkgname-common apache2"
380 381 382 383
	install -D -m755 "$srcdir"/build-apache2/libs/libphp5.so \
		"$subpkgdir"/usr/lib/apache2/libphp5.so || return 1
	install -D -m644 "$srcdir"/php5-module.conf \
		"$subpkgdir"/etc/apache2/conf.d/php5-module.conf || return 1
384 385
}

386 387
embed() {
	pkgdesc="PHP Embed Library"
388
	depends="$pkgname-common"
389 390
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libphp5.so "$subpkgdir"/usr/lib/
391 392
}

393 394
pear() {
	pkgdesc="PHP Extension and Application Repository (PEAR)"
395 396
	depends="$pkgname-cli $pkgname-xml"
	mkdir -p "$subpkgdir"/usr/share "$subpkgdir"$_confdir \
397 398 399 400 401
		"$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/pecl \
		"$pkgdir"/usr/bin/pear \
		"$pkgdir"/usr/bin/peardev \
		"$subpkgdir"/usr/bin/ || return 1
402 403 404
	mv "$pkgdir"$_confdir/pear.conf \
		"$subpkgdir"$_confdir/ || return 1
	mv "$pkgdir"${_peardir} \
405 406 407
		"$subpkgdir"/usr/share/ || return 1
}

Natanael Copa's avatar
Natanael Copa committed
408 409 410
phpdbg() {
	pkgdesc="Interactive PHP debugger"
	mkdir -p "$subpkgdir"/usr/bin
411
	mv "$pkgdir"/usr/bin/phpdbg* "$subpkgdir"/usr/bin/
Natanael Copa's avatar
Natanael Copa committed
412 413
}

414 415
_mv_ext() {
	local ext=$1
416
	local ini=$ext.ini
417 418 419 420 421
	pkgdesc="${ext} extension for PHP"

	# extension dependencies
	if [ -n "${2-}" ]; then
		depends="${2-}"
422 423
	fi
	depends="${pkgname} ${depends}"
424

425 426 427 428 429 430
	# work around dependency issue
	# https://bugs.alpinelinux.org/issues/1848
	if [ "$ext" = "wddx" ]; then
		ini=xml_$ext.ini
	fi

431
	mkdir -p "$subpkgdir"/$_extdir
432
	mv "$pkgdir"/$_extdir/${ext}.so "$subpkgdir"/$_extdir/ || return 1
433
	mkdir -p "$subpkgdir"$_confdir/conf.d
434 435
	case "$1" in
		opcache)
436
			echo "zend_extension=${ext}.so" > "$subpkgdir"$_confdir/conf.d/$ini
437 438
			;;
		*)
439
			echo "extension=${ext}.so" > "$subpkgdir"$_confdir/conf.d/$ini
440 441
			;;
	esac
442
}
Carlo Landmeter's avatar
Carlo Landmeter committed
443

444 445 446
bcmath()	{ _mv_ext bcmath; }
bz2()		{ _mv_ext bz2; }
calendar()	{ _mv_ext calendar; }
447
ctype()		{ _mv_ext ctype; }
448
_curl()		{ _mv_ext curl; }
449 450
dba()		{ _mv_ext dba; }
dom()		{ _mv_ext dom; }
451
enchant()	{ _mv_ext enchant; }
452 453 454 455 456 457 458 459 460 461 462
exif()		{ _mv_ext exif; }
ftp()		{ _mv_ext ftp; }
gd()		{ _mv_ext gd; }
gettext()	{ _mv_ext gettext; }
gmp()		{ _mv_ext gmp; }
iconv()		{ _mv_ext iconv; }
imap()		{ _mv_ext imap; }
intl()		{ _mv_ext intl; }
json()		{ _mv_ext json; }
ldap()		{ _mv_ext ldap; }
mcrypt()	{ _mv_ext mcrypt; }
463 464
mysql()		{ _mv_ext mysql; }
mysqli()	{ _mv_ext mysqli; }
465
odbc()		{ _mv_ext odbc unixodbc; }
466
openssl()	{ _mv_ext openssl; }
467
pcntl()		{ _mv_ext pcntl; }
468
pdo()		{ _mv_ext pdo; }
469 470 471 472
pdo_mysql()	{ _mv_ext pdo_mysql $pkgname-pdo; }
pdo_odbc()	{ _mv_ext pdo_odbc $pkgname-pdo; }
pdo_pgsql()	{ _mv_ext pdo_pgsql $pkgname-pdo; }
pdo_sqlite()	{ _mv_ext pdo_sqlite $pkgname-pdo; }
473
pgsql()		{ _mv_ext pgsql; }
474
phar()		{
475
			_mv_ext phar
476 477
			mkdir -p "$subpkgdir"/usr/bin
			mv "$pkgdir"/usr/bin/phar* "$subpkgdir"/usr/bin/
478
		}
479 480 481 482 483 484
posix()		{ _mv_ext posix; }
pspell()	{ _mv_ext pspell; }
shmop()		{ _mv_ext shmop; }
snmp()		{ _mv_ext snmp; }
soap()		{ _mv_ext soap; }
sockets()	{ _mv_ext sockets; }
485
sqlite3()	{ _mv_ext sqlite3; }
486 487 488 489
sysvmsg()	{ _mv_ext sysvmsg; }
sysvsem()	{ _mv_ext sysvsem; }
sysvshm()	{ _mv_ext sysvshm; }
xml()		{ _mv_ext xml; }
490 491 492
xmlreader()	{ _mv_ext xmlreader $pkgname-dom; }
xmlrpc()	{ _mv_ext xmlrpc $pkgname-xml; }
xsl()		{ _mv_ext xsl $pkgname-dom; }
493 494
zip()		{ _mv_ext zip; }
zlib()		{ _mv_ext zlib; }
495
mssql()		{ _mv_ext mssql; }
496
pdo_dblib()	{ _mv_ext pdo_dblib "$pkgname-pdo freetds"; }
497
wddx()		{ _mv_ext wddx; }
498
opcache()	{ _mv_ext opcache; }
499

500
sha512sums="12734d786cca5767b8b8838affbe1c3d578dd179c8d5339653d905658562c5fdf39a88349213b1340f320320700a5378aed617447b6e15909019788a49ad2da0  php-5.6.30.tar.bz2
501
f7d922cab98617ef910b4c14974e768c85e60424cd1b216f688b34b2d823b642a5b896463008c134ce47c150f9407f5c438823b7e7bc89b3fb440cd3e97b9d7e  php-fpm.initd
502
895e94c791bd82060ad820fef049d366a09c932097faa6b7b9a2c2e9e00a18cb7c0f9b128679c7659b404379266fd0f95dba5c0333f626194cf60f7bf6044102  php5-module.conf
503
f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505  php-install-pear-xml.patch
504
6ecd0be2da1dc5b1d7512e46a2a5cd107a8b2a8c364efc9c624a7d6b2ab081685a329c94c22c970dc14c5c1115f702c512e97ae858da1bc69c6423323dbeeba2  gd-iconv.patch"