Install VcRedist from GitHub

This commit is contained in:
Shivam Mathur 2020-10-30 11:28:54 +05:30
parent 5d27b8f90e
commit 294f03454a
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 19 additions and 9 deletions

View File

@ -769,6 +769,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
## :package: Dependencies
- [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
- [aaronparker/VcRedist](https://github.com/aaronparker/VcRedist "VcRedist PowerShell package")
- [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions")
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")

View File

@ -79,7 +79,7 @@ Function Add-Printf {
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
} else {
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip"
Invoke-WebRequest -UseBasicParsing -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip"
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force
}
} else {
@ -96,16 +96,24 @@ Function Get-CleanPSProfile {
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
}
# Function to install PhpManager.
Function Install-PhpManager() {
$module_path = "$bin_dir\PhpManager\PhpManager.psm1"
# Function to install a powershell package from GitHub.
Function Install-GitHubPackage() {
param(
[Parameter(Position = 0, Mandatory = $true)]
$package,
[Parameter(Position = 1, Mandatory = $true)]
$psm1_path,
[Parameter(Position = 2, Mandatory = $true)]
$url
)
$module_path = "$bin_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) {
$zip_file = "$bin_dir\PhpManager.zip"
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip' -OutFile $zip_file
$zip_file = "$bin_dir\$package.zip"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
}
Import-Module $module_path
Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path"
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
}
# Function to add PHP extensions.
@ -319,6 +327,7 @@ $cross = ([char]10007)
$php_dir = 'C:\tools\php'
$ext_dir = "$php_dir\ext"
$bin_dir = $php_dir
$github = 'https://github.com'
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
$current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue'
@ -362,7 +371,7 @@ if($env:RUNNER -eq 'self-hosted') {
Add-Printf >$null 2>&1
Step-Log "Setup PhpManager"
Install-PhpManager >$null 2>&1
Install-GitHubPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
Add-Log $tick "PhpManager" "Installed"
Step-Log "Setup PHP"
@ -375,7 +384,7 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
$status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
Install-Module -Name VcRedist -Force
Install-GitHubPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
}
if ($version -match $nightly_version) {
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/Install-PhpNightly.ps1 -OutFile $php_dir\Install-PhpNightly.ps1 > $null 2>&1