mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Refactor scripts to enable pre-existing ext-phalcon
This commit is contained in:
parent
898b6fa1f9
commit
63c4aea452
@ -52,6 +52,10 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
expect(linux).toContain('Platform fedora is not supported');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
||||||
|
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
||||||
|
expect(linux).toContain('phalcon.sh phalcon4 7.3');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addExtensionOnDarwin', async () => {
|
it('checking addExtensionOnDarwin', async () => {
|
||||||
|
9
dist/index.js
vendored
9
dist/index.js
vendored
@ -2703,6 +2703,15 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
version +
|
version +
|
||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nsh ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
||||||
|
' ' +
|
||||||
|
extension +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
// match 7.0xdebug..7.4xdebug
|
// match 7.0xdebug..7.4xdebug
|
||||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||||
script +=
|
script +=
|
||||||
|
@ -128,6 +128,15 @@ export async function addExtensionLinux(
|
|||||||
version +
|
version +
|
||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nsh ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
||||||
|
' ' +
|
||||||
|
extension +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
// match 7.0xdebug..7.4xdebug
|
// match 7.0xdebug..7.4xdebug
|
||||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||||
script +=
|
script +=
|
||||||
|
@ -10,16 +10,12 @@ Param (
|
|||||||
[string]
|
[string]
|
||||||
$version
|
$version
|
||||||
)
|
)
|
||||||
$tick = ([char]8730)
|
|
||||||
$domain = 'https://github.com'
|
Function Install-Phalcon() {
|
||||||
$php_dir = 'C:\tools\php'
|
if ($extension_version -eq '4') {
|
||||||
$ext_dir = $php_dir + '\ext'
|
|
||||||
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
|
||||||
if($extension -eq "phalcon4") {
|
|
||||||
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
||||||
} else {
|
} else {
|
||||||
$installed = Get-Php -Path $php_dir
|
$installed = Get-Php -Path $php_dir
|
||||||
$extension_version = $extension.substring($extension.Length - 1)
|
|
||||||
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
||||||
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
|
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
|
||||||
$zip_file = $match.Matches[0].Groups[1].Value
|
$zip_file = $match.Matches[0].Groups[1].Value
|
||||||
@ -29,3 +25,31 @@ if($extension -eq "phalcon4") {
|
|||||||
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
||||||
}
|
}
|
||||||
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
$tick = ([char]8730)
|
||||||
|
$domain = 'https://github.com'
|
||||||
|
$php_dir = 'C:\tools\php'
|
||||||
|
$ext_dir = $php_dir + '\ext'
|
||||||
|
$extension_version = $extension.substring($extension.Length - 1)
|
||||||
|
|
||||||
|
if($extension_version -eq '4') {
|
||||||
|
if (Test-Path $ext_dir\php_psr.dll) {
|
||||||
|
Enable-PhpExtension -Extension psr -Path $php_dir
|
||||||
|
} else {
|
||||||
|
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Test-Path $ext_dir\php_phalcon.dll) {
|
||||||
|
$phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll
|
||||||
|
if($phalcon.Version[0] -eq $extension_version) {
|
||||||
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
||||||
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Enabled"
|
||||||
|
} else {
|
||||||
|
Remove-Item $ext_dir\php_phalcon.dll
|
||||||
|
Install-Phalcon
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Install-Phalcon
|
||||||
|
}
|
@ -1,22 +1,78 @@
|
|||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_ppa() {
|
||||||
|
if [ "$ppa_updated" = "false" ]; then
|
||||||
|
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-get update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||||
|
ppa_updated="true"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_phalcon() {
|
||||||
|
extension=$1
|
||||||
|
version=$2
|
||||||
|
(sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_extension() {
|
||||||
|
extension=$1
|
||||||
|
sudo sed -i "/$extension/d" "$ini_file"
|
||||||
|
rm -rf "$ext_dir/$extension.so"
|
||||||
|
}
|
||||||
|
|
||||||
ini_file=$(php --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")
|
||||||
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr
|
|
||||||
|
|
||||||
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
|
|
||||||
for tool in php-config phpize; do
|
|
||||||
if [ -e "/usr/bin/$tool$2" ]; then
|
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$2"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
|
|
||||||
cd php-psr && sudo /usr/bin/phpize"$2"
|
|
||||||
./configure --with-php-config=/usr/bin/php-config"$2"
|
|
||||||
make -j2 && sudo make -j2 install
|
|
||||||
echo "extension=psr.so" >> "$ini_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
||||||
extension_version=$(apt-cache policy -- *phalcon | grep -i -Po "$extension_major_version\.\d\.\d.*php$2" | head -n 1)
|
ppa_updated="false"
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast -o Dpkg::Options::="--force-overwrite" install -y php"$2"-phalcon="$extension_version"
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
|
||||||
|
if [ "$extension_major_version" = "4" ]; then
|
||||||
|
if [ -e "$ext_dir/psr.so" ]; then
|
||||||
|
echo "extension=psr" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
|
if php -m | grep -i -q -w psr; then
|
||||||
|
echo "extension=phalcon" >>"$ini_file"
|
||||||
|
phalcon_version=$(php -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
|
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
||||||
|
remove_extension "psr" >/dev/null 2>&1
|
||||||
|
remove_extension "phalcon" >/dev/null 2>&1
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
else
|
||||||
|
add_log "$tick" "$1" "Enabled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$extension_major_version" = "3" ]; then
|
||||||
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
|
echo "extension=phalcon" >>"$ini_file"
|
||||||
|
phalcon_version=$(php -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
|
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
||||||
|
remove_extension "phalcon" >/dev/null 2>&1
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
else
|
||||||
|
add_log "$tick" "$1" "Enabled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
extension=$1
|
extension=$1
|
||||||
extension_major=${extension: -1}
|
extension_major=${extension: -1}
|
||||||
php_version=$2
|
php_version=$2
|
||||||
|
ini_file=$(php -d "date.timezone=UTC" --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
|
||||||
|
echo "extension=psr" >>"$ini_file"
|
||||||
|
echo "extension=phalcon" >>"$ini_file"
|
||||||
|
phalcon_semver=$(php -r "echo phpversion('phalcon');")
|
||||||
|
phalcon_version=$(echo "$phalcon_semver" | cut -d'.' -f 1)
|
||||||
|
if [ "$phalcon_version" != "$extension_major" ]; then
|
||||||
|
sudo sed -i '' "/psr/d" "$ini_file"
|
||||||
|
sudo sed -i '' "/phalcon/d" "$ini_file"
|
||||||
|
rm -rf "$ext_dir"/psr.so
|
||||||
|
rm -rf "$ext_dir"/phalcon.so
|
||||||
brew tap shivammathur/homebrew-phalcon
|
brew tap shivammathur/homebrew-phalcon
|
||||||
brew install phalcon@"$php_version"_"$extension_major"
|
brew install phalcon@"$php_version"_"$extension_major"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
brew tap shivammathur/homebrew-phalcon
|
||||||
|
brew install phalcon@"$php_version"_"$extension_major"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user