diff --git a/support/get_gmp b/support/get_gmp index 0ac2b6ed..77f48856 100755 --- a/support/get_gmp +++ b/support/get_gmp @@ -5,6 +5,8 @@ if [ -n "$DEBUG" ]; then set -x fi +which m4 2> /dev/null || (apt-get update && apt-get install --yes m4) + # The variable is assigned in `buildpack.conf` declare gmp_version basedir="$( cd -P "$( dirname "$0" )" && pwd )" diff --git a/support/package_php b/support/package_php index 8304402c..c4cbf442 100755 --- a/support/package_php +++ b/support/package_php @@ -1,9 +1,9 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e if [ -n "$DEBUG" ]; then - set -x + set -x fi basedir="$( cd -P "$( dirname "$0" )" && pwd )" @@ -19,27 +19,29 @@ if [ -z "$1" ]; then fi php_version="$1" -php_series="$(echo $php_version | cut -d '.' -f1,2)" echo "-----> Packaging PHP $php_version" tempdir=$(mktmpdir php) -cd $tempdir +cd "$tempdir" echo "-----> Downloading dependency zlib ${zlib_version}" curl -LO "${PHP_BASE_URL}/zlib/zlib-${zlib_version}.tar.gz" -tar -xzvf "zlib-${zlib_version}.tar.gz" +tar -xzf "zlib-${zlib_version}.tar.gz" echo "-----> Downloading dependency libonig ${libonig_version}" -libzip_flag="" mkdir /app/vendor/libonig -p curl -L -o - "${PHP_BASE_URL}/package/libonig-${libonig_version}.tgz" | tar -C /app/vendor/libonig -xvz export C_INCLUDE_PATH="$C_INCLUDE_PATH:/app/vendor/libonig/include" export PKG_CONFIG_PATH="/app/vendor/libonig/lib/pkgconfig:$PKG_CONFIG_PATH" +echo "-----> Downloading dependency WebP library ${webp_version}" +mkdir -p "/app/vendor/libwebp" +curl "${PHP_BASE_URL}/package/libwebp-${webp_version}.tgz" | tar xz -C /app/vendor/libwebp + echo "-----> Downloading PHP $php_version" curl -LO "https://php.net/distributions/php-${php_version}.tar.gz" -tar -xzvf "php-${php_version}.tar.gz" +tar -xzf "php-${php_version}.tar.gz" install_zend_optimizer=":" install_zend_optimizer=$(cat </dev/null && ./configure --prefix=/app/vendor/php/zlib && make && make install && popd > /dev/null \ -&& pushd php-${php_version} >/dev/null \ -&& ./configure --prefix=/app/vendor/php \ ---with-config-file-path=/app/vendor/php/etc \ ---with-config-file-scan-dir=/app/vendor/php/etc/conf.d \ ---enable-intl \ -${ENABLE_GD_CONFIGURE} \ ---enable-exif \ ---with-mysqli \ ---with-pdo-mysql \ ---with-pdo-sqlite \ ---with-pdo-pgsql=/usr/bin/pg_config \ ---with-pgsql \ ---enable-shmop \ ---with-zip \ -${WITH_CURL_CONFIGURE} \ -${libzip_flag} \ ---with-zlib=/app/vendor/php/zlib \ ---with-bz2 \ ---with-openssl \ ---enable-soap \ ---enable-xmlreader \ ---with-curl=/usr \ ---with-xsl \ ---enable-fpm \ ---enable-mbstring \ ---enable-pcntl \ ---enable-sockets \ ---enable-bcmath \ ---with-readline \ ---with-password-argon2 \ ---disable-debug \ -&& echo ${php_version} | grep ^5.3 && sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile || true \ -&& make -j 8 \ -&& make install \ -&& popd > /dev/null \ -&& eval $install_zend_optimizer +mkdir -p "/app/vendor/php/etc/conf.d" + +echo "-----> Compile ZLib v${zlib_version}" +pushd "zlib-${zlib_version}" >/dev/null +./configure --prefix=/app/vendor/php/zlib +make +make install +popd > /dev/null + +echo "-----> Compile PHP v${php_version}" +pushd "php-${php_version}" >/dev/null +./configure --prefix=/app/vendor/php \ + --with-config-file-path=/app/vendor/php/etc \ + --with-config-file-scan-dir=/app/vendor/php/etc/conf.d \ + --enable-intl \ + --enable-gd --with-jpeg --with-freetype --with-webp \ + --enable-exif \ + --with-mysqli \ + --with-pdo-mysql \ + --with-pdo-sqlite \ + --with-pdo-pgsql=/usr/bin/pg_config \ + --with-pgsql \ + --enable-shmop \ + --with-zip \ + ${WITH_CURL_CONFIGURE} \ + --with-zlib=/app/vendor/php/zlib \ + --with-bz2 \ + --with-openssl \ + --enable-soap \ + --enable-xmlreader \ + --with-xsl \ + --enable-fpm \ + --enable-mbstring \ + --enable-pcntl \ + --enable-sockets \ + --enable-bcmath \ + --with-readline \ + --with-password-argon2 \ + --disable-debug +echo "${php_version}" | grep ^5.3 && sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile || true +make -j 8 +make install +popd > /dev/null + +eval "$install_zend_optimizer" mkdir package pushd /app/vendor/php > /dev/null -tar zcvf "${tempdir}/package/php-${php_version}.tgz" . +tar zcf "${tempdir}/package/php-${php_version}.tgz" . popd > /dev/null echo "-----> Moving package to Swift"