From 0135ee2ed159c6bd2aa20576d707b277566d8675 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 9 May 2020 07:20:08 +0530 Subject: [PATCH] Fix support for phalcon and gearman --- dist/index.js | 6 +++--- src/extensions.ts | 6 +++--- src/scripts/ext/phalcon.sh | 2 +- src/scripts/ext/phalcon_darwin.sh | 10 +++++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 129b7101..651c2cd9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2657,7 +2657,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): add_script += - 'sh ' + + '\nbash ' + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + ' ' + extension + @@ -2811,7 +2811,7 @@ async function addExtensionLinux(extension_csv, version, pipe) { // match 5.6gearman..7.4gearman case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): command = - 'sh ' + + '\nbash ' + path.join(__dirname, '../src/scripts/ext/gearman.sh') + ' ' + version + @@ -2820,7 +2820,7 @@ async function addExtensionLinux(extension_csv, version, pipe) { // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): add_script += - '\nsh ' + + '\nbash ' + path.join(__dirname, '../src/scripts/ext/phalcon.sh') + ' ' + extension + diff --git a/src/extensions.ts b/src/extensions.ts index f38c565a..c925ad6f 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -98,7 +98,7 @@ export async function addExtensionDarwin( // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): add_script += - 'sh ' + + '\nbash ' + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + ' ' + extension + @@ -267,7 +267,7 @@ export async function addExtensionLinux( // match 5.6gearman..7.4gearman case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): command = - 'sh ' + + '\nbash ' + path.join(__dirname, '../src/scripts/ext/gearman.sh') + ' ' + version + @@ -276,7 +276,7 @@ export async function addExtensionLinux( // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): add_script += - '\nsh ' + + '\nbash ' + path.join(__dirname, '../src/scripts/ext/phalcon.sh') + ' ' + extension + diff --git a/src/scripts/ext/phalcon.sh b/src/scripts/ext/phalcon.sh index 6ae5839d..7a56e3e3 100644 --- a/src/scripts/ext/phalcon.sh +++ b/src/scripts/ext/phalcon.sh @@ -36,7 +36,7 @@ tick="✓" cross="✗" if [ "$extension_major_version" = "4" ]; then - if [ -e "$ext_dir/psr.so" ]; then + if [ -e "$ext_dir/psr.so" ] && ! php -m | grep -i -q -w psr; then echo "extension=psr.so" | sudo tee -a "$ini_file" >/dev/null 2>&1 fi diff --git a/src/scripts/ext/phalcon_darwin.sh b/src/scripts/ext/phalcon_darwin.sh index 0297eed2..d1edf06d 100644 --- a/src/scripts/ext/phalcon_darwin.sh +++ b/src/scripts/ext/phalcon_darwin.sh @@ -13,6 +13,7 @@ add_log() { # Function to install phalcon install_phalcon() { ( + sed -i '' '/extension.*psr/d' "$ini_file" brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1 brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1 sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1 @@ -27,14 +28,17 @@ extension=$1 extension_major=${extension: -1} php_version=$2 semver=$(php -v | head -n 1 | cut -f 2 -d ' ') -ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") +ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then - phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) + phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1) + if php -m | grep -i -q -w psr; then + phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1) + fi if [ "$phalcon_version" != "$extension_major" ]; then install_phalcon else - echo "extension=psr.so" >>"$ini_file" + if ! php -m | grep -i -q -w psr; then echo "extension=psr.so" >>"$ini_file"; fi echo "extension=phalcon.so" >>"$ini_file" add_log "$tick" "$extension" "Enabled" fi