From b556cf729253c33b068e35b68dd700fcb9b5156d Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 26 Sep 2022 09:42:27 +0530 Subject: [PATCH] Add support for debug builds --- src/configs/php_debug_packages | 11 +++++++++++ src/scripts/darwin.sh | 1 + src/scripts/extensions/source.sh | 1 + src/scripts/linux.sh | 19 ++++++++++++++----- src/scripts/tools/ppa.sh | 2 ++ src/scripts/unix.sh | 1 + 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/configs/php_debug_packages diff --git a/src/configs/php_debug_packages b/src/configs/php_debug_packages new file mode 100644 index 00000000..5475016b --- /dev/null +++ b/src/configs/php_debug_packages @@ -0,0 +1,11 @@ +cgi +cli +curl +fpm +intl +mbstring +mysql +opcache +pgsql +xml +zip diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index c2caf8f7..4a1f38bc 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -173,6 +173,7 @@ add_php() { existing_version=$2 add_brew_tap "$php_tap" update_dependencies + [ "${debug:?}" = "debug" ] && php_formula="$php_formula-debug" if [ "$existing_version" != "false" ]; then ([ "$action" = "upgrade" ] && brew upgrade -f "$php_formula") || brew unlink "$php_formula" else diff --git a/src/scripts/extensions/source.sh b/src/scripts/extensions/source.sh index 1b416ef6..355726e5 100644 --- a/src/scripts/extensions/source.sh +++ b/src/scripts/extensions/source.sh @@ -146,6 +146,7 @@ add_extension_from_source() { add_log "${cross:?}" "$source" "$source does not have a PHP extension" else [[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries" + [ "${debug:?}" = "debug" ] && suffix_opts="$suffix_opts --enable-debug" patch_extension "$extension" >/dev/null 2>&1 run_group "phpize" "phpize" run_group "sudo $prefix_opts ./configure $suffix_opts $opts" "configure" diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index d684d8cb..e9ccab55 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -75,9 +75,10 @@ check_package() { # Helper function to add an extension. add_extension_helper() { local extension=$1 - package=php"$version"-"$extension" + packages=(php"$version"-"$extension") + [ "${debug:?}" = "debug" ] && check_package php"$version"-"$extension"-dbgsym && packages+=(php"$version"-"$extension"-dbgsym) add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php - (check_package "$package" && install_packages "$package") || pecl_install "$extension" + (check_package "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "$extension" add_extension_log "$extension" "Installed and enabled" sudo chmod 777 "${ini_file[@]}" } @@ -95,7 +96,7 @@ add_devtools() { # Function to setup the nightly build from shivammathur/php-builder setup_nightly() { - run_script "php-builder" "${runner:?}" "$version" + run_script "php-builder" "${runner:?}" "$version" "${debug:?}" } # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5. @@ -133,14 +134,22 @@ switch_version() { wait "${to_wait[@]}" } +# Function to get packages to install +get_php_packages() { + sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ' + if [ "${debug:?}" = "debug" ]; then + sed "s/[^ ]*/php$version-&-dbgsym/g" "$src"/configs/php_debug_packages | tr '\n' ' ' + fi +} + # Function to install packaged PHP add_packaged_php() { if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php - IFS=' ' read -r -a packages <<<"$(sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ')" + IFS=' ' read -r -a packages <<<"$(get_php_packages)" install_packages "${packages[@]}" else - run_script "php-ubuntu" "$version" + run_script "php-ubuntu" "$version" "${debug:?}" fi } diff --git a/src/scripts/tools/ppa.sh b/src/scripts/tools/ppa.sh index f73a5196..65662883 100644 --- a/src/scripts/tools/ppa.sh +++ b/src/scripts/tools/ppa.sh @@ -154,8 +154,10 @@ add_ppa() { ppa=${1:-ondrej/php} if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then add_list "$ppa" + [ "${debug:?}" = "debug" ] && add_list "$ppa" "$lp_ppa/$ppa/ubuntu" "$lp_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug" elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg + [ "${debug:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug" else add_list "$ppa" fi diff --git a/src/scripts/unix.sh b/src/scripts/unix.sh index a5abf380..2d058332 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -50,6 +50,7 @@ set_output() { # Function to read env inputs. read_env() { update="${update:-${UPDATE:-false}}" + [ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release fail_fast="${fail_fast:-${FAIL_FAST:-false}}" [[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github runner="${runner:-${RUNNER:-$_runner}}"