@@ -290,6 +290,68 @@ function Copy-OpenSSLSDK
290
290
}
291
291
}
292
292
293
+ function Package-OpenSSH
294
+ {
295
+ [CmdletBinding (SupportsShouldProcess = $false )]
296
+ param
297
+ (
298
+ [ValidateSet (' x86' , ' x64' )]
299
+ [string ]$NativeHostArch = " x64" ,
300
+
301
+ [ValidateSet (' Debug' , ' Release' , ' ' )]
302
+ [string ]$Configuration = " Release"
303
+ )
304
+
305
+ [System.IO.DirectoryInfo ] $repositoryRoot = Get-RepositoryRoot
306
+ $repositoryRoot = Get-Item - Path $repositoryRoot.FullName
307
+ $folderName = $NativeHostArch
308
+ if ($NativeHostArch -ieq ' x86' )
309
+ {
310
+ $folderName = " Win32"
311
+ }
312
+ $buildDir = Join-Path $repositoryRoot (" bin\" + $folderName + " \" + $Configuration )
313
+ $payload = " sshd.exe" , " ssh.exe" , " ssh-agent.exe" , " ssh-add.exe" , " sftp.exe"
314
+ $payload += " sftp-server.exe" , " scp.exe" , " ssh-lsa.dll" , " ssh-shellhost.exe" , " ssh-keygen.exe"
315
+ $payload += " sshd_config" , " install-sshd.ps1" , " uninstall-sshd.ps1"
316
+ $payload += " install-sshlsa.ps1" , " uninstall-sshlsa.ps1"
317
+
318
+ $packageName = " OpenSSH-Win64"
319
+ if ($NativeHostArch -eq ' x86' ) {
320
+ $packageName = " OpenSSH-Win32"
321
+ }
322
+
323
+ $packageDir = Join-Path $buildDir $packageName
324
+ Remove-Item $packageDir - Recurse - Force - ErrorAction SilentlyContinue
325
+ New-Item $packageDir - Type Directory | Out-Null
326
+
327
+ $symbolsDir = Join-Path $buildDir ($packageName + ' _Symbols' )
328
+ Remove-Item $symbolsDir - Recurse - Force - ErrorAction SilentlyContinue
329
+ New-Item $symbolsDir - Type Directory | Out-Null
330
+
331
+ foreach ($file in $payload ) {
332
+ if ((-not (Test-Path (Join-Path $buildDir $file )))) {
333
+ Throw " Cannot find $file under $buildDir . Did you run Build-OpenSSH?"
334
+ }
335
+ Copy-Item (Join-Path $buildDir $file ) $packageDir
336
+ if ($file.EndsWith (" .exe" )) {
337
+ $pdb = $file.Replace (" .exe" , " .pdb" )
338
+ Copy-Item (Join-Path $buildDir $pdb ) $symbolsDir
339
+ }
340
+ if ($file.EndsWith (" .dll" )) {
341
+ $pdb = $file.Replace (" .dll" , " .pdb" )
342
+ Copy-Item (Join-Path $buildDir $pdb ) $symbolsDir
343
+ }
344
+ }
345
+
346
+ Remove-Item ($packageDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
347
+ Compress-Archive - Path $packageDir - DestinationPath ($packageDir + ' .zip' )
348
+ Remove-Item $packageDir - Recurse - Force - ErrorAction SilentlyContinue
349
+
350
+ Remove-Item ($symbolsDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
351
+ Compress-Archive - Path $symbolsDir - DestinationPath ($symbolsDir + ' .zip' )
352
+ Remove-Item $symbolsDir - Recurse - Force - ErrorAction SilentlyContinue
353
+ }
354
+
293
355
function Build-OpenSSH
294
356
{
295
357
[CmdletBinding (SupportsShouldProcess = $false )]
@@ -527,4 +589,4 @@ function UnInstall-OpenSSH
527
589
}
528
590
529
591
530
- Export-ModuleMember - Function Build-OpenSSH , Get-BuildLogFile , Install-OpenSSH , UnInstall-OpenSSH
592
+ Export-ModuleMember - Function Build-OpenSSH , Get-BuildLogFile , Install-OpenSSH , UnInstall-OpenSSH , Package - OpenSSH
0 commit comments