Skip to content

migrate dependencies to vcpkg #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: latestw_all
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
048dbc4
modify dependency retrieval to support vcpkg switch
tgauth Nov 20, 2024
5e8fa5b
start transition to vcpkg
tgauth Dec 5, 2024
831f744
start transition to vcpkg 2
tgauth Dec 9, 2024
dd0941e
add vcpkg folder to .gitignore - build working for static zlib consum…
tgauth Dec 11, 2024
e23a9d3
add custom triplets for static/dynamic dependency specification
tgauth Dec 11, 2024
3e6f6b2
point build to custom triplet file
tgauth Dec 11, 2024
0e0fd5f
start transition to libressl vcpkg - build not working yet
tgauth Dec 11, 2024
d5467b0
temp workaround for config.ps1 bug
tgauth Dec 11, 2024
3d9df11
add libcrypto patch
tgauth Jan 13, 2025
779e4eb
add working poc for all dependencies
tgauth Mar 4, 2025
fd38487
update custom triplet naming in proj files
tgauth Mar 4, 2025
7e9896a
add libressl patch for arm arch
tgauth Mar 19, 2025
b7f822e
use static build for libfido2 and remove unused libressl artifacts
tgauth Mar 19, 2025
bbb2862
update CI to build all 4 architectures
tgauth Mar 19, 2025
3f0c4f9
add vcpkg repo clone to ci
tgauth Mar 19, 2025
5975fce
revert config.ps1 workaround
tgauth Mar 19, 2025
65c64ce
remove dependency version from paths.targets as they are in vcpkg.jso…
tgauth Mar 19, 2025
27449d5
Update OpenSSHBuildHelper.psm1
tgauth Mar 19, 2025
0fb694c
revert accidental change to filters file
tgauth Apr 10, 2025
aeb6969
add comp flags
tgauth May 13, 2025
13ec6c6
Merge branch 'latestw_all' into vcpkg-test
tgauth May 13, 2025
6b013b9
update build files
tgauth May 14, 2025
497e97a
Delete OpenSSH-arm_symbols/OpenSSHUtils.psm1
tgauth Jun 2, 2025
12acc67
update build script libcrypto onecore steps
tgauth Jun 2, 2025
e79d60d
Update fix_cmakelists.patch
tgauth Jun 2, 2025
089632e
Update x64-custom.cmake
tgauth Jun 2, 2025
8120bf3
update libressl port
tgauth Jun 2, 2025
3587179
revert libcbor version update for now
tgauth Jun 3, 2025
972a4b3
fix typo
tgauth Jun 3, 2025
b7b74ce
Delete contrib/win32/openssh/vcpkg_overlay_ports/libressl/modify-name…
tgauth Jun 3, 2025
9f52492
fix path to version file
tgauth Jun 3, 2025
41fcede
Update AzDOBuildTools.psm1
tgauth Jun 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 46 additions & 18 deletions .azdo/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,32 @@ stages:
- ImageOverride -equals PSMMS2022-OpenSSH-Secure

steps:
- powershell: |
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
./install-powershell.ps1 -Destination $powerShellPath
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Install PowerShell Core

- pwsh: |
# Compare LibreSSL versions in vcpkg.json and add-resource-file.patch
$vcpkgObj = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg.json" | ConvertFrom-Json
$libresslVersionJson = $vcpkgObj | Select-Object -ExpandProperty overrides | Where-Object { $_.name -eq 'libressl' } | Select-Object -ExpandProperty version

# resource file version needs to be trimmed (e.g. 4.0.0.0 to 4.0.0)
$patchContent = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_overlay_ports/libressl/add-version-file.patch"
$libresslVersionPatch = ($patchContent -join "`n" | Select-String -Pattern '"FileVersion",\s*"(\d+\.\d+\.\d+\.\d+)"' -AllMatches).Matches | ForEach-Object { $_.Groups[1].Value }
$libresslVersionPatchParts = $libresslVersionPatch -split '\.'
$libresslVersionPatchShort = ($libresslVersionPatchParts[0..2] -join '.')

if ($libresslVersionJson -ne $libresslVersionPatchShort) {
Write-Error "LibreSSL version mismatch: vcpkg.json has $libresslVersionJson, patch file has $libresslVersionPatch"
exit 1
} else {
Write-Verbose -Verbose "LibreSSL versions match: $libresslVersionJson"
}
displayName: 'Verify version info'

