Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thread-safe setup support #651

Merged
merged 3 commits into from Oct 17, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
482 changes: 482 additions & 0 deletions reset 1 qqc

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/configs/php_debug_packages
@@ -0,0 +1,11 @@
cgi
cli
curl
fpm
intl
mbstring
mysql
opcache
pgsql
xml
zip
2 changes: 1 addition & 1 deletion src/configs/tools.json
Expand Up @@ -110,7 +110,7 @@
"repository": "laravel/pint",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "Pint ",
"version_prefix": "v",
"version_parameter": "-V"
},
"psalm": {
Expand Down
1 change: 1 addition & 0 deletions src/scripts/darwin.sh
Expand Up @@ -173,6 +173,7 @@ add_php() {
existing_version=$2
add_brew_tap "$php_tap"
update_dependencies
[ "${build:?}" = "debug" ] && php_formula="$php_formula-debug"
if [ "$existing_version" != "false" ]; then
([ "$action" = "upgrade" ] && brew upgrade -f "$php_formula") || brew unlink "$php_formula"
else
Expand Down
1 change: 1 addition & 0 deletions src/scripts/extensions/source.sh
Expand Up @@ -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"
[ "${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"
Expand Down
21 changes: 15 additions & 6 deletions src/scripts/linux.sh
Expand Up @@ -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")
[ "${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 "$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[@]}"
}
Expand All @@ -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" "${build:?}"
}

# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
Expand Down Expand Up @@ -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 [ "${build:?}" = "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" "${build:?}"
fi
}

Expand All @@ -158,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
Expand Down
2 changes: 2 additions & 0 deletions src/scripts/tools/ppa.sh
Expand Up @@ -154,8 +154,10 @@ add_ppa() {
ppa=${1:-ondrej/php}
if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
add_list "$ppa"
[ "${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
[ "${build:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug"
else
add_list "$ppa"
fi
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/unix.sh
Expand Up @@ -50,6 +50,9 @@ set_output() {
# Function to read env inputs.
read_env() {
update="${update:-${UPDATE:-false}}"
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}}"
Expand Down