mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 13:23:05 +07:00
Fix extension setup using PECL on Linux and macOS
This commit is contained in:
parent
16011a795d
commit
7e03c76ef2
@ -144,14 +144,18 @@ add_extension() {
|
|||||||
# Function to get the PECL version of an extension.
|
# Function to get the PECL version of an extension.
|
||||||
get_pecl_version() {
|
get_pecl_version() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
|
states=("stable" "rc" "preview" "beta" "alpha" "snapshot")
|
||||||
|
stability="$(echo "$2" | grep -m 1 -Eio "($(IFS='|' ; echo "${states[*]}"))")"
|
||||||
|
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo "$stability.*")"
|
||||||
major_version=${3:-'[0-9]+'}
|
major_version=${3:-'[0-9]+'}
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
|
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "($major_version\.[0-9]+\.[0-9]+${stability}[0-9]+<)" | cut -d '<' -f 1)
|
for state in "${states[@]}"; do
|
||||||
if [ ! "$pecl_version" ]; then
|
pecl_version=$(echo "$response" | grep -m 1 -Eio "($major_version\.[0-9]+\.[0-9]+${state}[0-9]+<)" | cut -d '<' -f 1)
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+)<" | cut -d '<' -f 1)
|
[ -z "$pecl_version" ] && pecl_version=$(echo "$response" | grep -m 1 -Eio "v>(.*)<\/v>.*$state<" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+.*)<" | cut -d '<' -f 1)
|
||||||
fi
|
[ -n "$pecl_version" ] && break;
|
||||||
|
done
|
||||||
|
[ -z "$pecl_version" ] && pecl_version=$(echo "$response" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+)<" | cut -d '<' -f 1)
|
||||||
echo "$pecl_version"
|
echo "$pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,8 +189,9 @@ add_pecl_extension() {
|
|||||||
add_log "${tick:?}" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
else
|
else
|
||||||
disable_extension_helper "$extension" >/dev/null 2>&1
|
disable_extension_helper "$extension" >/dev/null 2>&1
|
||||||
pecl_install "$extension-$pecl_version"
|
[ -n "$pecl_version" ] && pecl_version="-$pecl_version"
|
||||||
add_extension_log "$extension-$pecl_version" "Installed and enabled"
|
pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")"
|
||||||
|
add_extension_log "$extension-$(php -r "echo phpversion('$extension');")" "Installed and enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,3 +203,8 @@ add_unstable_extension() {
|
|||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to get extension prefix
|
||||||
|
get_extension_prefix() {
|
||||||
|
echo "$1" | grep -Eq "xdebug([2-3])?$|opcache|ioncube|eaccelerator" && echo zend_extension || echo extension
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user