Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions support/get_gmp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )"
Expand Down
108 changes: 56 additions & 52 deletions support/package_php
Original file line number Diff line number Diff line change
@@ -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 )"
Expand All @@ -19,89 +19,93 @@ if [ -z "$1" ]; then
fi

php_version="$1"
php_series="$(echo $php_version | cut -d '.' -f1,2)"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is never used


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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the verbosity of the tar calls as it pollutes stdout.


echo "-----> Downloading dependency libonig ${libonig_version}"
libzip_flag=""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always empty

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}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved this earlier

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 <<SH
echo "zend_extension=opcache.so" > /app/vendor/php/etc/conf.d/opcache.ini
SH
)

WITH_CURL_CONFIGURE=""
WITH_CURL_CONFIGURE="--with-curl=/usr"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default value was already in the call to configure. We had a duplicated with-curl so I'm fixing this.

if [ -d '/app/.apt/usr' ] ; then
WITH_CURL_CONFIGURE="--with-curl=/app/.apt/usr"
fi

mkdir -p "/app/vendor/libwebp" \
&& curl "${PHP_BASE_URL}/package/libwebp-${webp_version}.tgz" | tar xzv -C /app/vendor/libwebp

export WEBP_LIBS="-L/app/vendor/libwebp/lib -lwebp"
export WEBP_CFLAGS="-I/app/vendor/libwebp/include"

ENABLE_GD_CONFIGURE="--enable-gd --with-jpeg --with-freetype --with-webp"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these options in the configure call directly, I find this clearer


mkdir -p "/app/vendor/php/etc/conf.d" \
&& pushd zlib-${zlib_version} >/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"
Expand Down