diff --git a/scripts/deploy-from-workstation.ps1 b/scripts/deploy-from-workstation.ps1 index f50f6d93..a9814f7a 100644 --- a/scripts/deploy-from-workstation.ps1 +++ b/scripts/deploy-from-workstation.ps1 @@ -200,11 +200,33 @@ function Compress-Gzip { function Get-RegctlPath { $toolRoot = Join-Path $env:LOCALAPPDATA 'CaiWuXiTong\tools' - $regctlPath = Join-Path $toolRoot "regctl-$regctlVersion.exe" + $regctlAsset = 'regctl-windows-amd64.exe' + $regctlExtension = '.exe' + $expectedHash = $regctlSha256 + if ($IsMacOS -and [Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [Runtime.InteropServices.Architecture]::Arm64) { + $regctlAsset = 'regctl-darwin-arm64' + $regctlExtension = '' + $expectedHash = 'f4d536d64d0c3cc1db7400902175a1c314675991d22e87e15c319501a2676d3f' + } + elseif ($IsMacOS) { + $regctlAsset = 'regctl-darwin-amd64' + $regctlExtension = '' + $expectedHash = 'c132fdddda68b9c7584ac19f3b40cd17f71916c2bca8182270ebe65b55198a12' + } + elseif ($IsLinux -and [Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [Runtime.InteropServices.Architecture]::Arm64) { + $regctlAsset = 'regctl-linux-arm64' + $regctlExtension = '' + $expectedHash = 'c4cf231e74cda685f1599f3d866b02b03c572e54b79ec8b062f32070b0ba4587' + } + elseif ($IsLinux) { + $regctlAsset = 'regctl-linux-amd64' + $regctlExtension = '' + } + $regctlPath = Join-Path $toolRoot "regctl-$regctlVersion$regctlExtension" if (Test-Path -LiteralPath $regctlPath) { $actualHash = (Get-FileHash -LiteralPath $regctlPath -Algorithm SHA256).Hash.ToLowerInvariant() - if ($actualHash -eq $regctlSha256) { + if ($actualHash -eq $expectedHash) { return $regctlPath } Remove-Item -LiteralPath $regctlPath -Force @@ -214,11 +236,11 @@ function Get-RegctlPath { $downloadPath = "$regctlPath.download" try { Invoke-WebRequest ` - -Uri "https://github.com/regclient/regclient/releases/download/$regctlVersion/regctl-windows-amd64.exe" ` + -Uri "https://github.com/regclient/regclient/releases/download/$regctlVersion/$regctlAsset" ` -OutFile $downloadPath $actualHash = (Get-FileHash -LiteralPath $downloadPath -Algorithm SHA256).Hash.ToLowerInvariant() - if ($actualHash -ne $regctlSha256) { - throw "regctl 校验失败:预期 $regctlSha256,实际 $actualHash。" + if ($actualHash -ne $expectedHash) { + throw "regctl 校验失败:预期 $expectedHash,实际 $actualHash。" } Move-Item -LiteralPath $downloadPath -Destination $regctlPath -Force }