From 012070d418632e60b933018192fa44eb9e6c514f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 14:59:31 +0200 Subject: [PATCH 01/14] chore(php-buildpack): update pecl functions --- bin/compile | 6 +- lib/pecl | 350 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 291 insertions(+), 65 deletions(-) mode change 100644 => 100755 lib/pecl diff --git a/bin/compile b/bin/compile index 7de8c5f0..b562cd55 100755 --- a/bin/compile +++ b/bin/compile @@ -312,9 +312,9 @@ if [ -f "$BUILD_DIR/composer.json" ] && package_datadog_enabled; then install_datadog "${DATADOG_TRACER_VERSION}" "${DATADOG_APPSEC_VERSION}" fi -if [ -f "$BUILD_DIR/composer.json" ] && package_scout_enabled; then - install_scout "${SCOUT_APM_VERSION}" -fi +# if [ -f "$BUILD_DIR/composer.json" ] && package_scout_enabled; then +# install_scout "${SCOUT_APM_VERSION}" +# fi if [ -f "$BUILD_DIR/composer.json" ] && package_newrelic_enabled; then status "New Relic usage detected, installing Agent and PHP extension" diff --git a/lib/pecl b/lib/pecl old mode 100644 new mode 100755 index cc06ae73..3d2e370a --- a/lib/pecl +++ b/lib/pecl @@ -1,87 +1,313 @@ -function install_pecl_extension() { +#!/usr/bin/env bash + +function php::pecl::enable_pecl_extension() { + local rc=0 + + local name="${1}" + + local is_zend_extension_var_name + local is_zend_extension + + is_zend_extension_var_name="PHP_PECL_EXTENSION_IS_ZEND_${name}" + is_zend_extension="$( printenv "${is_zend_extension_var_name}" )" + + if [[ "${is_zend_extension}" = "true" ]]; then + echo "zend_extension=${name}.so" \ + > "/app/vendor/php/etc/conf.d/${name}.ini" + else + echo "extension=${name}.so" \ + > "/app/vendor/php/etc/conf.d/${name}.ini" + fi + + return "${rc}" +} + + +function php::pecl::get_latest_version() { + local rc=1 + local extension_name="${1}" + + local version + local url="https://pecl.php.net/rest/r/${extension_name}/latest.txt" + + if version="$( curl --fail --silent --show-error --location "${url}" )"; then + echo "${version}" + rc=0 + fi + + return "${rc}" +} + + +function php::pecl::install_from_cache() { + local rc=1 + + local name="${1}" local version="${2}" local cache_dir="${3}" + local ext_dir="${4}" - if [[ $version = '*' ]]; then - local version=$(curl --silent "https://pecl.php.net/rest/r/$extension_name/latest.txt") + local cached_file + + cached_file="${cache_dir}/${name}-${version}.so" + + if [ -f "${cached_file}" ]; then + cp "${cached_file}" "${ext_dir}/${name}.so" + + php::pecl::enable_pecl_extension "${name}" + rc="${?}" fi - local ext_dir=/app/vendor/php/lib/php/extensions/no-debug-non-zts-$(php_api_version) - - local cache_extension_file="${cache_dir}/${extension_name}-${version}.so" - if [ -f "${cache_extension_file}" ]; then - echo "Installing PECL extension ${extension_name} version ${version} from the cache" | indent - cp "${cache_extension_file}" "${ext_dir}/${extension_name}.so" - enable_pecl_extension ${extension_name} - return + + return "${rc}" +} + + +function php::pecl::download_extension() { + local rc=1 + + local name="${1}" + local version="${2}" + local temp_dir="${3}" + + local file + local url + + file="${name}-${version}.tgz" + url="https://pecl.php.net/get/${file}" + + pushd "${temp_dir}" >/dev/null \ + || { echo "Unable to enter ${temp_dir}." >&2; return 1; } + + curl --silent --location --fail "${url}" --output "${file}" + rc="${?}" + + if [ "${rc}" -eq 0 ]; then + echo "${temp_dir}/${file}" fi - local build_dir=$(pwd) - local temp_dir=$(mktmpdir "pecl-extension") + popd || return 1 - echo "Installing PECL extension ${extension_name} version ${version}" | indent + return "${rc}" +} - pushd "${temp_dir}" > /dev/null - curl --silent --location "https://pecl.php.net/get/${extension_name}-${version}.tgz" | tar xz +function php::pecl::extract_extension() { + local rc=1 - pushd ${extension_name}-${version} > /dev/null - ( - set +e - readonly phpize_log_file=$(mktemp "/tmp/pecl-phpize-${extension_name}-XXXX.log") - /app/vendor/php/bin/phpize > "${phpize_log_file}" 2>&1 - [ $? -eq 0 ] || install_pecl_error "${extension_name}" "package" "${phpize_log_file}" + local archive="${1}" + local output_dir="${2}" - local configure_extension_args_var_name="PHP_PECL_EXTENSION_CONFIGURE_ARGS_$extension_name" - local configure_extension_args=$(printenv $configure_extension_args_var_name) - local flags=$(echo $configure_extension_args | sed "s|\$BUILD_DIR|$build_dir|") + mkdir --parents "${output_dir}" - if [[ $extension_name = 'oci8' ]]; then - flags="--with-oci8=instantclient,${ORACLE_HOME}" - fi + tar --extract --gzip --strip-components=1 --directory="${output_dir}" \ + "${archive}" + + rc="${?}" + + if [ "${rc}" -ne 0 ]; then + rm --recursive --force "${archive}" + fi + + return "${rc}" +} - readonly configure_log_file=$(mktemp "/tmp/pecl-configure-${extension_name}-XXXX.log") - ./configure --with-php-config=/app/vendor/php/bin/php-config $flags > "${configure_log_file}" 2>&1 - [ $? -eq 0 ] || install_pecl_error "${extension_name}" "configure build" "${configure_log_file}" - readonly make_log_file=$(mktemp "/tmp/pecl-make-${extension_name}-XXXX.log") - make -j 2 > "${make_log_file}" 2>&1 - [ $? -eq 0 ] || install_pecl_error "${extension_name}" "compile" "${make_log_file}" - ) +function php::pecl::package_extension() { + local rc=1 - cp modules/${extension_name}.so "${ext_dir}/${extension_name}.so" - cp modules/${extension_name}.so "${cache_extension_file}" - enable_pecl_extension ${extension_name} + local name="${1}" - popd > /dev/null - popd > /dev/null + local log + + log="$( mktemp "/tmp/pecl-phpize-${name}-XXXX.log" )" + + /app/vendor/php/bin/phpize >"${log}" 2>&1 + rc="${?}" + + echo "${log}" + + return "${rc}" } -function enable_pecl_extension() { - local extension_name="${1}" - local is_zend_extension_var_name="PHP_PECL_EXTENSION_IS_ZEND_$extension_name" - local is_zend_extension=$(printenv $is_zend_extension_var_name) - if [[ $is_zend_extension = "true" ]] ; then - echo "zend_extension=${extension_name}.so" > "/app/vendor/php/etc/conf.d/${extension_name}.ini" - else - echo "extension=${extension_name}.so" > "/app/vendor/php/etc/conf.d/${extension_name}.ini" +function php::pecl::configure_extension() { + local rc=1 + + local name="${1}" + local build_dir="${2}" + + local log + local configure_args_varname + local configure_args + local flags + local raw_flags + + log="$( mktemp "/tmp/pecl-configure-${name}-XXXX.log" )" + + # Let's ease installation of some extensions: + case "${name}" in + "oci8") + flags=("--with-oci8=instantclient,${ORACLE_HOME}") + ;; + + "scoutapm") + flags=("--enable-scoutapm") + # scoutapm is a Zend extension: + PHP_PECL_EXTENSION_IS_ZEND_scoutapm="true" + export PHP_PECL_EXTENSION_IS_ZEND_scoutapm + ;; + + "yaml") + flags=("--with-yaml=${BUILD_DIR}/.apt/usr") + ;; + + *) + configure_args_varname="PHP_PECL_EXTENSION_CONFIGURE_ARGS_${name}" + configure_args="$( printenv "${configure_args_varname}" )" + raw_flags="${configure_args//\$BUILD_DIR/${build_dir}}" + + # Transform raw_flags into an array: + readarray -d " " -t flags <<<"${raw_flags} " + unset 'flags[-1]' + ;; + esac + + ./configure --with-php-config=/app/vendor/php/bin/php-config "${flags[@]}" >"${log}" 2>&1 + rc="${?}" + + echo "${log}" + + return "${rc}" +} + + +function php::pecl::make_extension() { + local rc=1 + + local name="${1}" + + local log + + log="$( mktemp "/tmp/pecl-make-${name}-XXXX.log" )" + + make -j 2 >"${log}" 2>&1 + rc="${?}" + + echo "${log}" + + return "${rc}" +} + + +function php::pecl::compile_extension() { + local rc=0 + + local ext_dir="${1}" + local build_dir="${2}" + local name="${3}" + + pushd "${ext_dir}" >/dev/null \ + || { echo "Unable to enter ${ext_dir}." >&2; return 1; } + + if ! log="$( php::pecl::package_extension "${name}" )"; then + rc="${?}" + cat "${log}" + fi + + if [ "${rc}" -eq 0 ]; then + if ! log="$( php::pecl::configure_extension "${name}" "${build_dir}" )"; then + rc="${?}" + cat "${log}" + fi + fi + + if [ "${rc}" -eq 0 ]; then + if ! log="$( php::pecl::make_extension "${name}" )"; then + rc="${?}" + cat "${log}" + fi fi + + popd || return 1 + + return "${rc}" } -function install_pecl_error() { + +function install_pecl_extension() { + local rc=1 + local extension_name="${1}" - local action="${2}" - local log_file="${3}" - - echo - tail -n 30 "${log_file}" | indent - echo - # This sleep prevents from having the following lines mixed up with the output - # of the above tail. Mystery of shellscripting. - sleep 0.1 - warn "Fail to ${action} of PHP PECL extension: ${extension_name}" - echo "Read above logs to understand the source of the issue" | indent - echo - exit 1 + local version="${2}" + local cache_dir="${3}" + + local build_dir + local version_number + local ext_dir + local temp_dir + local extension_temp_dir + local archive + + build_dir="$( pwd )" + version_number="${version}" + ext_dir="/app/vendor/php/lib/php/extensions/no-debug-non-zts-$(php_api_version)" + + + # If version is given as '*', try to retrieve the latest version number: + if [[ "${version}" = '*' ]]; then + if ! version_number="$( php::pecl::get_latest_version "${extension_name}" )"; then + rc="${?}" + echo "Unable retrieve PECL extension ${extension_name} latest version number. Aborting." >&2 + exit "${rc}" + fi + fi + + + # Try to install extension from cache, but never fail: + if php::pecl::install_from_cache "${extension_name}" "${version_number}" "${cache_dir}" "${ext_dir}"; then + echo "Successfully installed ${extension_name} ${version_number} from cache." + exit 0 + fi + + + # The extension is not cached, we have to install it. + echo "Installing PECL extension ${extension_name} ${version_number}" | indent + + temp_dir="$( mktmpdir "pecl-extension" )" + extension_temp_dir="${temp_dir}/${extension_name}-${version_number}" + + # Download: + if ! archive="$( php::pecl::download_extension "${extension_name}" "${version_number}" "${temp_dir}" )"; then + rc="${?}" + echo "Unable to download PECL extension ${extension_name} ${version_number}. Aborting." >&2 + exit "${rc}" + fi + + # Extract: + if ! php::pecl::extract_extension "${archive}" "${extension_temp_dir}"; then + rc="${?}" + echo "Unable to unpack PECL extension ${extension_name}. Aborting." >&2 + exit "${rc}" + fi + + # Compile: + if ! php::pecl::compile_extension "${extension_temp_dir}" "${build_dir}" "${extension_name}"; then + rc="${?}" + echo "Unable to compile extension ${extension_name}. Aborting." >&2 + exit "${rc}" + fi + + pushd "${extension_temp_dir}" >/dev/null \ + || { echo "Unable to enter ${extension_temp_dir}." >&2; return 1; } + + cp "modules/${extension_name}.so" "${ext_dir}/${extension_name}.so" + cp "modules/${extension_name}.so" "${cache_dir}/${extension_name}-${version_number}.so" + + popd || return 1 + + php::pecl::enable_pecl_extension "${extension_name}" + rc="${?}" + + return "${rc}" } From 8cccf6e21d712da75adc28474dc3adb958b3c548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 15:15:45 +0200 Subject: [PATCH 02/14] fix(pecl): fix php::pecl::extract_extension --- lib/pecl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pecl b/lib/pecl index 3d2e370a..62e518f6 100755 --- a/lib/pecl +++ b/lib/pecl @@ -100,8 +100,8 @@ function php::pecl::extract_extension() { mkdir --parents "${output_dir}" - tar --extract --gzip --strip-components=1 --directory="${output_dir}" \ - "${archive}" + tar --extract --gzip --strip-components=1 \ + --directory="${output_dir}" --file="${archive}" rc="${?}" From 513624f0d46fc35d7192d800d9d8daef7d7f51f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 15:20:15 +0200 Subject: [PATCH 03/14] fix(pecl): fix some echo calls --- lib/pecl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pecl b/lib/pecl index 62e518f6..4fd72d6b 100755 --- a/lib/pecl +++ b/lib/pecl @@ -32,7 +32,7 @@ function php::pecl::get_latest_version() { local url="https://pecl.php.net/rest/r/${extension_name}/latest.txt" if version="$( curl --fail --silent --show-error --location "${url}" )"; then - echo "${version}" + echo -n "${version}" rc=0 fi @@ -83,7 +83,7 @@ function php::pecl::download_extension() { rc="${?}" if [ "${rc}" -eq 0 ]; then - echo "${temp_dir}/${file}" + echo -n "${temp_dir}/${file}" fi popd || return 1 @@ -125,7 +125,7 @@ function php::pecl::package_extension() { /app/vendor/php/bin/phpize >"${log}" 2>&1 rc="${?}" - echo "${log}" + echo -n "${log}" return "${rc}" } @@ -176,7 +176,7 @@ function php::pecl::configure_extension() { ./configure --with-php-config=/app/vendor/php/bin/php-config "${flags[@]}" >"${log}" 2>&1 rc="${?}" - echo "${log}" + echo -n "${log}" return "${rc}" } @@ -194,7 +194,7 @@ function php::pecl::make_extension() { make -j 2 >"${log}" 2>&1 rc="${?}" - echo "${log}" + echo -n "${log}" return "${rc}" } From 39e845d2eaa014f9a10fa4de60fede9c98141eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 15:45:23 +0200 Subject: [PATCH 04/14] fix(pecl): fix some erroneous code --- lib/pecl | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/pecl b/lib/pecl index 4fd72d6b..eb736d39 100755 --- a/lib/pecl +++ b/lib/pecl @@ -70,23 +70,23 @@ function php::pecl::download_extension() { local version="${2}" local temp_dir="${3}" - local file + local archive local url - file="${name}-${version}.tgz" - url="https://pecl.php.net/get/${file}" + archive="${name}-${version}.tgz" + url="https://pecl.php.net/get/${archive}" pushd "${temp_dir}" >/dev/null \ || { echo "Unable to enter ${temp_dir}." >&2; return 1; } - curl --silent --location --fail "${url}" --output "${file}" + curl --silent --location --fail "${url}" --output "${archive}" rc="${?}" if [ "${rc}" -eq 0 ]; then - echo -n "${temp_dir}/${file}" + echo "${temp_dir}/${archive}" fi - popd || return 1 + popd >/dev/null || return 1 return "${rc}" } @@ -229,7 +229,7 @@ function php::pecl::compile_extension() { fi fi - popd || return 1 + popd >/dev/null || return 1 return "${rc}" } @@ -279,23 +279,20 @@ function install_pecl_extension() { # Download: if ! archive="$( php::pecl::download_extension "${extension_name}" "${version_number}" "${temp_dir}" )"; then - rc="${?}" echo "Unable to download PECL extension ${extension_name} ${version_number}. Aborting." >&2 - exit "${rc}" + return 1 fi # Extract: if ! php::pecl::extract_extension "${archive}" "${extension_temp_dir}"; then - rc="${?}" echo "Unable to unpack PECL extension ${extension_name}. Aborting." >&2 - exit "${rc}" + return 1 fi # Compile: if ! php::pecl::compile_extension "${extension_temp_dir}" "${build_dir}" "${extension_name}"; then - rc="${?}" echo "Unable to compile extension ${extension_name}. Aborting." >&2 - exit "${rc}" + return 1 fi pushd "${extension_temp_dir}" >/dev/null \ @@ -304,7 +301,7 @@ function install_pecl_extension() { cp "modules/${extension_name}.so" "${ext_dir}/${extension_name}.so" cp "modules/${extension_name}.so" "${cache_dir}/${extension_name}-${version_number}.so" - popd || return 1 + popd >/dev/null || return 1 php::pecl::enable_pecl_extension "${extension_name}" rc="${?}" From b15160580097991a609734cad0a687322ece3c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 18:16:06 +0200 Subject: [PATCH 05/14] fix(pecl): fix enable_pecl_extension function --- lib/pecl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pecl b/lib/pecl index eb736d39..f0003891 100755 --- a/lib/pecl +++ b/lib/pecl @@ -2,13 +2,23 @@ function php::pecl::enable_pecl_extension() { local rc=0 + local known_zend_extensions=("scoutapm") local name="${1}" local is_zend_extension_var_name local is_zend_extension + local is_in_array is_zend_extension_var_name="PHP_PECL_EXTENSION_IS_ZEND_${name}" + + is_in_array="$( echo "${known_zend_extensions[@]}" | grep -ow "${name}" | wc -w )" + + if [ "${is_in_array}" -gt 0 ]; then + declare "${is_zend_extension_var_name}"="true" + export "${is_zend_extension_var_name}" + fi + is_zend_extension="$( printenv "${is_zend_extension_var_name}" )" if [[ "${is_zend_extension}" = "true" ]]; then @@ -153,9 +163,6 @@ function php::pecl::configure_extension() { "scoutapm") flags=("--enable-scoutapm") - # scoutapm is a Zend extension: - PHP_PECL_EXTENSION_IS_ZEND_scoutapm="true" - export PHP_PECL_EXTENSION_IS_ZEND_scoutapm ;; "yaml") From 3b49c6a9426b52c2fc43eae5557cedacca5fe133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 18:19:01 +0200 Subject: [PATCH 06/14] fix(pecl): fix error handling when an extension doesn't exist --- lib/pecl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pecl b/lib/pecl index f0003891..88fa57be 100755 --- a/lib/pecl +++ b/lib/pecl @@ -264,9 +264,8 @@ function install_pecl_extension() { # If version is given as '*', try to retrieve the latest version number: if [[ "${version}" = '*' ]]; then if ! version_number="$( php::pecl::get_latest_version "${extension_name}" )"; then - rc="${?}" echo "Unable retrieve PECL extension ${extension_name} latest version number. Aborting." >&2 - exit "${rc}" + return 1 fi fi @@ -274,7 +273,7 @@ function install_pecl_extension() { # Try to install extension from cache, but never fail: if php::pecl::install_from_cache "${extension_name}" "${version_number}" "${cache_dir}" "${ext_dir}"; then echo "Successfully installed ${extension_name} ${version_number} from cache." - exit 0 + return 0 fi From fb6b1cfbab86d380135be9f732cea10d4d737c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 18:22:24 +0200 Subject: [PATCH 07/14] fix(pecl): better error messages --- lib/pecl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pecl b/lib/pecl index 88fa57be..91ef9b91 100755 --- a/lib/pecl +++ b/lib/pecl @@ -264,7 +264,7 @@ function install_pecl_extension() { # If version is given as '*', try to retrieve the latest version number: if [[ "${version}" = '*' ]]; then if ! version_number="$( php::pecl::get_latest_version "${extension_name}" )"; then - echo "Unable retrieve PECL extension ${extension_name} latest version number. Aborting." >&2 + echo "Unable to retrieve '${extension_name}' latest version number. Aborting." >&2 return 1 fi fi @@ -272,32 +272,32 @@ function install_pecl_extension() { # Try to install extension from cache, but never fail: if php::pecl::install_from_cache "${extension_name}" "${version_number}" "${cache_dir}" "${ext_dir}"; then - echo "Successfully installed ${extension_name} ${version_number} from cache." + echo "Successfully installed '${extension_name}' ${version_number} from cache." return 0 fi # The extension is not cached, we have to install it. - echo "Installing PECL extension ${extension_name} ${version_number}" | indent + echo "Installing PECL extension '${extension_name}' ${version_number}" | indent temp_dir="$( mktmpdir "pecl-extension" )" extension_temp_dir="${temp_dir}/${extension_name}-${version_number}" # Download: if ! archive="$( php::pecl::download_extension "${extension_name}" "${version_number}" "${temp_dir}" )"; then - echo "Unable to download PECL extension ${extension_name} ${version_number}. Aborting." >&2 + echo "Unable to download PECL extension '${extension_name}' ${version_number}. Aborting." >&2 return 1 fi # Extract: if ! php::pecl::extract_extension "${archive}" "${extension_temp_dir}"; then - echo "Unable to unpack PECL extension ${extension_name}. Aborting." >&2 + echo "Unable to unpack PECL extension '${extension_name}'. Aborting." >&2 return 1 fi # Compile: if ! php::pecl::compile_extension "${extension_temp_dir}" "${build_dir}" "${extension_name}"; then - echo "Unable to compile extension ${extension_name}. Aborting." >&2 + echo "Unable to compile PECL extension '${extension_name}'. Aborting." >&2 return 1 fi From 925734a225641035f6f0dba65b175e95908ef543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 18:31:39 +0200 Subject: [PATCH 08/14] fix(pecl): better success message --- lib/pecl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pecl b/lib/pecl index 91ef9b91..7c9a5b88 100755 --- a/lib/pecl +++ b/lib/pecl @@ -243,8 +243,6 @@ function php::pecl::compile_extension() { function install_pecl_extension() { - local rc=1 - local extension_name="${1}" local version="${2}" local cache_dir="${3}" @@ -309,8 +307,11 @@ function install_pecl_extension() { popd >/dev/null || return 1 - php::pecl::enable_pecl_extension "${extension_name}" - rc="${?}" - - return "${rc}" + if ! php::pecl::enable_pecl_extension "${extension_name}"; then + echo "Unable to activate PECL extension '${extension_name}' ${version_number}. Aborting." >&2 + return 1 + else + echo "Successfully installed PECL extension '${extension_name}' ${version_number}." + return 0 + fi } From 52a749f8f52556a1796c14c82269ae0325616029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Mon, 10 Jul 2023 18:39:34 +0200 Subject: [PATCH 09/14] fix(pecl): shellcheck compliance --- lib/pecl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pecl b/lib/pecl index 7c9a5b88..120e0cc9 100755 --- a/lib/pecl +++ b/lib/pecl @@ -16,7 +16,7 @@ function php::pecl::enable_pecl_extension() { if [ "${is_in_array}" -gt 0 ]; then declare "${is_zend_extension_var_name}"="true" - export "${is_zend_extension_var_name}" + export "${is_zend_extension_var_name?}" fi is_zend_extension="$( printenv "${is_zend_extension_var_name}" )" From 356b7a7dedb6c6d663a30694ed638c1bbeba4e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Tue, 11 Jul 2023 10:38:48 +0200 Subject: [PATCH 10/14] chore(pecl): remove useless files and calls --- lib/composer | 2 +- lib/scout | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 lib/scout diff --git a/lib/composer b/lib/composer index e97a9419..b30c7c26 100644 --- a/lib/composer +++ b/lib/composer @@ -127,7 +127,7 @@ function install_composer_deps() { echo "Installing PHP extension: ${ext}" | indent fetch_package "${PHP_BASE_URL}" "${extension_package_path}" "/app/vendor/php" else - install_pecl_extension "${ext}" "${ext_version}" "${CACHE_DIR}" + php::pecl::install_extension "${ext}" "${ext_version}" "${CACHE_DIR}" fi done fi diff --git a/lib/scout b/lib/scout deleted file mode 100644 index 58a5ebb7..00000000 --- a/lib/scout +++ /dev/null @@ -1,22 +0,0 @@ -function install_scout() { - status "ScoutAPM usage detected, installing PHP extension" - - local ext_dir=/app/vendor/php/lib/php/extensions/no-debug-non-zts-$(php_api_version) - local version="${1}" - local cwd=$(pwd) - local temp_dir=$(mktmpdir "scout") - - cd "${temp_dir}" - - curl --location "https://pecl.php.net/get/scoutapm-${version}.tgz" | tar xzv - - cd scoutapm-${version} - /app/vendor/php/bin/phpize - ./configure --with-php-config=/app/vendor/php/bin/php-config --enable-scoutapm - - make - cp modules/scoutapm.so "${ext_dir}/scoutapm.so" - echo "zend_extension=scoutapm.so" > "/app/vendor/php/etc/conf.d/scoutapm.ini" - - cd "${cwd}" -} From 5ded27c8107c8b709dded9fe8dd816e72b03f60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Tue, 11 Jul 2023 10:40:22 +0200 Subject: [PATCH 11/14] chore(pecl): rename function --- lib/pecl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pecl b/lib/pecl index 120e0cc9..54a66fee 100755 --- a/lib/pecl +++ b/lib/pecl @@ -242,7 +242,7 @@ function php::pecl::compile_extension() { } -function install_pecl_extension() { +function php::pecl::install_extension() { local extension_name="${1}" local version="${2}" local cache_dir="${3}" From 16eb9829c226fbb493dec8ece6673166643a85b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Tue, 11 Jul 2023 10:42:22 +0200 Subject: [PATCH 12/14] chore(pecl): remove import of 'lib/scout' --- bin/compile | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/compile b/bin/compile index b562cd55..9fd55dde 100755 --- a/bin/compile +++ b/bin/compile @@ -11,7 +11,6 @@ source $basedir/common.sh source $basedir/../lib/package source $basedir/../lib/composer source $basedir/../lib/datadog -source $basedir/../lib/scout source $basedir/../lib/newrelic source $basedir/../lib/apt source $basedir/../lib/pecl From 4527a82497474f1354f793085c703a1455a23a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Tue, 11 Jul 2023 11:00:51 +0200 Subject: [PATCH 13/14] chore(pecl): rename function --- lib/pecl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pecl b/lib/pecl index 54a66fee..ae4345b4 100755 --- a/lib/pecl +++ b/lib/pecl @@ -1,6 +1,6 @@ #!/usr/bin/env bash -function php::pecl::enable_pecl_extension() { +function php::pecl::enable_extension() { local rc=0 local known_zend_extensions=("scoutapm") @@ -65,7 +65,7 @@ function php::pecl::install_from_cache() { if [ -f "${cached_file}" ]; then cp "${cached_file}" "${ext_dir}/${name}.so" - php::pecl::enable_pecl_extension "${name}" + php::pecl::enable_extension "${name}" rc="${?}" fi @@ -307,7 +307,7 @@ function php::pecl::install_extension() { popd >/dev/null || return 1 - if ! php::pecl::enable_pecl_extension "${extension_name}"; then + if ! php::pecl::enable_extension "${extension_name}"; then echo "Unable to activate PECL extension '${extension_name}' ${version_number}. Aborting." >&2 return 1 else From 3f43de314f4fbd61369dbd22fcdc5a054ec4dcb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20KUBLER?= Date: Tue, 11 Jul 2023 11:03:39 +0200 Subject: [PATCH 14/14] chore(pecl): remove useless code --- bin/compile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bin/compile b/bin/compile index 9fd55dde..7a9570e5 100755 --- a/bin/compile +++ b/bin/compile @@ -311,10 +311,6 @@ if [ -f "$BUILD_DIR/composer.json" ] && package_datadog_enabled; then install_datadog "${DATADOG_TRACER_VERSION}" "${DATADOG_APPSEC_VERSION}" fi -# if [ -f "$BUILD_DIR/composer.json" ] && package_scout_enabled; then -# install_scout "${SCOUT_APM_VERSION}" -# fi - if [ -f "$BUILD_DIR/composer.json" ] && package_newrelic_enabled; then status "New Relic usage detected, installing Agent and PHP extension" LOG_FILES+=( "/app/vendor/newrelic/daemon.log" "/app/vendor/newrelic/agent.log" )