Use libre ssl official release binaries (#294)

- Use LibreSSL release binaries. Update paths.target
- Update paths.targets to remove onecore specific changes
- Minor changes
This commit is contained in:
bagajjal 2018-03-29 10:23:05 -07:00 committed by Manoj Ampalam
parent be0a2ff29d
commit 00b869dbd8
3 changed files with 48 additions and 54 deletions

2
.gitignore vendored
View File

@ -36,7 +36,7 @@ sshd
/contrib/win32/openssh/Win32/Debug/libssh/libssh.tlog /contrib/win32/openssh/Win32/Debug/libssh/libssh.tlog
/contrib/win32/openssh/Win32/Debug/libssh /contrib/win32/openssh/Win32/Debug/libssh
/config.h /config.h
/contrib/win32/openssh/LibreSSLSDK /contrib/win32/openssh/LibreSSL
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.

View File

@ -7,8 +7,6 @@ Import-Module $PSScriptRoot\OpenSSHCommonUtils.psm1 -Force
[System.IO.DirectoryInfo] $script:gitRoot = $null [System.IO.DirectoryInfo] $script:gitRoot = $null
[bool] $script:Verbose = $false [bool] $script:Verbose = $false
[string] $script:BuildLogFile = $null [string] $script:BuildLogFile = $null
[string] $script:libreSSLSDKStr = "LibreSSLSDK"
[string] $script:win32OpenSSHPath = $null
<# <#
Called by Write-BuildMsg to write to the build log, if it exists. Called by Write-BuildMsg to write to the build log, if it exists.
#> #>
@ -294,41 +292,37 @@ function Start-OpenSSHBootstrap
} }
} }
function Get-Win32OpenSSHRepo
{
[bool] $silent = -not $script:Verbose
if (-not (Test-Path -Path $script:win32OpenSSHPath -PathType Container))
{
Write-BuildMsg -AsInfo -Message "clone repo Win32-OpenSSH" -Silent:$silent
Push-Location $gitRoot
git clone -q --recursive https://github.com/PowerShell/Win32-OpenSSH.git $script:win32OpenSSHPath
Pop-Location
}
Write-BuildMsg -AsInfo -Message "pull latest from repo Win32-OpenSSH" -Silent:$silent
Push-Location $script:win32OpenSSHPath
git fetch -q origin
git checkout -qf L1-Prod
Pop-Location
}
function Remove-Win32OpenSSHRepo
{
Remove-Item -Path $script:win32OpenSSHPath -Recurse -Force -ErrorAction SilentlyContinue
}
function Copy-LibreSSLSDK function Copy-LibreSSLSDK
{ {
[bool] $silent = -not $script:Verbose [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor `
[Net.SecurityProtocolType]::Tls11 -bor `
[Net.SecurityProtocolType]::Tls
$sourcePath = Join-Path $script:win32OpenSSHPath "contrib\win32\openssh\LibreSSLSDK" $url = 'https://github.com/PowerShell/libressl/releases/latest/'
Write-BuildMsg -AsInfo -Message "copying $sourcePath" -Silent:$silent $request = [System.Net.WebRequest]::Create($url)
Copy-Item -Container -Path $sourcePath -Destination $PSScriptRoot -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable e $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) if($e -ne $null)
{ {
Write-BuildMsg -AsError -ErrorAction Stop -Message "Copy LibreSSLSDK from $sourcePath to $PSScriptRoot failed." 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
@ -405,18 +399,18 @@ function Start-OpenSSHPackage
} }
#copy libcrypto dll #copy libcrypto dll
$libreSSLSDKPath = Join-Path $PSScriptRoot $script:libreSSLSDKStr $libreSSLPath = Join-Path $PSScriptRoot "LibreSSL"
if (-not $NoOpenSSL.IsPresent) if (-not $NoOpenSSL.IsPresent)
{ {
if($OneCore) if($OneCore)
{ {
Copy-Item -Path $(Join-Path $libreSSLSDKPath "Onecore\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop Copy-Item -Path $(Join-Path $libreSSLPath "bin\onecore\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
Copy-Item -Path $(Join-Path $libreSSLSDKPath "Onecore\$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop Copy-Item -Path $(Join-Path $libreSSLPath "bin\onecore\$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop
} }
else else
{ {
Copy-Item -Path $(Join-Path $libreSSLSDKPath "$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop Copy-Item -Path $(Join-Path $libreSSLPath "bin\desktop\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
Copy-Item -Path $(Join-Path $libreSSLSDKPath "$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop Copy-Item -Path $(Join-Path $libreSSLPath "bin\desktop\$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop
} }
} }
@ -482,7 +476,7 @@ function Start-OpenSSHBuild
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot [System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
# Get openssh-portable root # Get openssh-portable root
$script:OpenSSHRoot = Get-Item -Path $repositoryRoot.FullName $script:OpenSSHRoot = Get-Item -Path $repositoryRoot.FullName
$script:gitRoot = split-path $script:OpenSSHRoot $script:gitRoot = split-path $script:OpenSSHRoot
@ -497,17 +491,15 @@ function Start-OpenSSHBuild
{ {
Remove-Item -Path $script:BuildLogFile -force Remove-Item -Path $script:BuildLogFile -force
} }
Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)."
Start-OpenSSHBootstrap -OneCore:$OneCore Start-OpenSSHBootstrap -OneCore:$OneCore
$script:win32OpenSSHPath = join-path $script:gitRoot "Win32-OpenSSH" # Download the LibreSSL
if (-not (Test-Path (Join-Path $PSScriptRoot LibreSSLSDK))) if (-not (Test-Path (Join-Path $PSScriptRoot "LibreSSL")))
{ {
Get-Win32OpenSSHRepo Write-BuildMsg -AsInfo -Message "Download, Copy LibreSSL"
Copy-LibreSSLSDK Copy-LibreSSLSDK
Remove-Win32OpenSSHRepo Write-BuildMsg -AsInfo -Message "LibreSSL copied successfully"
} }
$PathTargets = Join-Path $PSScriptRoot paths.targets $PathTargets = Join-Path $PSScriptRoot paths.targets
@ -553,10 +545,10 @@ function Start-OpenSSHBuild
$xml.Project.PropertyGroup.MinimalCoreWin = 'true' $xml.Project.PropertyGroup.MinimalCoreWin = 'true'
#Use onecore libcrypto binaries #Use onecore libcrypto binaries
$xml.Project.PropertyGroup."LibreSSL-x86-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\x86\' $xml.Project.PropertyGroup."LibreSSL-x86-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\x86\'
$xml.Project.PropertyGroup."LibreSSL-x64-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\x64\' $xml.Project.PropertyGroup."LibreSSL-x64-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\x64\'
$xml.Project.PropertyGroup."LibreSSL-arm-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\arm\' $xml.Project.PropertyGroup."LibreSSL-arm-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\arm\'
$xml.Project.PropertyGroup."LibreSSL-arm64-Path" = '$(SolutionDir)\LibreSSLSDK\onecore\arm64\' $xml.Project.PropertyGroup."LibreSSL-arm64-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\arm64\'
$xml.Save($PathTargets) $xml.Save($PathTargets)
} }
@ -573,6 +565,8 @@ function Start-OpenSSHBuild
{ {
$msbuildCmd = Get-VS2015BuildToolPath $msbuildCmd = Get-VS2015BuildToolPath
} }
Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)."
& "$msbuildCmd" $cmdMsg & "$msbuildCmd" $cmdMsg
$errorCode = $LASTEXITCODE $errorCode = $LASTEXITCODE

View File

@ -4,11 +4,11 @@
<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>
<LibreSSL-Path>$(SolutionDir)\LibreSSLSDK\</LibreSSL-Path> <LibreSSL-Path>$(SolutionDir)\LibreSSL\sdk\</LibreSSL-Path>
<LibreSSL-x86-Path>$(SolutionDir)\LibreSSLSDK\x86\</LibreSSL-x86-Path> <LibreSSL-x86-Path>$(SolutionDir)\LibreSSL\bin\desktop\x86\</LibreSSL-x86-Path>
<LibreSSL-x64-Path>$(SolutionDir)\LibreSSLSDK\x64\</LibreSSL-x64-Path> <LibreSSL-x64-Path>$(SolutionDir)\LibreSSL\bin\desktop\x64\</LibreSSL-x64-Path>
<LibreSSL-arm64-Path>$(SolutionDir)\LibreSSLSDK\arm64\</LibreSSL-arm64-Path> <LibreSSL-arm64-Path>$(SolutionDir)\LibreSSL\bin\desktop\arm64\</LibreSSL-arm64-Path>
<LibreSSL-arm-Path>$(SolutionDir)\LibreSSLSDK\arm\</LibreSSL-arm-Path> <LibreSSL-arm-Path>$(SolutionDir)\LibreSSL\bin\desktop\arm\</LibreSSL-arm-Path>
<UseOpenSSL>true</UseOpenSSL> <UseOpenSSL>true</UseOpenSSL>
<SSLLib>libcrypto.lib;</SSLLib> <SSLLib>libcrypto.lib;</SSLLib>
<WindowsSDKVersion>8.1</WindowsSDKVersion> <WindowsSDKVersion>8.1</WindowsSDKVersion>