mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Add support for old PHP versions on darwin
This commit is contained in:
parent
d9cf6f5ad6
commit
326dfd1e76
@ -84,6 +84,15 @@ describe('Extension tests', () => {
|
|||||||
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
|
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install -f pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '5.3', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f xdebug-2.2.7');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '5.4', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f xdebug-2.4.1');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '5.5', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
|
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
|
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
|
||||||
|
|
||||||
|
8
dist/index.js
vendored
8
dist/index.js
vendored
@ -2663,7 +2663,13 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
' ' +
|
' ' +
|
||||||
prefix;
|
prefix;
|
||||||
return;
|
return;
|
||||||
case /5\.6xdebug/.test(version_extension):
|
case /5\.3xdebug/.test(version_extension):
|
||||||
|
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
|
||||||
|
break;
|
||||||
|
case /5\.4xdebug/.test(version_extension):
|
||||||
|
install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe;
|
||||||
|
break;
|
||||||
|
case /5\.[5-6]xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
case /7\.0xdebug/.test(version_extension):
|
case /7\.0xdebug/.test(version_extension):
|
||||||
|
44
package-lock.json
generated
44
package-lock.json
generated
@ -711,12 +711,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@typescript-eslint/eslint-plugin": {
|
"@typescript-eslint/eslint-plugin": {
|
||||||
"version": "2.18.0",
|
"version": "2.19.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.18.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.19.0.tgz",
|
||||||
"integrity": "sha512-kuO8WQjV+RCZvAXVRJfXWiJ8iYEtfHlKgcqqqXg9uUkIolEHuUaMmm8/lcO4xwCOtaw6mY0gStn2Lg4/eUXXYQ==",
|
"integrity": "sha512-u7IcQ9qwsB6U806LupZmINRnQjC+RJyv36sV/ugaFWMHTbFm/hlLTRx3gGYJgHisxcGSTnf+I/fPDieRMhPSQQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/experimental-utils": "2.18.0",
|
"@typescript-eslint/experimental-utils": "2.19.0",
|
||||||
"eslint-utils": "^1.4.3",
|
"eslint-utils": "^1.4.3",
|
||||||
"functional-red-black-tree": "^1.0.1",
|
"functional-red-black-tree": "^1.0.1",
|
||||||
"regexpp": "^3.0.0",
|
"regexpp": "^3.0.0",
|
||||||
@ -724,32 +724,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/experimental-utils": {
|
"@typescript-eslint/experimental-utils": {
|
||||||
"version": "2.18.0",
|
"version": "2.19.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.18.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.0.tgz",
|
||||||
"integrity": "sha512-J6MopKPHuJYmQUkANLip7g9I82ZLe1naCbxZZW3O2sIxTiq/9YYoOELEKY7oPg0hJ0V/AQ225h2z0Yp+RRMXhw==",
|
"integrity": "sha512-zwpg6zEOPbhB3+GaQfufzlMUOO6GXCNZq6skk+b2ZkZAIoBhVoanWK255BS1g5x9bMwHpLhX0Rpn5Fc3NdCZdg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.3",
|
"@types/json-schema": "^7.0.3",
|
||||||
"@typescript-eslint/typescript-estree": "2.18.0",
|
"@typescript-eslint/typescript-estree": "2.19.0",
|
||||||
"eslint-scope": "^5.0.0"
|
"eslint-scope": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/parser": {
|
"@typescript-eslint/parser": {
|
||||||
"version": "2.18.0",
|
"version": "2.19.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.18.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.19.0.tgz",
|
||||||
"integrity": "sha512-SJJPxFMEYEWkM6pGfcnjLU+NJIPo+Ko1QrCBL+i0+zV30ggLD90huEmMMhKLHBpESWy9lVEeWlQibweNQzyc+A==",
|
"integrity": "sha512-s0jZoxAWjHnuidbbN7aA+BFVXn4TCcxEVGPV8lWMxZglSs3NRnFFAlL+aIENNmzB2/1jUJuySi6GiM6uACPmpg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/eslint-visitor-keys": "^1.0.0",
|
"@types/eslint-visitor-keys": "^1.0.0",
|
||||||
"@typescript-eslint/experimental-utils": "2.18.0",
|
"@typescript-eslint/experimental-utils": "2.19.0",
|
||||||
"@typescript-eslint/typescript-estree": "2.18.0",
|
"@typescript-eslint/typescript-estree": "2.19.0",
|
||||||
"eslint-visitor-keys": "^1.1.0"
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/typescript-estree": {
|
"@typescript-eslint/typescript-estree": {
|
||||||
"version": "2.18.0",
|
"version": "2.19.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.18.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.0.tgz",
|
||||||
"integrity": "sha512-gVHylf7FDb8VSi2ypFuEL3hOtoC4HkZZ5dOjXvVjoyKdRrvXAOPSzpNRnKMfaUUEiSLP8UF9j9X9EDLxC0lfZg==",
|
"integrity": "sha512-n6/Xa37k0jQdwpUszffi19AlNbVCR0sdvCs3DmSKMD7wBttKY31lhD2fug5kMD91B2qW4mQldaTEc1PEzvGu8w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
@ -3036,9 +3036,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"istanbul-lib-instrument": {
|
"istanbul-lib-instrument": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.1.tgz",
|
||||||
"integrity": "sha512-Nm4wVHdo7ZXSG30KjZ2Wl5SU/Bw7bDx1PdaiIFzEStdjs0H12mOTncn1GVYuqQSaZxpg87VGBRsVRPGD2cD1AQ==",
|
"integrity": "sha512-imIchxnodll7pvQBYOqUu88EufLCU56LMeFPZZM/fJZ1irYcYdqroaV+ACK1Ila8ls09iEYArp+nqyC6lW1Vfg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/core": "^7.7.5",
|
"@babel/core": "^7.7.5",
|
||||||
@ -5524,9 +5524,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ts-jest": {
|
"ts-jest": {
|
||||||
"version": "25.1.0",
|
"version": "25.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.0.tgz",
|
||||||
"integrity": "sha512-1Lf576ulKhbxX5og+tG8udVg/5cgcMLPBxp1iCqbbf6VvUK4gEsgAtzMjl8u98izhLrzKMPB0LxCBKEZ5l19Hw==",
|
"integrity": "sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bs-logger": "0.x",
|
"bs-logger": "0.x",
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.1.1",
|
"@types/jest": "^25.1.1",
|
||||||
"@types/node": "^13.7.0",
|
"@types/node": "^13.7.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.18.0",
|
"@typescript-eslint/eslint-plugin": "^2.19.0",
|
||||||
"@typescript-eslint/parser": "^2.18.0",
|
"@typescript-eslint/parser": "^2.19.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@zeit/ncc": "^0.21.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-prettier": "^6.10.0",
|
"eslint-config-prettier": "^6.10.0",
|
||||||
@ -44,7 +44,7 @@
|
|||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"jest-circus": "^25.1.0",
|
"jest-circus": "^25.1.0",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^25.1.0",
|
"ts-jest": "^25.2.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
@ -32,7 +32,13 @@ export async function addExtensionDarwin(
|
|||||||
' ' +
|
' ' +
|
||||||
prefix;
|
prefix;
|
||||||
return;
|
return;
|
||||||
case /5\.6xdebug/.test(version_extension):
|
case /5\.3xdebug/.test(version_extension):
|
||||||
|
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
|
||||||
|
break;
|
||||||
|
case /5\.4xdebug/.test(version_extension):
|
||||||
|
install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe;
|
||||||
|
break;
|
||||||
|
case /5\.[5-6]xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
case /7\.0xdebug/.test(version_extension):
|
case /7\.0xdebug/.test(version_extension):
|
||||||
|
@ -29,12 +29,18 @@ add_extension() {
|
|||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
elif php -m | grep -i -q -w "$extension"; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
elif ! php -m | grep -i -q -w "$extension"; then
|
||||||
(eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
(eval "$install_command" >/dev/null 2>&1 && echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
(sudo port install php"$nodot_version"-"$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
else
|
||||||
|
(eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +107,7 @@ add_tool() {
|
|||||||
add_extension xml >/dev/null 2>&1
|
add_extension xml >/dev/null 2>&1
|
||||||
elif [ "$tool" = "cs2pr" ]; then
|
elif [ "$tool" = "cs2pr" ]; then
|
||||||
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
||||||
tr -d '\r' < "$tool_path" | sudo tee "$tool_path" >/dev/null 2>&1
|
tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
@ -124,11 +130,13 @@ add_composer_tool() {
|
|||||||
|
|
||||||
# Function to configure PECL
|
# Function to configure PECL
|
||||||
configure_pecl() {
|
configure_pecl() {
|
||||||
for tool in pear pecl; do
|
if [[ ! "$version" =~ $old_versions ]]; then
|
||||||
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
for tool in pear pecl; do
|
||||||
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
done
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to log PECL, it is installed along with PHP
|
# Function to log PECL, it is installed along with PHP
|
||||||
@ -136,27 +144,81 @@ add_pecl() {
|
|||||||
add_log "$tick" "PECL" "Added"
|
add_log "$tick" "PECL" "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup PHP and composer
|
# Function to add PECL when macports is used
|
||||||
setup_php_and_composer() {
|
add_pecl_old() {
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
pecl_version='master'
|
||||||
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
if [ "$1" = "53" ]; then
|
||||||
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
pecl_version='v1.9.5'
|
||||||
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
fi
|
||||||
|
curl -o pear.phar -sSL https://github.com/pear/pearweb_phars/raw/$pecl_version/install-pear-nozlib.phar
|
||||||
|
sudo php pear.phar -d /opt/local/lib/php$1 -b /usr/local/bin && rm -rf pear.phar
|
||||||
|
}
|
||||||
|
|
||||||
|
add_macports() {
|
||||||
|
uri=$(curl -sSL https://github.com/macports/macports-base/releases | grep -Eo "(\/.*Catalina.pkg)" | head -n 1)
|
||||||
|
curl -o port.pkg -sSL https://github.com"$uri"
|
||||||
|
sudo installer -pkg port.pkg -target / && rm -rf port.pkg
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_macports() {
|
||||||
|
while true; do
|
||||||
|
status=0
|
||||||
|
sudo port sync || status=$?
|
||||||
|
if [[ "$status" -eq 0 ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
port_setup_php() {
|
||||||
|
sudo port install php$1 php$1-curl php$1-mbstring php$1-xmlrpc php$1-openssl php$1-opcache
|
||||||
|
sudo cp /opt/local/etc/php$1/php.ini-development /opt/local/etc/php$1/php.ini
|
||||||
|
sudo port select --set php php$1
|
||||||
|
sudo ln -sf /opt/local/bin/* /usr/local/bin
|
||||||
|
add_pecl_old "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup PHP
|
||||||
|
setup_php() {
|
||||||
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
|
step_log "Setup Macports"
|
||||||
|
add_macports >/dev/null 2>&1
|
||||||
|
add_log "$tick" "Macports" "Installed"
|
||||||
|
sync_macports >/dev/null 2>&1
|
||||||
|
add_log "$tick" "Macports" "Synced"
|
||||||
|
|
||||||
|
step_log "Setup PHP"
|
||||||
|
port_setup_php $nodot_version >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
step_log "Setup PHP"
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1
|
||||||
|
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
||||||
|
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
||||||
|
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
version=$1
|
version=$1
|
||||||
|
nodot_version=${1/./}
|
||||||
|
old_versions="5.[3-5]"
|
||||||
|
|
||||||
# Setup PHP and composer
|
# Setup Environment
|
||||||
step_log "Setup PHP"
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
setup_php_and_composer
|
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
|
||||||
|
export TERM=xterm
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup PHP
|
||||||
|
setup_php
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
echo "date.timezone=UTC" >>"$ini_file"
|
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
echo "date.timezone=UTC" >>"$ini_file"
|
||||||
|
ext_dir=$(php -i | grep -Ei "extension_dir => /(usr|opt)" | sed -e "s|.*=> s*||")
|
||||||
|
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 ' ')
|
||||||
add_log "$tick" "PHP" "Installed PHP $semver"
|
|
||||||
configure_pecl
|
configure_pecl
|
||||||
|
add_log "$tick" "PHP" "Installed PHP $semver"
|
Loading…
Reference in New Issue
Block a user