From f99a9d462487827bbeab1ee533a0e6269f3f3687 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Wed, 5 Oct 2022 19:31:52 -0300 Subject: [PATCH] Add thread-safe setup support --- src/scripts/darwin.sh | 2 +- src/scripts/extensions/source.sh | 2 +- src/scripts/linux.sh | 10 +++++----- src/scripts/tools/ppa.sh | 4 ++-- src/scripts/unix.sh | 4 +++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 4a1f38bc..3ef59881 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -173,7 +173,7 @@ add_php() { existing_version=$2 add_brew_tap "$php_tap" update_dependencies - [ "${debug:?}" = "debug" ] && php_formula="$php_formula-debug" + [ "${build:?}" = "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 355726e5..88839b25 100644 --- a/src/scripts/extensions/source.sh +++ b/src/scripts/extensions/source.sh @@ -146,7 +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" + [ "${build:?}" = "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 e9ccab55..846c0f22 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -76,7 +76,7 @@ check_package() { add_extension_helper() { local extension=$1 packages=(php"$version"-"$extension") - [ "${debug:?}" = "debug" ] && check_package php"$version"-"$extension"-dbgsym && packages+=(php"$version"-"$extension"-dbgsym) + [ "${build:?}" = "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 "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "$extension" add_extension_log "$extension" "Installed and enabled" @@ -96,7 +96,7 @@ add_devtools() { # Function to setup the nightly build from shivammathur/php-builder setup_nightly() { - run_script "php-builder" "${runner:?}" "$version" "${debug:?}" + run_script "php-builder" "${runner:?}" "$version" "${build:?}" } # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5. @@ -137,7 +137,7 @@ switch_version() { # Function to get packages to install get_php_packages() { sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ' - if [ "${debug:?}" = "debug" ]; then + if [ "${build:?}" = "debug" ]; then sed "s/[^ ]*/php$version-&-dbgsym/g" "$src"/configs/php_debug_packages | tr '\n' ' ' fi } @@ -149,7 +149,7 @@ add_packaged_php() { IFS=' ' read -r -a packages <<<"$(get_php_packages)" install_packages "${packages[@]}" else - run_script "php-ubuntu" "$version" "${debug:?}" + run_script "php-ubuntu" "$version" "${build:?}" fi } @@ -167,7 +167,7 @@ update_php() { # Function to install PHP. add_php() { - if [[ "$version" =~ ${nightly_versions:?} ]]; then + if [[ "$version" =~ ${nightly_versions:?} ]] || [[ "${build:?}" = "thread-safe" ]]; then setup_nightly elif [[ "$version" =~ ${old_versions:?} ]]; then setup_old_versions diff --git a/src/scripts/tools/ppa.sh b/src/scripts/tools/ppa.sh index 65662883..8809e6de 100644 --- a/src/scripts/tools/ppa.sh +++ b/src/scripts/tools/ppa.sh @@ -154,10 +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" + [ "${build:?}" = "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" + [ "${build:?}" = "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 2d058332..2a684bc9 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -50,7 +50,9 @@ set_output() { # Function to read env inputs. read_env() { update="${update:-${UPDATE:-false}}" - [ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release + build=release + [ "${debug:-${DEBUG:-false}}" = "true" ] && build=debug && update=true + [ "${phpts:-${PHPTS:-nts}}" = "ts" ] && build="thread-safe" && update=true fail_fast="${fail_fast:-${FAIL_FAST:-false}}" [[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github runner="${runner:-${RUNNER:-$_runner}}"