- pwsh: |-
git clone https://github.com/microsoft/vcpkg
cd vcpkg
& ./bootstrap-vcpkg.bat
& ./vcpkg.exe integrate install
displayName: Install vcpkg

- pwsh: |
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
Invoke-AzDOBuild
Expand Down Expand Up @@ -81,6 +98,26 @@ stages:
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$configFilePath"
displayName: Upload Win32-OpenSSH build artifacts

- pwsh: |
$logFileNames = @("OpenSSHReleasex64.log", "OpenSSHReleasex86.log")
$uniqueLines = [System.Collections.Generic.HashSet[string]]::new()
forEach ($logFile in $logFileNames) {
$logFilePath = "$(Build.SourcesDirectory)/contrib/win32/openssh/$logFile"
$logLines = Get-Content $logFilePath
$buildSucceededIndex = $logLines.IndexOf("Build succeeded.")
$linesToCheck = $logLines[($buildSucceededIndex + 1)..$logLines.Length]
forEach ($line in $linesToCheck) {
if ($line -match "warning C") {
$uniqueLines.Add($line) | Out-Null
}
}
}
forEach ($uniqueLine in $uniqueLines) {
Write-Output $uniqueLine
Write-Host "##vso[task.logissue type=warning]$uniqueLine"
}
displayName: Surface Warnings from Build Logs

- stage: Test
displayName: Test Win32-OpenSSH
dependsOn: Build
Expand All @@ -92,15 +129,6 @@ stages:
variables:
testFilesDrivePath: '**'
steps:
- powershell: |
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
./install-powershell.ps1 -Destination $powerShellPath
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Install PowerShell Core'

- task: DownloadBuildArtifacts@0
displayName: 'Download build artifacts'
inputs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tags
/contrib/win32/openssh/LibreSSL
/contrib/win32/openssh/ZLib
/contrib/win32/openssh/libfido2
/contrib/win32/openssh/vcpkg_installed
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

