跳到主要内容

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

浏览文件

package-macos.sh

90 行 · 5.5 KB历史下载
1#!/usr/bin/env bash
2# Build, notarize, and package a Developer ID distribution. No installation.
3set -euo pipefail
4cd "$(dirname "$0")/.."
5if [[ "$(uname -s)" != Darwin || "$(uname -m)" != arm64 ]]; then
6 echo 'The supported release target is Apple Silicon macOS 14+.' >&2; exit 1
7fi
8case "${1:-}" in ''|--from-notarized-app) ;; *) echo 'Usage: scripts/package-macos.sh [--from-notarized-app]' >&2; exit 2 ;; esac
9: "${CAGE_SIGNING_IDENTITY:?Set CAGE_SIGNING_IDENTITY to your Developer ID Application identity.}"
10: "${CAGE_NOTARY_PROFILE:?Set CAGE_NOTARY_PROFILE to a notarytool keychain profile.}"
11notary_credentials=(--keychain-profile "$CAGE_NOTARY_PROFILE")
12if [[ -n "${CAGE_NOTARY_KEYCHAIN:-}" ]]; then
13 notary_credentials+=(--keychain "$CAGE_NOTARY_KEYCHAIN")
14fi
15if [[ "$CAGE_SIGNING_IDENTITY" == - ]]; then echo 'Release packages require a Developer ID identity.' >&2; exit 1; fi
16version="$(tr -d '\n\r' < VERSION)"
17release="$PWD/_output/releases/$version"
18bundle="$PWD/_output/Cage.app"
19mkdir -p "$release"
20if [[ "${1:-}" != --from-notarized-app ]]; then
21 bash scripts/build-app.sh
22 ditto -c -k --keepParent "$bundle" "$release/Cage-notarization.zip"
23 xcrun notarytool submit "$release/Cage-notarization.zip" \
24 "${notary_credentials[@]}" --wait --timeout 20m \
25 --output-format json > "$release/app-notarization.json"
26 node -e 'const r=JSON.parse(require("fs").readFileSync(process.argv[1])); if(r.status!=="Accepted") throw new Error(`Apple notarization: ${r.status}; submission ${r.id}`)' "$release/app-notarization.json"
27 xcrun stapler staple "$bundle"
28fi
29actual_version="$(/usr/libexec/PlistBuddy -c 'Print :CageVersion' "$bundle/Contents/Info.plist")"
30if [[ "$actual_version" != "$version" ]]; then echo 'App version differs from VERSION; rebuild before packaging.' >&2; exit 1; fi
31codesign --verify --deep --strict --verbose=2 "$bundle"
32xcrun stapler validate "$bundle"
33spctl --assess --type execute --verbose=2 "$bundle"
34guest_source="cage-macos-guest-$version-source.tar.gz"
35guest_materials="$bundle/Contents/Resources/guest-os/sources/$guest_source"
36node scripts/guest-os/collect-macos-sshfs-sources.mjs verify "$guest_materials" \
37 "$bundle/Contents/Resources/guest-os/project/cage-sshfs" "$version"
38# Copy only the source frozen by this App build, including the final signed
39# helper hash. Packaging must not substitute newer Homebrew source material.
40cp "$guest_materials" "$release/$guest_source"
41
42stage="$(mktemp -d "$PWD/_output/dmg-stage.XXXXXX")"
43trap 'rm -rf "$stage"' EXIT
44ditto "$bundle" "$stage/Cage.app"
45ln -s /Applications "$stage/Applications"
46cat > "$stage/安装说明 - Read Me.txt" <<'EOF'
47Cage — 本机隔离编码工作区
48
491. 将 Cage.app 拖入 Applications(应用程序)。
502. 从应用程序打开 Cage,设置本地账户,并按首次引导选择客机系统、存储位置和代理。
513. 添加自己的 Clash/Mihomo YAML 订阅或配置并选择节点,创建和启动环境。首次需下载系统镜像和工具,请保持网络连接。
524. 打开项目或新建终端,输入 claude,并在 Cage 浏览器内登录自己的 Claude 账户。
53
54需要 Apple Silicon Mac、macOS 14 或更新版本。无需安装 Go、Node.js 或 Clash。
55代理服务与 Claude 账户需自行准备。具体版本与发布状态以发行说明为准。
56共享项目中的文件修改会直接写回 Mac;请备份重要项目。
57升级前请退出 Cage 并停止环境,再替换应用程序;配置与项目文件会保留。
58
59Drag Cage.app into Applications, then open it from Applications.
60Complete the local account and environment setup, add your own Clash/Mihomo
61YAML subscription or configuration, select a node, and start the environment.
62Initial setup downloads the selected guest system and developer tools.
63Requires Apple Silicon and macOS 14+. Your own proxy and Claude account are required.
64
65入门 / Getting started:
66https://github.com/Lee-xeo/Claude-Cage/blob/main/docs/getting-started.md
67问题反馈 / Issues:
68https://github.com/Lee-xeo/Claude-Cage/issues
69EOF
70artifact="Cage-$version-macos-arm64.dmg"
71hdiutil create -volname Cage -srcfolder "$stage" -ov -format UDZO "$release/$artifact"
72codesign --force --sign "$CAGE_SIGNING_IDENTITY" --timestamp "$release/$artifact"
73xcrun notarytool submit "$release/$artifact" "${notary_credentials[@]}" \
74 --wait --timeout 20m --output-format json > "$release/dmg-notarization.json"
75node -e 'const r=JSON.parse(require("fs").readFileSync(process.argv[1])); if(r.status!=="Accepted") throw new Error(`Apple notarization: ${r.status}; submission ${r.id}`)' "$release/dmg-notarization.json"
76xcrun stapler staple "$release/$artifact"
77xcrun stapler validate "$release/$artifact"
78spctl --assess --type open --context context:primary-signature --verbose=2 "$release/$artifact"
79
80# Distribute the corresponding unmodified Mihomo source beside its executable.
81core_version="$(sed -n 's/^version=//p' scripts/fetch-proxy-core.sh)"
82core_source="mihomo-$core_version-source.tar.gz"
83curl --fail --location --retry 2 --connect-timeout 15 --max-time 180 \
84 "https://github.com/MetaCubeX/mihomo/archive/refs/tags/$core_version.tar.gz" \
85 -o "$release/$core_source.part"
86mv "$release/$core_source.part" "$release/$core_source"
87tar -tzf "$release/$core_source" > /dev/null
88(cd "$release" && shasum -a 256 "$artifact" "$core_source" "$guest_source" > SHA256SUMS)
89node scripts/cleanup-apps.mjs --keep "$bundle" --root "$PWD/_output"
90printf 'Verified release artifacts:\n%s/%s\n%s/%s\n%s/%s\n%s/SHA256SUMS\n' "$release" "$artifact" "$release" "$core_source" "$release" "$guest_source" "$release"