mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix caching PDO extensions on linux
This commit is contained in:
parent
b7d68d8225
commit
58f376b118
@ -35,15 +35,15 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
let linux: string = await extensions.addExtension(
|
let linux: string = await extensions.addExtension(
|
||||||
'xdebug, pcov, ast-beta, xdebug-alpha, grpc-1.2.3',
|
'xdebug, pcov, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('update_extension xdebug 2.9.1');
|
expect(linux).toContain('update_extension xdebug 2.9.1');
|
||||||
expect(linux).toContain(
|
expect(linux).toContain('sudo $debconf_fix 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_pdo_extension mysql');
|
||||||
|
expect(linux).toContain('add_pdo_extension odbc');
|
||||||
expect(linux).toContain('add_pecl_extension grpc 1.2.3 extension');
|
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'
|
||||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -2917,12 +2917,18 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
'\n' +
|
'\n' +
|
||||||
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||||
return;
|
return;
|
||||||
|
// match pdo extensions
|
||||||
|
case /.*pdo[_-].*/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nadd_pdo_extension ' +
|
||||||
|
extension.replace('pdo_', '').replace('pdo-', '');
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
install_command =
|
install_command =
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
'sudo $debconf_fix apt-get install -y php' +
|
||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
extension +
|
||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -241,12 +241,18 @@ export async function addExtensionLinux(
|
|||||||
'\n' +
|
'\n' +
|
||||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||||
return;
|
return;
|
||||||
|
// match pdo extensions
|
||||||
|
case /.*pdo[_-].*/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nadd_pdo_extension ' +
|
||||||
|
extension.replace('pdo_', '').replace('pdo-', '');
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
install_command =
|
install_command =
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
'sudo $debconf_fix apt-get install -y php' +
|
||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
extension +
|
||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,7 @@ get_pecl_version() {
|
|||||||
|
|
||||||
# Function to test if extension is loaded
|
# Function to test if extension is loaded
|
||||||
check_extension() {
|
check_extension() {
|
||||||
extension=$1
|
php -m | grep -i -q -w "$1"
|
||||||
php -m | grep -i -q -w "$extension"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to delete extensions
|
# Function to delete extensions
|
||||||
@ -77,6 +76,32 @@ remove_extension() {
|
|||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to enable existing extension
|
||||||
|
enable_extension() {
|
||||||
|
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
|
||||||
|
echo "$2=$1.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Funcion to add PDO extension
|
||||||
|
add_pdo_extension() {
|
||||||
|
pdo_ext="pdo_$1"
|
||||||
|
if check_extension "$pdo_ext"; then
|
||||||
|
add_log "$tick" "$pdo_ext" "Enabled"
|
||||||
|
else
|
||||||
|
read -r ext ext_name <<< "$1 $1"
|
||||||
|
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1 && enable_extension "pdo" "extension" >/dev/null 2>&1
|
||||||
|
if [ "$ext" = "mysql" ]; then
|
||||||
|
enable_extension "mysqlnd" "extension"
|
||||||
|
ext_name="mysqli"
|
||||||
|
fi
|
||||||
|
add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1
|
||||||
|
enable_extension "$pdo_ext" "extension"
|
||||||
|
(check_extension "$pdo_ext" && add_log "$tick" "$pdo_ext" "Enabled") ||
|
||||||
|
add_log "$cross" "$pdo_ext" "Could not install $pdo_ext on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to setup extensions
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
@ -85,11 +110,10 @@ add_extension() {
|
|||||||
if [[ "$version" =~ $old_versions ]]; then
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
|
install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
|
||||||
fi
|
fi
|
||||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
enable_extension "$extension" "$prefix"
|
||||||
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
if check_extension "$extension"; then
|
||||||
elif check_extension "$extension"; then
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! check_extension "$extension"; then
|
else
|
||||||
eval "$install_command" >/dev/null 2>&1 ||
|
eval "$install_command" >/dev/null 2>&1 ||
|
||||||
(update_ppa && 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
|
sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||||
|
Loading…
Reference in New Issue
Block a user