Expand Down
30 changes: 15 additions & 15 deletions contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Invoke-AzDOBuild
function Install-OpenSSH
{
[CmdletBinding()]
param (
param (
[Parameter(Mandatory=$true)]
[string]$SourceDir,

Expand All @@ -62,7 +62,7 @@ function Install-OpenSSH

Copy-Item -Path "$SourceDir/*" -Destination $OpenSSHDir -Recurse -Force -Verbose

Push-Location $OpenSSHDir
Push-Location $OpenSSHDir

try
{
Expand All @@ -81,8 +81,8 @@ function Install-OpenSSH
{
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
}
Start-Service -Name sshd

Start-Service -Name sshd
Start-Service -Name ssh-agent
}
finally
Expand All @@ -100,7 +100,7 @@ function Install-OpenSSH
function UnInstall-OpenSSH
{
[CmdletBinding()]
param (
param (
[string]$OpenSSHDir = "$env:SystemDrive\OpenSSH"
)

Expand All @@ -117,15 +117,15 @@ function UnInstall-OpenSSH
Stop-Service ssh-agent -Force
}
& "$OpenSSHDir\uninstall-sshd.ps1"

$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
$newMachineEnvironmentPath = $machinePath
if ($machinePath.ToLower().Contains($OpenSSHDir.ToLower()))
{
{
$newMachineEnvironmentPath = $newMachineEnvironmentPath.Replace("$OpenSSHDir;", '')
$env:Path = $env:Path.Replace("$OpenSSHDir;", '')
}

if ($newMachineEnvironmentPath -ne $machinePath)
{
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
Expand All @@ -136,7 +136,7 @@ function UnInstall-OpenSSH
Pop-Location
}

Remove-Item -Path $OpenSSHDir -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path $OpenSSHDir -Recurse -Force -ErrorAction SilentlyContinue
}

#
Expand Down Expand Up @@ -181,7 +181,7 @@ function Invoke-OpenSSHTests
}

$xml = [xml](Get-Content $OpenSSHTestInfo["SetupTestResultsFile"] | out-string)
if ([int]$xml.'test-results'.failures -gt 0)
if ([int]$xml.'test-results'.failures -gt 0)
{
$errorMessage = "$($xml.'test-results'.failures) Setup Tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["SetupTestResultsFile"])."
Write-BuildMessage -Message $errorMessage -Category Error
Expand Down Expand Up @@ -306,7 +306,7 @@ function Invoke-OpenSSHTests
else
{
$xml = [xml](Get-Content $OpenSSHTestInfo["UninstallTestResultsFile"] | out-string)
if ([int]$xml.'test-results'.failures -gt 0)
if ([int]$xml.'test-results'.failures -gt 0)
{
$errorMessage = "$($xml.'test-results'.failures) uninstall tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["UninstallTestResultsFile"])."
Write-BuildMessage -Message $errorMessage -Category Error
Expand All @@ -318,7 +318,7 @@ function Invoke-OpenSSHTests
$OpenSSHTestInfo | Export-Clixml -Path "$repoRoot/OpenSSHTestInfo.xml" -Depth 10

# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
if ($Error.Count -gt 0)
if ($Error.Count -gt 0)
{
Write-BuildMessage -Message "Tests Should always clean $Error variable after success." -Category Warning
}
Expand All @@ -339,7 +339,7 @@ function Invoke-OpenSSHTests
Collect OpenSSH pester test results into one directory
#>
function Copy-OpenSSHTestResults
{
{
param (
[Parameter(Mandatory=$true)]
[string] $ResultsPath
Expand All @@ -352,7 +352,7 @@ function Copy-OpenSSHTestResults

Write-Verbose -Verbose "Creating test results directory for artifacts upload: $ResultsPath"
$null = New-Item -Path $ResultsPath -ItemType Directory -Force

if (! (Test-Path -Path $ResultsPath))
{
Write-BuildMessage -Message "Unable to write to test results path for test artifacts upload: $ResultsPath" -Category Error
Expand Down Expand Up @@ -498,7 +498,7 @@ function Copy-UnitTests
function Install-UnitTests
{
[CmdletBinding()]
param (
param (
[Parameter(Mandatory=$true)]
[string]$SourceDir,

Expand Down
21 changes: 4 additions & 17 deletions contrib/win32/openssh/OpenSSHBuildHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,12 @@ function Start-OpenSSHPackage
}

#copy libcrypto dll
$libreSSLPath = Join-Path $PSScriptRoot "LibreSSL"
$libreSSLPath = Join-Path $PSScriptRoot "vcpkg_installed"
if (-not $NoOpenSSL.IsPresent)
{
if($OneCore)
{
Copy-Item -Path $(Join-Path $libreSSLPath "bin\onecore\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
Copy-Item -Path $(Join-Path $libreSSLPath "bin\onecore\$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop
}
else
{
Copy-Item -Path $(Join-Path $libreSSLPath "bin\desktop\$NativeHostArch\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
Copy-Item -Path $(Join-Path $libreSSLPath "bin\desktop\$NativeHostArch\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop
}
$subPath = $NativeHostArch + "-custom\" + $NativeHostArch + "-custom\bin\"
Copy-Item -Path $(Join-Path $libreSSLPath "$subPath\libcrypto.dll") -Destination $packageDir -Force -ErrorAction Stop
Copy-Item -Path $(Join-Path $libreSSLPath "$subPath\libcrypto.pdb") -Destination $symbolsDir -Force -ErrorAction Stop
}

if ($DestinationPath -ne "") {
Expand Down Expand Up @@ -554,12 +547,6 @@ function Start-OpenSSHBuild
$xml.Project.PropertyGroup.AdditionalDependentLibs = 'onecore.lib;shlwapi.lib'
$xml.Project.PropertyGroup.MinimalCoreWin = 'true'

#Use onecore libcrypto binaries
$xml.Project.PropertyGroup."LibreSSL-x86-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\x86\'
$xml.Project.PropertyGroup."LibreSSL-x64-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\x64\'
$xml.Project.PropertyGroup."LibreSSL-arm-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\arm\'
$xml.Project.PropertyGroup."LibreSSL-arm64-Path" = '$(SolutionDir)\LibreSSL\bin\onecore\arm64\'

$xml.Save($PathTargets)
}

Expand Down
Loading