@@ -299,7 +299,10 @@ function Package-OpenSSH
299
299
[string ]$NativeHostArch = " x64" ,
300
300
301
301
[ValidateSet (' Debug' , ' Release' , ' ' )]
302
- [string ]$Configuration = " Release"
302
+ [string ]$Configuration = " Release" ,
303
+
304
+ # Copy payload to DestinationPath instead of packaging
305
+ [string ]$DestinationPath = " "
303
306
)
304
307
305
308
[System.IO.DirectoryInfo ] $repositoryRoot = Get-RepositoryRoot
@@ -311,9 +314,8 @@ function Package-OpenSSH
311
314
}
312
315
$buildDir = Join-Path $repositoryRoot (" bin\" + $folderName + " \" + $Configuration )
313
316
$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"
317
+ $payload += " sftp-server.exe" , " scp.exe" , " ssh-shellhost.exe" , " ssh-keygen.exe"
315
318
$payload += " sshd_config" , " install-sshd.ps1" , " uninstall-sshd.ps1"
316
- $payload += " install-sshlsa.ps1" , " uninstall-sshlsa.ps1"
317
319
318
320
$packageName = " OpenSSH-Win64"
319
321
if ($NativeHostArch -eq ' x86' ) {
@@ -343,12 +345,29 @@ function Package-OpenSSH
343
345
}
344
346
}
345
347
346
- Remove-Item ($packageDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
347
- Compress-Archive - Path $packageDir - DestinationPath ($packageDir + ' .zip' )
348
+ if ($DestinationPath -ne " " ) {
349
+ if (Test-Path $DestinationPath ) {
350
+ Remove-Item $DestinationPath \* - Force
351
+ }
352
+ else {
353
+ New-Item - ItemType Directory $DestinationPath | Out-Null
354
+ }
355
+ Copy-Item - Path $packageDir \* - Destination $DestinationPath - Force - Recurse
356
+ }
357
+ else {
358
+ Remove-Item ($packageDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
359
+ Compress-Archive - Path $packageDir - DestinationPath ($packageDir + ' .zip' )
360
+ }
348
361
Remove-Item $packageDir - Recurse - Force - ErrorAction SilentlyContinue
349
362
350
- Remove-Item ($symbolsDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
351
- Compress-Archive - Path $symbolsDir - DestinationPath ($symbolsDir + ' .zip' )
363
+
364
+ if ($DestinationPath -ne " " ) {
365
+ Copy-Item - Path $symbolsDir \* - Destination $DestinationPath - Force - Recurse
366
+ }
367
+ else {
368
+ Remove-Item ($symbolsDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
369
+ Compress-Archive - Path $symbolsDir - DestinationPath ($symbolsDir + ' .zip' )
370
+ }
352
371
Remove-Item $symbolsDir - Recurse - Force - ErrorAction SilentlyContinue
353
372
}
354
373
@@ -436,97 +455,41 @@ function Get-SolutionFile
436
455
437
456
<#
438
457
. Synopsis
439
- Deploy all required files to build a package and create zip file.
458
+ Deploy all required files to a location and install the binaries
440
459
#>
441
- function Deploy-Win32OpenSSHBinaries
460
+ function Install-OpenSSH
442
461
{
443
462
[CmdletBinding ()]
444
463
param
445
- (
464
+ (
446
465
[ValidateSet (' Debug' , ' Release' , ' ' )]
447
466
[string ]$Configuration = " " ,
467
+
448
468
[ValidateSet (' x86' , ' x64' , ' ' )]
449
469
[string ]$NativeHostArch = " " ,
470
+
450
471
[string ]$OpenSSHDir = " $env: SystemDrive \OpenSSH"
451
472
)
452
473
453
- if (-not ( Test-Path - Path $OpenSSHDir - PathType Container) )
474
+ if ($Configuration -eq " " )
454
475
{
455
- $null = New-Item - Path $OpenSSHDir - ItemType Directory - Force - ErrorAction Stop
476
+ $Configuration = ' Release '
456
477
}
457
478
458
- [string ] $platform = $env: PROCESSOR_ARCHITECTURE
459
- if (-not [String ]::IsNullOrEmpty($NativeHostArch ))
479
+ if ($NativeHostArch -eq " " )
460
480
{
461
- $folderName = $NativeHostArch
462
- if ($NativeHostArch -ieq ' x86' )
463
- {
464
- $folderName = " Win32"
465
- }
466
- }
467
- else
468
- {
469
- if ($platform -ieq " AMD64" )
470
- {
471
- $folderName = " x64"
472
- }
473
- else
474
- {
475
- $folderName = " Win32"
476
- }
477
- }
478
-
479
- if ([String ]::IsNullOrEmpty($Configuration ))
480
- {
481
- if ( $folderName -ieq " Win32" )
482
- {
483
- $RealConfiguration = " Debug"
484
- }
485
- else
486
- {
487
- $RealConfiguration = " Release"
481
+ $NativeHostArch = ' x64'
482
+ if ($env: PROCESSOR_ARCHITECTURE -eq ' x86' ) {
483
+ $NativeHostArch = ' x86'
488
484
}
489
485
}
490
- else
491
- {
492
- $RealConfiguration = $Configuration
493
- }
494
486
495
- [System.IO.DirectoryInfo ] $repositoryRoot = Get-RepositoryRoot
496
-
497
- $sourceDir = Join-Path $repositoryRoot.FullName - ChildPath " bin\$folderName \$RealConfiguration "
498
- if ((Get-Service ssh- agent - ErrorAction Ignore) -ne $null ) {
499
- Stop-Service ssh- agent - Force
500
- }
501
- Copy-Item - Path " $sourceDir \*" - Destination $OpenSSHDir - Include * .exe, * .dll - Exclude * unittest* .* - Force - ErrorAction Stop
502
- $sourceDir = Join-Path $repositoryRoot.FullName - ChildPath " contrib\win32\openssh"
503
- Copy-Item - Path " $sourceDir \*" - Destination $OpenSSHDir - Include * .ps1, sshd_config - Exclude AnalyzeCodeDiff.ps1 - Force - ErrorAction Stop
504
- }
505
-
506
- <#
507
- . Synopsis
508
- Deploy all required files to a location and install the binaries
509
- #>
510
- function Install-OpenSSH
511
- {
512
- [CmdletBinding ()]
513
- param
514
- (
515
- [ValidateSet (' Debug' , ' Release' , ' ' )]
516
- [string ]$Configuration = " " ,
517
-
518
- [ValidateSet (' x86' , ' x64' , ' ' )]
519
- [string ]$NativeHostArch = " " ,
520
-
521
- [string ]$OpenSSHDir = " $env: SystemDrive \OpenSSH"
522
- )
523
-
524
- Deploy-Win32OpenSSHBinaries @PSBoundParameters
487
+ Package- OpenSSH - NativeHostArch $NativeHostArch - Configuration $Configuration - DestinationPath $OpenSSHDir
525
488
526
489
Push-Location $OpenSSHDir
527
490
& ( " $OpenSSHDir \install-sshd.ps1" )
528
491
.\ssh-keygen.exe - A
529
- & ( " $OpenSSHDir \install-sshlsa.ps1 " )
492
+
530
493
531
494
# machine will be reboot after Install-openssh anyway
532
495
$machinePath = [Environment ]::GetEnvironmentVariable(' Path' , ' MACHINE' )
0 commit comments