add local-sign variant to baosign.ps1

This commit is contained in:
bunnie 2026-04-13 00:04:14 +08:00
parent 0c23c5e5bc
commit aaad119bcc

View file

@ -16,7 +16,10 @@ param(
[string]$CredentialFile = "beta.json", [string]$CredentialFile = "beta.json",
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
[string]$Target = "bunnie@10.0.245.50:code/csp-tool/" [string]$Target = "bunnie@10.0.245.50:code/csp-tool/",
[Parameter(Mandatory = $false)]
[switch]$Local
) )
# Configuration # Configuration
@ -193,6 +196,7 @@ foreach ($imageSpec in $selectedConfig) {
Write-Status "Signing image..." Write-Status "Signing image..."
Write-Status "Command: $($cargoCmd -join ' ')" Write-Status "Command: $($cargoCmd -join ' ')"
Write-Status "Target SSH: $(if ($Local) { '(skipped, --Local mode)' } else { $TARGET })"
# Execute the signing command # Execute the signing command
& cargo run -- --credential-file "..\credentials\$CredentialFile" --file "..\..\$imagePath" --function-code $functionCode 2>&1 | Tee-Object -Variable result & cargo run -- --credential-file "..\credentials\$CredentialFile" --file "..\..\$imagePath" --function-code $functionCode 2>&1 | Tee-Object -Variable result
@ -218,6 +222,12 @@ foreach ($imageSpec in $selectedConfig) {
} }
# Copy files to SSH target # Copy files to SSH target
if ($Local) {
Write-Warning "Skipping remote copy (--Local flag set)"
Write-Success "Completed processing: $imageName"
$successfulImages++
}
else {
Write-Status "Copying files to remote host..." Write-Status "Copying files to remote host..."
$imgCopySuccess = Copy-ToSSH -LocalPath $imagePath -RemoteTarget $TARGET $imgCopySuccess = Copy-ToSSH -LocalPath $imagePath -RemoteTarget $TARGET
@ -231,7 +241,7 @@ foreach ($imageSpec in $selectedConfig) {
Write-Warning "Partial completion for: $imageName (signing OK, copy failed)" Write-Warning "Partial completion for: $imageName (signing OK, copy failed)"
$failedImages++ $failedImages++
} }
}
} }
else { else {
Write-Error "Failed to sign image: $imageName" Write-Error "Failed to sign image: $imageName"