跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

prepare-qemu-release.ps1

38 行 · 2.8 KB历史下载
1#requires -Version 7.0
2[CmdletBinding()]
3param([string]$MsysDirectory = $env:CAGE_MSYS2_ROOT)
4. (Join-Path $PSScriptRoot 'windows-common.ps1')
5if (-not $IsWindows) { throw 'Prepare the corresponding runtime sources on Windows.' }
6$repository = Split-Path $PSScriptRoot -Parent
7if (-not $MsysDirectory) {
8 $MsysDirectory = @('C:\msys64', 'D:\msys64') | Where-Object { Test-Path (Join-Path $_ 'ucrt64/bin/pkg-config.exe') } | Select-Object -First 1
9}
10if (-not $MsysDirectory) { throw 'Set CAGE_MSYS2_ROOT to the MSYS2 UCRT64 build environment.' }
11$runtime = Join-Path $repository '_output/windows-deps/qemu-cage'
12& (Join-Path $PSScriptRoot 'build-qemu-windows.ps1') -OutputDirectory $runtime -MsysDirectory $MsysDirectory
13$runtimeIdentity = Get-Content (Join-Path $runtime 'cage-build.json') -Raw | ConvertFrom-Json
14$runtimeManifestHash = (Get-FileHash -LiteralPath (Join-Path $runtime 'cage-build.json') -Algorithm SHA256).Hash
15$collectorHash = (Get-FileHash -LiteralPath (Join-Path $PSScriptRoot 'bundle-qemu-sources.sh') -Algorithm SHA256).Hash + (Get-FileHash -LiteralPath $PSCommandPath -Algorithm SHA256).Hash
16$directory = Join-Path $repository '_output/windows-qemu-sources'
17$archive = Join-Path $directory 'full-source.tar.gz'
18$record = Join-Path $directory 'source-identity.json'
19if ((Test-Path -LiteralPath $record) -and (Test-Path -LiteralPath $archive)) {
20 $identity = Get-Content -LiteralPath $record -Raw | ConvertFrom-Json
21 if ($identity.schema -ne 2 -or $identity.fingerprint -ne $runtimeIdentity.fingerprint -or $identity.runtimeManifestHash -ne $runtimeManifestHash -or $identity.collectorHash -ne $collectorHash -or $identity.sha256 -ne (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash) {
22 throw 'Cached QEMU sources differ from their verified runtime identity.'
23 }
24 Write-Host 'Verified cached QEMU corresponding sources.'
25 return
26}
27New-Item -ItemType Directory -Path $directory -Force | Out-Null
28$savedMsystem, $savedChere, $savedNode = $env:MSYSTEM, $env:CHERE_INVOKING, $env:CAGE_NODE
29try {
30 $env:MSYSTEM = 'UCRT64'; $env:CHERE_INVOKING = '1'
31 $env:CAGE_NODE = Get-BuildCommand @('node.exe', 'node')
32 Invoke-BuildTool (Join-Path $MsysDirectory 'usr/bin/bash.exe') @('-l',
33 (Join-Path $PSScriptRoot 'bundle-qemu-sources.sh'), $repository, $runtime, $archive)
34} finally { $env:MSYSTEM = $savedMsystem; $env:CHERE_INVOKING = $savedChere; $env:CAGE_NODE = $savedNode }
35$identity = @{ schema = 2; fingerprint = $runtimeIdentity.fingerprint; runtimeManifestHash = $runtimeManifestHash; collectorHash = $collectorHash; sha256 = (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash }
36$identity | ConvertTo-Json | Set-Content -LiteralPath "$record.partial" -Encoding utf8
37Move-Item -LiteralPath "$record.partial" -Destination $record -Force
38Write-Host 'Collected and verified QEMU corresponding sources before application signing.'