mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Fix versioned extensions
This commit is contained in:
parent
9d77946f60
commit
9b297384e1
@ -38,7 +38,7 @@ describe('Extension tests', () => {
|
|||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||||
expect(linux).toContain('add_pecl_extension grpc 1.2.3');
|
expect(linux).toContain('add_pecl_extension grpc 1.2.3 extension');
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'add_unstable_extension xdebug alpha zend_extension'
|
'add_unstable_extension xdebug alpha zend_extension'
|
||||||
);
|
);
|
||||||
@ -74,7 +74,7 @@ describe('Extension tests', () => {
|
|||||||
expect(darwin).toContain('sudo pecl install -f xdebug');
|
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||||
expect(darwin).toContain('sudo pecl install -f pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||||
expect(darwin).toContain('sudo pecl install -f grpc-1.2.3');
|
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
||||||
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
||||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -2711,6 +2711,11 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
' ' +
|
' ' +
|
||||||
prefix;
|
prefix;
|
||||||
return;
|
return;
|
||||||
|
// match exact versions
|
||||||
|
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix;
|
||||||
|
return;
|
||||||
case /5\.3xdebug/.test(version_extension):
|
case /5\.3xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
|
||||||
break;
|
break;
|
||||||
@ -2748,7 +2753,7 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' +
|
||||||
ext_name +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
@ -2842,7 +2847,8 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
return;
|
return;
|
||||||
// match exact versions
|
// match exact versions
|
||||||
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||||
script += '\nadd_pecl_extension ' + ext_name + ' ' + ext_version;
|
script +=
|
||||||
|
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix;
|
||||||
return;
|
return;
|
||||||
// match 5.6gearman..7.4gearman
|
// match 5.6gearman..7.4gearman
|
||||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
|
@ -32,6 +32,11 @@ export async function addExtensionDarwin(
|
|||||||
' ' +
|
' ' +
|
||||||
prefix;
|
prefix;
|
||||||
return;
|
return;
|
||||||
|
// match exact versions
|
||||||
|
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix;
|
||||||
|
return;
|
||||||
case /5\.3xdebug/.test(version_extension):
|
case /5\.3xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
|
||||||
break;
|
break;
|
||||||
@ -69,7 +74,7 @@ export async function addExtensionDarwin(
|
|||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' +
|
||||||
ext_name +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
@ -167,7 +172,8 @@ export async function addExtensionLinux(
|
|||||||
return;
|
return;
|
||||||
// match exact versions
|
// match exact versions
|
||||||
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||||
script += '\nadd_pecl_extension ' + ext_name + ' ' + ext_version;
|
script +=
|
||||||
|
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix;
|
||||||
return;
|
return;
|
||||||
// match 5.6gearman..7.4gearman
|
// match 5.6gearman..7.4gearman
|
||||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
|
@ -20,22 +20,14 @@ add_log() {
|
|||||||
remove_extension() {
|
remove_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
sudo sed -i '' "/$extension/d" "$ini_file"
|
sudo sed -i '' "/$extension/d" "$ini_file"
|
||||||
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to test if extension is loaded
|
||||||
add_extension() {
|
check_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
php -m | grep -i -q -w "$extension"
|
||||||
prefix=$3
|
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
||||||
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
|
||||||
(eval "$install_command" >/dev/null 2>&1 && test -f "$ext_dir/$extension.so" && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fuction to get the PECL version
|
# Fuction to get the PECL version
|
||||||
@ -51,31 +43,52 @@ get_pecl_version() {
|
|||||||
echo "$pecl_version"
|
echo "$pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to install a PECL version
|
||||||
|
add_pecl_extension() {
|
||||||
|
extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
remove_extension "$extension"
|
||||||
|
(
|
||||||
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup extensions
|
||||||
|
add_extension() {
|
||||||
|
extension=$1
|
||||||
|
install_command=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
|
elif check_extension "$extension"; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
elif ! check_extension "$extension"; then
|
||||||
|
(
|
||||||
|
eval "$install_command" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to pre-release extensions using PECL
|
# Function to pre-release extensions using PECL
|
||||||
add_unstable_extension() {
|
add_unstable_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
stability=$2
|
stability=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');")
|
|
||||||
if [ "$extension_version" = "$pecl_version" ]; then
|
|
||||||
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
remove_extension "$extension"
|
|
||||||
add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix"
|
|
||||||
fi
|
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
|
||||||
extension_version=$(php -r "echo phpversion('$extension');")
|
|
||||||
if [ "$extension_version" = "$pecl_version" ]; then
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
remove_extension "$extension"
|
|
||||||
add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool
|
# Function to setup a remote tool
|
||||||
@ -147,14 +160,13 @@ get_old_apiv() {
|
|||||||
|
|
||||||
# Function to setup PHP 5.3, 5.4 and 5.5
|
# Function to setup PHP 5.3, 5.4 and 5.5
|
||||||
setup_php_old() {
|
setup_php_old() {
|
||||||
php5=/usr/local/php5
|
|
||||||
ext_dir_parent="$php5"/lib/php/extensions
|
ext_dir_parent="$php5"/lib/php/extensions
|
||||||
ext_dir_name=no-debug-non-zts-$(get_old_apiv)
|
ext_dir_name=no-debug-non-zts-$(get_old_apiv)
|
||||||
ext_dir="$ext_dir_parent/$ext_dir_name"
|
ext_dir="$ext_dir_parent/$ext_dir_name"
|
||||||
sudo mv "$ext_dir" /tmp >/dev/null 2>&1 && sudo rm -rf "$php5"
|
sudo mv "$ext_dir" /tmp >/dev/null 2>&1 && sudo rm -rf "$php5"
|
||||||
sudo curl -s https://php-osx.liip.ch/install.sh | bash -s "$version" >/dev/null 2>&1
|
sudo curl -s https://php-osx.liip.ch/install.sh | bash -s "$version" >/dev/null 2>&1
|
||||||
sudo rsync -a /tmp/"$ext_dir_name"/ "$ext_dir" >/dev/null 2>&1
|
sudo rsync -a /tmp/"$ext_dir_name"/ "$ext_dir" >/dev/null 2>&1
|
||||||
sudo rm -rf "$php5"/php.d/*developer.ini "$php5"/php.d/*xdebug.ini /tmp/ext
|
sudo rm -rf "$php5"/php.d/*developer.ini "$php5"/php.d/*xdebug.ini /tmp/"$ext_dir_name"
|
||||||
for tool in pear peardev pecl php php-config phpize; do
|
for tool in pear peardev pecl php php-config phpize; do
|
||||||
sudo ln -sf "$php5"/bin/"$tool" /usr/local/bin/"$tool"
|
sudo ln -sf "$php5"/bin/"$tool" /usr/local/bin/"$tool"
|
||||||
done
|
done
|
||||||
@ -174,6 +186,7 @@ tick="✓"
|
|||||||
cross="✗"
|
cross="✗"
|
||||||
version=$1
|
version=$1
|
||||||
old_versions="5.[3-5]"
|
old_versions="5.[3-5]"
|
||||||
|
php5=/usr/local/php5
|
||||||
existing_version=$(php-config --version | cut -c 1-3)
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
[[ -z "${update}" ]] && update='false' || update="${update}"
|
[[ -z "${update}" ]] && update='false' || update="${update}"
|
||||||
|
|
||||||
@ -196,6 +209,7 @@ sudo chmod 777 "$ini_file"
|
|||||||
echo "date.timezone=UTC" >>"$ini_file"
|
echo "date.timezone=UTC" >>"$ini_file"
|
||||||
echo "detect_unicode=Off" >>"$ini_file"
|
echo "detect_unicode=Off" >>"$ini_file"
|
||||||
ext_dir=$(php -i | grep -Ei "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep -Ei "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
sudo mkdir -p "$ext_dir"
|
sudo mkdir -p "$ext_dir"
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
configure_pecl
|
configure_pecl
|
||||||
|
@ -54,27 +54,10 @@ get_pecl_version() {
|
|||||||
echo "$pecl_version"
|
echo "$pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to test if extension is loaded
|
||||||
add_extension() {
|
check_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
php -m | grep -i -q -w "$extension"
|
||||||
prefix=$3
|
|
||||||
if [[ "$version" =~ $old_versions ]]; then
|
|
||||||
install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
|
|
||||||
fi
|
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
||||||
# shellcheck disable=SC2046
|
|
||||||
$apt_install $(apt-cache depends php"$version"-"$extension" 2>/dev/null | awk '/Depends:/{print$2}') >/dev/null 2>&1
|
|
||||||
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
|
||||||
(eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
||||||
(update_ppa && eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
||||||
(sudo pecl install -f "$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
|
||||||
fi
|
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to delete extensions
|
# Function to delete extensions
|
||||||
@ -94,14 +77,49 @@ remove_extension() {
|
|||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to setup extensions
|
||||||
|
add_extension() {
|
||||||
|
extension=$1
|
||||||
|
install_command=$2
|
||||||
|
prefix=$3
|
||||||
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
|
install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
|
||||||
|
fi
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
$apt_install $(apt-cache depends php"$version"-"$extension" 2>/dev/null | awk '/Depends:/{print$2}') >/dev/null 2>&1
|
||||||
|
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
|
elif check_extension "$extension"; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
elif ! check_extension "$extension"; then
|
||||||
|
eval "$install_command" >/dev/null 2>&1 ||
|
||||||
|
(update_ppa && eval "$install_command" >/dev/null 2>&1) ||
|
||||||
|
sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||||
|
(check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
fi
|
||||||
|
sudo chmod 777 "$ini_file"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to install a PECL version
|
# Function to install a PECL version
|
||||||
add_pecl_extension() {
|
add_pecl_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
pecl_version=$2
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
(sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
(
|
||||||
add_log "$tick" "$extension" "Installed and enabled") ||
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to pre-release extensions using PECL
|
# Function to pre-release extensions using PECL
|
||||||
@ -110,25 +128,7 @@ add_unstable_extension() {
|
|||||||
stability=$2
|
stability=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');")
|
|
||||||
if [ "$extension_version" = "$pecl_version" ]; then
|
|
||||||
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
delete_extension "$extension"
|
|
||||||
add_pecl_extension "$extension" "$pecl_version"
|
|
||||||
fi
|
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
|
||||||
extension_version=$(php -r "echo phpversion('$extension');")
|
|
||||||
if [ "$extension_version" = "$pecl_version" ]; then
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
delete_extension "$extension"
|
|
||||||
add_pecl_extension "$extension" "$pecl_version"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
add_pecl_extension "$extension" "$pecl_version"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update extension
|
# Function to update extension
|
||||||
|
Loading…
Reference in New Issue
Block a user