mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-29 08:44:52 +02:00
Added config option to target a specific version of LibreSSL (#405)
Version of LibreSSL to link to, now needs to be explicitly declared in paths.targets
This commit is contained in:
parent
0d93457a2e
commit
762b888b89
@ -1,15 +1,15 @@
|
|||||||
param (
|
param (
|
||||||
[string]$sourceUrl = "https://github.com/PowerShell/libressl/releases/latest/",
|
[string] $paths_target_file_path,
|
||||||
[string]$zipDir,
|
[string] $destDir,
|
||||||
[string]$destDir,
|
[switch] $override
|
||||||
[switch]$override
|
)
|
||||||
)
|
|
||||||
|
|
||||||
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
|
|
||||||
# Workaround that $PSScriptRoot is not support on ps version 2
|
# Workaround that $PSScriptRoot is not support on ps version 2
|
||||||
if([string]::IsNullOrEmpty($zipDir))
|
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
|
||||||
|
|
||||||
|
if([string]::IsNullOrEmpty($paths_target_file_path))
|
||||||
{
|
{
|
||||||
$zipDir = $PSScriptRoot
|
$paths_target_file_path = Join-Path $PSScriptRoot "paths.targets"
|
||||||
}
|
}
|
||||||
|
|
||||||
if([string]::IsNullOrEmpty($destDir))
|
if([string]::IsNullOrEmpty($destDir))
|
||||||
@ -26,30 +26,36 @@ elseif (Test-Path (Join-Path $destDir "LibreSSL") -PathType Container)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[xml] $buildConfig = Get-Content $paths_target_file_path
|
||||||
|
$version = "V" + $buildConfig.Project.PropertyGroup.LibreSSLVersion
|
||||||
|
|
||||||
|
Write-Host "Downloading LibreSSL version:$version"
|
||||||
|
Write-Host "paths_target_file_path:$paths_target_file_path"
|
||||||
|
Write-Host "destDir:$destDir"
|
||||||
|
Write-Host "override:$override"
|
||||||
|
|
||||||
|
$zip_path = Join-Path $PSScriptRoot "LibreSSL.zip"
|
||||||
|
|
||||||
|
$release_url = "https://github.com/PowerShell/LibreSSL/releases/download/$version/LibreSSL.zip"
|
||||||
|
Write-Host "release_url:$release_url"
|
||||||
|
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor `
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor `
|
||||||
[Net.SecurityProtocolType]::Tls11 -bor `
|
[Net.SecurityProtocolType]::Tls11 -bor `
|
||||||
[Net.SecurityProtocolType]::Tls
|
[Net.SecurityProtocolType]::Tls
|
||||||
|
|
||||||
$request = [System.Net.WebRequest]::Create($sourceUrl)
|
|
||||||
$request.AllowAutoRedirect = $false
|
|
||||||
$request.Timeout = 60000; # 1 mins for the download to complete
|
|
||||||
$response = $request.GetResponse()
|
|
||||||
$release_url = $([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/LibreSSL.zip'
|
|
||||||
$zip_path = Join-Path $zipDir "libressl.zip"
|
|
||||||
|
|
||||||
# Download libressl latest release binaries
|
Remove-Item $zip_path -Force -ErrorAction SilentlyContinue
|
||||||
Remove-Item $zip_path -Force -ErrorAction SilentlyContinue
|
Invoke-WebRequest -Uri $release_url -OutFile $zip_path -UseBasicParsing
|
||||||
(New-Object System.Net.WebClient).DownloadFile($release_url, $zip_path)
|
if(-not (Test-Path $zip_path))
|
||||||
if(-not (Test-Path $zip_path))
|
{
|
||||||
{
|
throw "failed to download LibreSSL version:$version"
|
||||||
throw "failed to download ssl zip file"
|
}
|
||||||
}
|
|
||||||
|
Expand-Archive -Path $zip_path -DestinationPath $destDir -Force -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
# Expand the zip file
|
if($e -ne $null)
|
||||||
Expand-Archive -Path $zip_path -DestinationPath $destDir -Force -ErrorAction SilentlyContinue -ErrorVariable e
|
{
|
||||||
if($e -ne $null)
|
throw "Error when expand zip file. LibreSSL version:$version"
|
||||||
{
|
}
|
||||||
throw "Error when expand zip file"
|
|
||||||
}
|
Remove-Item $zip_path -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
Remove-Item $zip_path -Force -ErrorAction SilentlyContinue
|
Write-Host "Succesfully downloaded LibreSSL version:$version"
|
||||||
|
@ -292,39 +292,6 @@ function Start-OpenSSHBootstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Copy-LibreSSLSDK
|
|
||||||
{
|
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor `
|
|
||||||
[Net.SecurityProtocolType]::Tls11 -bor `
|
|
||||||
[Net.SecurityProtocolType]::Tls
|
|
||||||
|
|
||||||
$url = 'https://github.com/PowerShell/libressl/releases/latest/'
|
|
||||||
$request = [System.Net.WebRequest]::Create($url)
|
|
||||||
$request.AllowAutoRedirect = $false
|
|
||||||
$request.Timeout = 30000; #30 sec
|
|
||||||
$response=$request.GetResponse()
|
|
||||||
$libressl_release_url=$([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/LibreSSL.zip'
|
|
||||||
$libressl_zip_path=Join-Path $script:gitRoot "libressl.zip"
|
|
||||||
|
|
||||||
#download libressl latest release binaries
|
|
||||||
Remove-Item $libressl_zip_path -Force -ErrorAction SilentlyContinue
|
|
||||||
(New-Object System.Net.WebClient).DownloadFile($libressl_release_url, $libressl_zip_path)
|
|
||||||
if(-not (Test-Path $libressl_zip_path))
|
|
||||||
{
|
|
||||||
Write-BuildMsg -AsError -ErrorAction Stop -Message "Unable to download $libressl_release_url to $libressl_zip_path."
|
|
||||||
}
|
|
||||||
|
|
||||||
#copy libressl
|
|
||||||
$openssh_libressl_path=Join-Path $script:OpenSSHRoot "contrib\win32\openssh"
|
|
||||||
Expand-Archive -Path $libressl_zip_path -DestinationPath $openssh_libressl_path -Force -ErrorAction SilentlyContinue -ErrorVariable e
|
|
||||||
if($e -ne $null)
|
|
||||||
{
|
|
||||||
Write-BuildMsg -AsError -ErrorAction Stop -Message "Unable to extract LibreSSL from $libressl_zip_path to $openssh_libressl_path failed."
|
|
||||||
}
|
|
||||||
|
|
||||||
Remove-Item $libressl_zip_path -Force -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
|
|
||||||
function Start-OpenSSHPackage
|
function Start-OpenSSHPackage
|
||||||
{
|
{
|
||||||
[CmdletBinding(SupportsShouldProcess=$false)]
|
[CmdletBinding(SupportsShouldProcess=$false)]
|
||||||
@ -545,14 +512,6 @@ function Start-OpenSSHBuild
|
|||||||
|
|
||||||
Start-OpenSSHBootstrap -OneCore:$OneCore
|
Start-OpenSSHBootstrap -OneCore:$OneCore
|
||||||
|
|
||||||
# Download the LibreSSL
|
|
||||||
if (-not (Test-Path (Join-Path $PSScriptRoot "LibreSSL")))
|
|
||||||
{
|
|
||||||
Write-BuildMsg -AsInfo -Message "Download, Copy LibreSSL"
|
|
||||||
Copy-LibreSSLSDK
|
|
||||||
Write-BuildMsg -AsInfo -Message "LibreSSL copied successfully"
|
|
||||||
}
|
|
||||||
|
|
||||||
$PathTargets = Join-Path $PSScriptRoot paths.targets
|
$PathTargets = Join-Path $PSScriptRoot paths.targets
|
||||||
if ($NoOpenSSL)
|
if ($NoOpenSSL)
|
||||||
{
|
{
|
||||||
@ -624,7 +583,7 @@ function Start-OpenSSHBuild
|
|||||||
|
|
||||||
if ($errorCode -ne 0)
|
if ($errorCode -ne 0)
|
||||||
{
|
{
|
||||||
Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $error."
|
Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $errorCode."
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-BuildMsg -AsInfo -Message "SSH build successful."
|
Write-BuildMsg -AsInfo -Message "SSH build successful."
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<OpenSSH-Src-Path>$(SolutionDir)..\..\..\</OpenSSH-Src-Path>
|
<OpenSSH-Src-Path>$(SolutionDir)..\..\..\</OpenSSH-Src-Path>
|
||||||
<OpenSSH-Bin-Path>$(SolutionDir)..\..\..\bin\</OpenSSH-Bin-Path>
|
<OpenSSH-Bin-Path>$(SolutionDir)..\..\..\bin\</OpenSSH-Bin-Path>
|
||||||
<OpenSSH-Lib-Path>$(SolutionDir)lib\</OpenSSH-Lib-Path>
|
<OpenSSH-Lib-Path>$(SolutionDir)lib\</OpenSSH-Lib-Path>
|
||||||
|
<LibreSSLVersion>2.6.5.1</LibreSSLVersion>
|
||||||
<ZLibVersion>2.1.11</ZLibVersion>
|
<ZLibVersion>2.1.11</ZLibVersion>
|
||||||
<LibreSSL-Path>$(SolutionDir)\LibreSSL\sdk\</LibreSSL-Path>
|
<LibreSSL-Path>$(SolutionDir)\LibreSSL\sdk\</LibreSSL-Path>
|
||||||
<LibreSSL-x86-Path>$(SolutionDir)\LibreSSL\bin\desktop\x86\</LibreSSL-x86-Path>
|
<LibreSSL-x86-Path>$(SolutionDir)\LibreSSL\bin\desktop\x86\</LibreSSL-x86-Path>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user