aisop/tools/Deploy-Linux.ps1

32 lines
2.0 KiB
PowerShell

param(
[string]$Target = 'wl@192.168.5.200'
)
$ErrorActionPreference = 'Stop'
if ($Target -notmatch '^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+$') { throw 'Target must be user@host' }
$repo = Split-Path $PSScriptRoot -Parent
$release = 'avalonia-' + (Get-Date -Format 'yyyyMMdd-HHmmss')
$output = Join-Path $repo "artifacts/$release"
& dotnet publish (Join-Path $repo 'src/SopHelper.Avalonia') -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=false -p:NativePlatform=Linux -o $output --nologo
if ($LASTEXITCODE) { throw 'Publish failed' }
$sdkExpected=Join-Path $repo 'libs/mvs/linux-x64/MvCameraControl.Net.dll'
if ((Get-FileHash $sdkExpected).Hash -ne (Get-FileHash (Join-Path $output 'MvCameraControl.Net.dll')).Hash) {
throw 'Linux package contains the wrong MVS managed binding'
}
$archive = Join-Path $repo "artifacts/$release.tar.gz"
& tar -czf $archive -C $output .
if ($LASTEXITCODE) { throw 'Packaging failed' }
& ssh -o BatchMode=yes $Target "mkdir -p ~/sophelper/releases/$release ~/sophelper/models"
if ($LASTEXITCODE) { throw 'SSH failed' }
& scp -o BatchMode=yes $archive (Join-Path $PSScriptRoot 'linux/install-desktop.sh') "${Target}:sophelper/"
if ($LASTEXITCODE) { throw 'Transfer failed' }
$models = @('yolo11n.onnx','palm_detection_full_Nx3x192x192_post.onnx','hand_landmark_sparse_Nx3x224x224.onnx')
foreach ($model in $models) {
$path = Join-Path $repo "models/$model"
if (!(Test-Path $path)) { throw "Missing model: $path" }
& scp -o BatchMode=yes $path "${Target}:sophelper/models/"
if ($LASTEXITCODE) { throw "Model transfer failed: $model" }
}
& ssh -o BatchMode=yes $Target "tar -xzf ~/sophelper/$release.tar.gz -C ~/sophelper/releases/$release && chmod +x ~/sophelper/releases/$release/SopHelper.Avalonia && ~/sophelper/releases/$release/SopHelper.Avalonia --check-runtime && bash ~/sophelper/install-desktop.sh ~/sophelper/releases/$release"
if ($LASTEXITCODE) { throw 'Installation or self-test failed; see ~/sophelper/workspace/logs/desktop.log' }
Write-Host "Installed $release on $Target. Start SopHelper from its desktop launcher."