mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Do not delete extensions, just disable them
This commit is contained in:
parent
f6b4601c63
commit
5402397d9f
@ -4,7 +4,7 @@ describe('Config tests', () => {
|
||||
it('checking addCoverage with PCOV on windows', async () => {
|
||||
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Remove-Extension xdebug');
|
||||
expect(win32).toContain('Disable-Extension xdebug');
|
||||
|
||||
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
||||
expect(win32).toContain('PHP 7.1 or newer is required');
|
||||
@ -16,13 +16,13 @@ describe('Config tests', () => {
|
||||
it('checking addCoverage with PCOV on linux', async () => {
|
||||
const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
|
||||
expect(linux).toContain('add_extension pcov');
|
||||
expect(linux).toContain('remove_extension xdebug');
|
||||
expect(linux).toContain('disable_extension xdebug');
|
||||
});
|
||||
|
||||
it('checking addCoverage with PCOV on darwin', async () => {
|
||||
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
|
||||
expect(darwin).toContain('add_brew_extension pcov');
|
||||
expect(darwin).toContain('remove_extension xdebug');
|
||||
expect(darwin).toContain('disable_extension xdebug');
|
||||
});
|
||||
|
||||
it('checking addCoverage with Xdebug on windows', async () => {
|
||||
@ -84,20 +84,20 @@ describe('Config tests', () => {
|
||||
|
||||
it('checking disableCoverage windows', async () => {
|
||||
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
|
||||
expect(win32).toContain('Remove-Extension xdebug');
|
||||
expect(win32).toContain('Remove-Extension pcov');
|
||||
expect(win32).toContain('Disable-Extension xdebug');
|
||||
expect(win32).toContain('Disable-Extension pcov');
|
||||
});
|
||||
|
||||
it('checking disableCoverage on linux', async () => {
|
||||
const linux: string = await coverage.addCoverage('none', '7.4', 'linux');
|
||||
expect(linux).toContain('remove_extension xdebug');
|
||||
expect(linux).toContain('remove_extension pcov');
|
||||
expect(linux).toContain('disable_extension xdebug');
|
||||
expect(linux).toContain('disable_extension pcov');
|
||||
});
|
||||
|
||||
it('checking disableCoverage on darwin', async () => {
|
||||
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
|
||||
expect(darwin).toContain('remove_extension xdebug');
|
||||
expect(darwin).toContain('remove_extension pcov');
|
||||
expect(darwin).toContain('disable_extension xdebug');
|
||||
expect(darwin).toContain('disable_extension pcov');
|
||||
});
|
||||
|
||||
it('checking no or invalid coverage driver', async () => {
|
||||
|
@ -10,7 +10,7 @@ describe('Extension tests', () => {
|
||||
expect(win32).toContain('Add-Extension xdebug');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Add-Extension sqlite3');
|
||||
expect(win32).toContain('Remove-Extension intl');
|
||||
expect(win32).toContain('Disable-Extension intl');
|
||||
expect(win32).toContain('Add-Phalcon phalcon4');
|
||||
expect(win32).toContain('Add-Http');
|
||||
expect(win32).toContain('Add-Ioncube');
|
||||
@ -78,7 +78,7 @@ describe('Extension tests', () => {
|
||||
);
|
||||
expect(linux).toContain('add_extension xdebug');
|
||||
expect(linux).toContain('add_extension sqlite3');
|
||||
expect(linux).toContain('remove_extension intl');
|
||||
expect(linux).toContain('disable_extension intl');
|
||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||
expect(linux).toContain('add_pdo_extension mysql');
|
||||
expect(linux).toContain('add_pdo_extension odbc');
|
||||
@ -185,7 +185,7 @@ describe('Extension tests', () => {
|
||||
expect(darwin).toContain('add_brew_extension swoole extension');
|
||||
expect(darwin).toContain('add_brew_extension yaml extension');
|
||||
expect(darwin).toContain('add_extension sqlite3');
|
||||
expect(darwin).toContain('remove_extension intl');
|
||||
expect(darwin).toContain('disable_extension intl');
|
||||
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
|
||||
|
||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -210,7 +210,7 @@ async function addExtensionDarwin(extension_csv, version) {
|
||||
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
||||
switch (true) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||
remove_script += '\ndisable_extension ' + ext_name.slice(1);
|
||||
return;
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
@ -256,7 +256,7 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
let matches;
|
||||
switch (true) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
|
||||
remove_script += '\nDisable-Extension ' + ext_name.slice(1);
|
||||
break;
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
||||
@ -313,7 +313,7 @@ async function addExtensionLinux(extension_csv, version) {
|
||||
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
||||
switch (true) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||
remove_script += '\ndisable_extension ' + ext_name.slice(1);
|
||||
return;
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
|
@ -21,7 +21,7 @@ export async function addExtensionDarwin(
|
||||
switch (true) {
|
||||
// match :extension
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||
remove_script += '\ndisable_extension ' + ext_name.slice(1);
|
||||
return;
|
||||
// match extensions for compiling from source
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
@ -115,7 +115,7 @@ export async function addExtensionWindows(
|
||||
switch (true) {
|
||||
// Match :extension
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
|
||||
remove_script += '\nDisable-Extension ' + ext_name.slice(1);
|
||||
break;
|
||||
// match 5.3blackfire...8.0blackfire
|
||||
// match 5.3blackfire-(semver)...8.0blackfire-(semver)
|
||||
@ -227,7 +227,7 @@ export async function addExtensionLinux(
|
||||
switch (true) {
|
||||
// Match :extension
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||
remove_script += '\ndisable_extension ' + ext_name.slice(1);
|
||||
return;
|
||||
// match extensions for compiling from source
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
|
@ -133,6 +133,18 @@ enable_extension() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to disable an extensions.
|
||||
disable_extension() {
|
||||
extension=$1
|
||||
if check_extension "$extension"; then
|
||||
disable_extension_helper "$extension"
|
||||
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Disabled") ||
|
||||
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP ${semver:?}"
|
||||
else
|
||||
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to configure PHP
|
||||
configure_php() {
|
||||
(
|
||||
@ -186,8 +198,7 @@ add_pecl_extension() {
|
||||
if [ "$ext_version" = "$pecl_version" ]; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
else
|
||||
disable_extension "$extension" >/dev/null 2>&1
|
||||
delete_extension "$extension" >/dev/null 2>&1
|
||||
disable_extension_helper "$extension" >/dev/null 2>&1
|
||||
pecl_install "$extension-$pecl_version"
|
||||
add_extension_log "$extension-$pecl_version" "Installed and enabled"
|
||||
fi
|
||||
|
@ -7,29 +7,11 @@ self_hosted_helper() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to delete extension.
|
||||
delete_extension() {
|
||||
extension=$1
|
||||
sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to disable extension.
|
||||
disable_extension() {
|
||||
# Helper function to disable an extension.
|
||||
disable_extension_helper() {
|
||||
extension=$1
|
||||
sudo sed -Ei '' "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file:?}"
|
||||
}
|
||||
|
||||
# Function to remove extensions.
|
||||
remove_extension() {
|
||||
extension=$1
|
||||
if check_extension "$extension"; then
|
||||
disable_extension "$extension"
|
||||
delete_extension "$extension"
|
||||
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
|
||||
add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
|
||||
else
|
||||
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||
fi
|
||||
sudo rm -rf "$scan_dir"/*"$extension"*
|
||||
}
|
||||
|
||||
# Function to fetch a brew tap.
|
||||
@ -217,7 +199,7 @@ setup_php() {
|
||||
semver=$(php_semver)
|
||||
extra_version=$(php_extra_version)
|
||||
if [ "${semver%.*}" != "$version" ]; then
|
||||
add_log "$cross" "PHP" "Could not setup PHP $version"
|
||||
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -99,7 +99,7 @@ add_http_version() {
|
||||
ext=$1
|
||||
enable_http
|
||||
if [ "x$(php -r "echo phpversion('http');")" != "x${ext##*-}" ]; then
|
||||
remove_extension http >/dev/null
|
||||
disable_extension_helper http >/dev/null
|
||||
add_http_helper pecl_http-"${ext##*-}" "$os"
|
||||
status="Installed and enabled"
|
||||
fi
|
||||
|
@ -126,7 +126,7 @@ add_extension_from_source() {
|
||||
step_log "Setup $slug"
|
||||
(
|
||||
add_devtools phpize >/dev/null 2>&1
|
||||
delete_extension "$extension"
|
||||
disable_extension_helper "$extension"
|
||||
fetch_extension "$fetch"
|
||||
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
|
||||
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
|
||||
|
@ -19,37 +19,12 @@ install_packages() {
|
||||
}
|
||||
|
||||
# Function to disable an extension.
|
||||
disable_extension() {
|
||||
disable_extension_helper() {
|
||||
extension=$1
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}"
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "$pecl_file"
|
||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file"
|
||||
sudo find "$ini_dir"/.. -name "*$extension.ini" -delete >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
# Function to delete an extension.
|
||||
delete_extension() {
|
||||
extension=$1
|
||||
disable_extension "$extension"
|
||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||
sudo sed -i "/Package: php$version-$extension/,/^$/d" /var/lib/dpkg/status
|
||||
}
|
||||
|
||||
# Function to disable and delete extensions.
|
||||
remove_extension() {
|
||||
extension=$1
|
||||
if check_extension "$extension"; then
|
||||
if [[ ! "$version" =~ ${old_versions:?} ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
||||
sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1
|
||||
fi
|
||||
delete_extension "$extension"
|
||||
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
|
||||
add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
|
||||
else
|
||||
delete_extension "$extension"
|
||||
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to add PDO extension.
|
||||
add_pdo_extension() {
|
||||
pdo_ext="pdo_$1"
|
||||
@ -59,7 +34,7 @@ add_pdo_extension() {
|
||||
ext=$1
|
||||
ext_name=$1
|
||||
if [ -e "$ext_dir"/pdo.so ]; then
|
||||
disable_extension pdo
|
||||
disable_extension_helper pdo
|
||||
echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}" >/dev/null 2>&1
|
||||
fi
|
||||
if [ "$ext" = "mysql" ]; then
|
||||
|
@ -214,8 +214,8 @@ Function Add-Extension {
|
||||
}
|
||||
}
|
||||
|
||||
# Function to remove PHP extensions.
|
||||
Function Remove-Extension() {
|
||||
# Function to disable an extension.
|
||||
Function Disable-Extension() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
@ -226,12 +226,9 @@ Function Remove-Extension() {
|
||||
if(php -m | findstr -i $extension) {
|
||||
try {
|
||||
Disable-PhpExtension $extension $php_dir
|
||||
if (Test-Path $ext_dir\php_$extension.dll) {
|
||||
Remove-Item $ext_dir\php_$extension.dll
|
||||
}
|
||||
Add-Log $tick ":$extension" "Removed"
|
||||
Add-Log $tick ":$extension" "Disabled"
|
||||
} catch {
|
||||
Add-Log $cross ":$extension" "Could not remove $extension on PHP $($installed.FullVersion)"
|
||||
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
||||
}
|
||||
} else {
|
||||
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
||||
|
Loading…
Reference in New Issue
Block a user