mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01: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,22 +10,46 @@ Param (
|
|||||||
[string]
|
[string]
|
||||||
$version
|
$version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Function Install-Phalcon() {
|
||||||
|
if ($extension_version -eq '4') {
|
||||||
|
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
||||||
|
} else {
|
||||||
|
$installed = Get-Php -Path $php_dir
|
||||||
|
$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)`""
|
||||||
|
$zip_file = $match.Matches[0].Groups[1].Value
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
|
||||||
|
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
|
||||||
|
New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll > $null 2>&1
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
$tick = ([char]8730)
|
$tick = ([char]8730)
|
||||||
$domain = 'https://github.com'
|
$domain = 'https://github.com'
|
||||||
$php_dir = 'C:\tools\php'
|
$php_dir = 'C:\tools\php'
|
||||||
$ext_dir = $php_dir + '\ext'
|
$ext_dir = $php_dir + '\ext'
|
||||||
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
$extension_version = $extension.substring($extension.Length - 1)
|
||||||
if($extension -eq "phalcon4") {
|
|
||||||
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
if($extension_version -eq '4') {
|
||||||
} else {
|
if (Test-Path $ext_dir\php_psr.dll) {
|
||||||
$installed = Get-Php -Path $php_dir
|
Enable-PhpExtension -Extension psr -Path $php_dir
|
||||||
$extension_version = $extension.substring($extension.Length - 1)
|
} else {
|
||||||
$nts = if(! $installed.ThreadSafe ) { "_nts" } else { "" }
|
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
||||||
$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
|
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip >$null 2>&1
|
|
||||||
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force >$null 2>&1
|
|
||||||
New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll >$null 2>&1
|
|
||||||
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"
|
|
||||||
|
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 @@
|
|||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
add_log() {
|
||||||
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
|
mark=$1
|
||||||
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
|
subject=$2
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr
|
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
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
|
update_ppa() {
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
|
if [ "$ppa_updated" = "false" ]; then
|
||||||
for tool in php-config phpize; do
|
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
|
||||||
if [ -e "/usr/bin/$tool$2" ]; then
|
ppa_updated="true"
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$2"
|
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")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
|
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
||||||
|
ppa_updated="false"
|
||||||
|
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
|
fi
|
||||||
done
|
else
|
||||||
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
|
install_phalcon "$1" "$2"
|
||||||
cd php-psr && sudo /usr/bin/phpize"$2"
|
fi
|
||||||
./configure --with-php-config=/usr/bin/php-config"$2"
|
|
||||||
make -j2 && sudo make -j2 install
|
|
||||||
echo "extension=psr.so" >> "$ini_file"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
if [ "$extension_major_version" = "3" ]; then
|
||||||
extension_version=$(apt-cache policy -- *phalcon | grep -i -Po "$extension_major_version\.\d\.\d.*php$2" | head -n 1)
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast -o Dpkg::Options::="--force-overwrite" install -y php"$2"-phalcon="$extension_version"
|
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
|
||||||
brew tap shivammathur/homebrew-phalcon
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
brew install phalcon@"$php_version"_"$extension_major"
|
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 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