mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 03:41:06 +07:00
Fix to avoid double activation
Fix parsing extension input
This commit is contained in:
parent
5b29e8a454
commit
3818224063
@ -49,6 +49,7 @@ describe('Extension tests', () => {
|
||||
${'http-1.2.3'} | ${'7.3'} | ${'add_http http-1.2.3'}
|
||||
${'intl-65.1'} | ${'5.6'} | ${'add_intl intl-65.1'}
|
||||
${'ioncube'} | ${'7.3'} | ${'add_ioncube'}
|
||||
${'memcache-8.2'} | ${'8.2'} | ${'add_pecl_extension memcache 8.2 extension'}
|
||||
${'mongodb-mongodb/mongo-php-driver@master'} | ${'7.3'} | ${'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension'}
|
||||
${'oci8'} | ${'7.3'} | ${'add_oci oci8'}
|
||||
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'}
|
||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -260,7 +260,7 @@ async function addExtensionDarwin(extension_csv, version) {
|
||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
||||
return;
|
||||
case /.+-\d+\.\d+\.\d+.*/.test(extension):
|
||||
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
|
||||
add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix);
|
||||
return;
|
||||
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
|
||||
@ -313,13 +313,13 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.getUnsupportedLog(extension, version, 'win32');
|
||||
break;
|
||||
case /.+-\d+\.\d+\.\d+$/.test(extension):
|
||||
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
|
||||
break;
|
||||
case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension):
|
||||
matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec(version_extension);
|
||||
add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2].replace('preview', 'devel'), matches[1]);
|
||||
break;
|
||||
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
|
||||
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
|
||||
break;
|
||||
case /7\.[2-4]xdebug2/.test(version_extension):
|
||||
add_script += '\nAdd-Extension xdebug stable 2.9.8';
|
||||
break;
|
||||
@ -379,7 +379,7 @@ async function addExtensionLinux(extension_csv, version) {
|
||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
||||
return;
|
||||
case /.+-\d+\.\d+\.\d+.*/.test(extension):
|
||||
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
|
||||
add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix);
|
||||
return;
|
||||
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
|
||||
|
@ -70,7 +70,7 @@ export async function addExtensionDarwin(
|
||||
);
|
||||
return;
|
||||
// match semver
|
||||
case /.+-\d+\.\d+\.\d+.*/.test(extension):
|
||||
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
|
||||
add_script += await utils.joins(
|
||||
'\nadd_pecl_extension',
|
||||
ext_name,
|
||||
@ -176,15 +176,6 @@ export async function addExtensionWindows(
|
||||
'win32'
|
||||
);
|
||||
break;
|
||||
// match semver without state
|
||||
case /.+-\d+\.\d+\.\d+$/.test(extension):
|
||||
add_script += await utils.joins(
|
||||
'\nAdd-Extension',
|
||||
ext_name,
|
||||
'stable',
|
||||
ext_version
|
||||
);
|
||||
break;
|
||||
// match semver with state
|
||||
case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension):
|
||||
matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec(
|
||||
@ -197,6 +188,15 @@ export async function addExtensionWindows(
|
||||
matches[1]
|
||||
);
|
||||
break;
|
||||
// match semver without state
|
||||
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
|
||||
add_script += await utils.joins(
|
||||
'\nAdd-Extension',
|
||||
ext_name,
|
||||
'stable',
|
||||
ext_version
|
||||
);
|
||||
break;
|
||||
// match 7.2xdebug2 to 7.4xdebug2
|
||||
case /7\.[2-4]xdebug2/.test(version_extension):
|
||||
add_script += '\nAdd-Extension xdebug stable 2.9.8';
|
||||
@ -306,7 +306,7 @@ export async function addExtensionLinux(
|
||||
);
|
||||
return;
|
||||
// match semver versions
|
||||
case /.+-\d+\.\d+\.\d+.*/.test(extension):
|
||||
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
|
||||
add_script += await utils.joins(
|
||||
'\nadd_pecl_extension',
|
||||
ext_name,
|
||||
|
@ -49,6 +49,7 @@ enable_extension() {
|
||||
enable_extension_dependencies "$1" "$2"
|
||||
enable_cache_extension_dependencies "$1" "$2"
|
||||
if ! [[ "${version:?}" =~ ${old_versions:?} ]] && command -v phpenmod >/dev/null 2>&1; then
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "$pecl_file"
|
||||
mod="${ini_dir:?}"/../mods-available/"$1".ini
|
||||
if ! [ -e "$mod" ]; then
|
||||
priority="${3:-20}";
|
||||
@ -134,7 +135,6 @@ configure_pecl() {
|
||||
[ -z "${pecl_file:-${ini_file[@]}}" ] && return
|
||||
if ! [ -e /tmp/pecl_config ]; then
|
||||
for script in pear pecl; do
|
||||
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
|
||||
sudo "$script" channel-update "$script".php.net
|
||||
done
|
||||
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
||||
@ -174,17 +174,22 @@ get_pecl_version() {
|
||||
# Function to install PECL extensions and accept default options
|
||||
pecl_install() {
|
||||
local extension=$1
|
||||
local prefix=${2:-extension}
|
||||
add_pecl >/dev/null 2>&1
|
||||
cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')"
|
||||
prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'"
|
||||
suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
|
||||
IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
||||
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
|
||||
disable_extension_helper "${extension%-*}" >/dev/null 2>&1
|
||||
if [ "$version" = "5.3" ]; then
|
||||
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
|
||||
else
|
||||
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
|
||||
fi
|
||||
local exit_code=$?
|
||||
enable_extension "${extension%-*}" "$prefix"
|
||||
return "$exit_code"
|
||||
}
|
||||
|
||||
# Function to install a specific version of PECL extension.
|
||||
@ -200,7 +205,6 @@ add_pecl_extension() {
|
||||
if [ "${ext_version/-/}" = "$pecl_version" ]; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
else
|
||||
disable_extension_helper "$extension" >/dev/null 2>&1
|
||||
[ -n "$pecl_version" ] && pecl_version="-$pecl_version"
|
||||
pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1
|
||||
extension_version="$(php -r "echo phpversion('$extension');")"
|
||||
|
@ -34,7 +34,7 @@ disable_extension_helper() {
|
||||
if [ "$disable_dependents" = "true" ]; then
|
||||
disable_extension_dependents "$extension"
|
||||
fi
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file"
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "${ini_file[@]}" "$pecl_file"
|
||||
sudo find "$ini_dir"/.. -name "*$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
||||
sudo rm -f /tmp/php"$version"_extensions
|
||||
mkdir -p /tmp/extdisabled/"$version"
|
||||
|
Loading…
Reference in New Issue
Block a user