跳到主要内容

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

提交记录
修改.github/workflows/macos-build.yml+3 −1看文件
@@ -53,7 +53,9 @@ jobs:
5353 cache-dependency-path: ui/package-lock.json
5454 - uses: astral-sh/[email protected]
5555 - name: Application version consistency
56删除: run: node scripts/check-version.mjs
56新增: run: |
57新增: node scripts/check-version.mjs
58新增: node --test scripts/macos-sshfs-sources.test.mjs
5759 - name: Build the macOS application without release credentials
5860 env:
5961 CAGE_SIGNING_IDENTITY: '-'
修改NOTICE+7 −0看文件
@@ -7,6 +7,13 @@ noVNC (MPL-2.0, including the modifications in internal/cage/novnc-patch.py),
77and the separately executed Mihomo core (GPL-3.0).
88Their license texts and source notices are distributed in Contents/Resources/licenses.
99Mihomo's corresponding source is distributed alongside the macOS release.
10新增:The macOS guest also includes Cage-modified SSHFS (GNU GPL version 2), with
11新增:statically linked GLib and GNU gettext libintl (LGPL-2.1-or-later), and PCRE2
12新增:(BSD-3-Clause WITH PCRE2-exception, and SLJIT under BSD-2-Clause). Their license
13新增:texts are in Contents/Resources/licenses/sshfs.
14新增:Their complete corresponding source, patches, build recipes and static relink
15新增:materials are in the cage-macos-guest-VERSION-source.tar.gz release asset,
16新增:also retained in Contents/Resources/guest-os/sources inside the macOS App.
1017The root MIT license does not replace these third-party license terms.
1118
1219agent-vm
修改docs/releases/v0.1.7-rc.1.md+2 −0看文件
@@ -54,3 +54,5 @@
5454- 真实账号授权、特定主机权限、音频设备、显示缩放、第三方输入法以及手机网络环境仍可能有差异。自动化、构建及隔离网络测试不等于所有设备组合的实机验收。
5555
5656完整使用说明见 [Cage 使用文档](https://lee-xeo.github.io/Claude-Cage/docs/)。本版本公开安装包、校验清单与对应源码以本发行条目的附件为准。
57新增:
58新增:[查看相较 v0.1.6-alpha-preview 的完整提交对比](https://github.com/Lee-xeo/Claude-Cage/compare/v0.1.6-alpha-preview...v0.1.7-rc.1)。
修改scripts/build-app.sh+2 −0看文件
@@ -60,6 +60,8 @@ cp _output/bin/cage "$bundle/Contents/Resources/cage"
6060if [[ "$(uname -m)" == arm64 ]]; then "$bundle/Contents/Resources/cage" verify-macos-guest; fi
6161if [[ "$(uname -m)" == arm64 ]]; then
6262 bash scripts/guest-os/package-macos-guest.sh "$bundle/Contents/Resources/guest-os"
63新增: mkdir -p "$bundle/Contents/Resources/licenses/sshfs"
64新增: cp -R "$bundle/Contents/Resources/guest-os/licenses/sshfs/." "$bundle/Contents/Resources/licenses/sshfs/"
6365 # The kit signs all nested native code before this outer App is sealed.
6466 # Do not generate or reuse an unsigned component manifest here: installation
6567 # hashes the final signed kit, including each nested bundle's CodeResources.
修改scripts/guest-os/build-macos-sshfs.sh+8 −22看文件
@@ -2,29 +2,15 @@
22# Build the FSKit-compatible SSHFS against the SDK from the signed macFUSE
33# installer. Pass its extracted usr/local directory; no host driver is installed.
44set -euo pipefail
5删除:[[ $# == 2 && $(uname -sm) == 'Darwin arm64' ]] || { echo 'Usage: build-macos-sshfs.sh /absolute/macfuse-sdk/usr/local /absolute/cage-sshfs' >&2; exit 2; }
5新增:[[ ( $# == 2 || $# == 3 ) && $(uname -sm) == 'Darwin arm64' ]] || { echo 'Usage: build-macos-sshfs.sh /absolute/macfuse-sdk/usr/local /absolute/cage-sshfs [/absolute/source-materials]' >&2; exit 2; }
66sdk=$1
77output=$2
88script_dir=$(cd "$(dirname "$0")" && pwd)
99[[ $sdk == /* && $output == /* && -f $sdk/include/fuse3/fuse.h && ! -e $output ]]
10删除:src=$(mktemp -d)
11删除:trap 'rm -rf "$src"' EXIT
12删除:commit=9b68e5f1b978c1d3c6ef7632b68d580a52ec0232
13删除:curl -fLsS --retry 2 "https://codeload.github.com/libfuse/sshfs/tar.gz/$commit" -o "$src/sshfs.tgz"
14删除:cd "$src"
15删除:echo '9be20256ac841c6e5b4cd8aefbf57c325f93e9ff01f7c7691edfe9f02700338b sshfs.tgz' | shasum -a 256 -c - >/dev/null
16删除:tar xzf sshfs.tgz --strip-components 1
17删除:patch -p1 < "$script_dir/sshfs-openwith.patch"
18删除:cat > config.h <<'HEADER'
19删除:#define PACKAGE_VERSION "3.7.6"
20删除:#define IDMAP_DEFAULT "user"
21删除:HEADER
22删除:glib=$(brew --prefix glib)
23删除:intl=$(brew --prefix gettext)
24删除:pcre=$(brew --prefix pcre2)
25删除:clang -arch arm64 -O2 -D_REENTRANT -DHAVE_CONFIG_H -DFUSE_DARWIN_ENABLE_EXTENSIONS=0 -DFUSE_USE_VERSION=31 \
26删除: -I. -Icompat -I"$sdk/include/fuse3" -I"$glib/include/glib-2.0" -I"$glib/lib/glib-2.0/include" -I"$intl/include" \
27删除: sshfs.c cache.c compat/darwin_compat.c "$glib/lib/libgthread-2.0.a" "$glib/lib/libglib-2.0.a" "$intl/lib/libintl.a" "$pcre/lib/libpcre2-8.a" \
28删除: -L"$sdk/lib" -lfuse3 -liconv -framework Foundation -framework CoreFoundation -framework AppKit -framework Carbon -o cage-sshfs
29删除:codesign -s - --force cage-sshfs
30删除:install -m 755 cage-sshfs "$output"
10新增:work=$(mktemp -d)
11新增:trap 'rm -rf "$work"' EXIT
12新增:materials=${3:-$work/source}
13新增:node "$script_dir/collect-macos-sshfs-sources.mjs" prepare "$sdk" "$materials"
14新增:bash "$script_dir/rebuild-macos-sshfs.sh" "$materials" "$sdk" "$work/cage-sshfs"
15新增:codesign -s - --force "$work/cage-sshfs"
16新增:install -m 755 "$work/cage-sshfs" "$output"
新增scripts/guest-os/collect-macos-sshfs-sources.mjs+139 −0看文件
@@ -0,0 +1,139 @@
1新增:import { createHash } from 'node:crypto';
2新增:import { execFileSync } from 'node:child_process';
3新增:import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
4新增:import { tmpdir } from 'node:os';
5新增:import { basename, dirname, join, resolve } from 'node:path';
6新增:import { fileURLToPath, pathToFileURL } from 'node:url';
7新增:
8新增:const here = dirname(fileURLToPath(import.meta.url));
9新增:const lock = JSON.parse(readFileSync(join(here, 'macos-sshfs-dependencies.json')));
10新增:const sha256 = file => createHash('sha256').update(readFileSync(file)).digest('hex');
11新增:const run = (command, args) => execFileSync(command, args, { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 });
12新增:const saveJSON = (file, value) => writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
13新增:const copy = (source, dest) => { mkdirSync(dirname(dest), { recursive: true }); cpSync(source, dest, { recursive: true, dereference: true }); };
14新增:
15新增:function files(root, relative = '') {
16新增: return readdirSync(join(root, relative)).sort().flatMap(name => {
17新增: const path = relative ? `${relative}/${name}` : name;
18新增: return statSync(join(root, path)).isDirectory() ? files(root, path) : [path];
19新增: });
20新增:}
21新增:
22新增:export function inspectDependency(name, prefix) {
23新增: const spec = lock[name];
24新增: const formula = join(prefix, '.brew', `${name}.rb`);
25新增: const receipt = JSON.parse(readFileSync(join(prefix, 'INSTALL_RECEIPT.json')));
26新增: if (sha256(formula) !== spec.formulaSha256 || receipt.source?.spec !== 'stable' || receipt.source?.versions?.stable !== spec.version) {
27新增: throw new Error(`${name}: installed formula/version differs from the reviewed SSHFS dependency lock; update the source lock before building.`);
28新增: }
29新增: // The raw receipt can contain personal paths. Keep only build identity fields.
30新增: const selected = Object.fromEntries(['homebrew_version', 'compiler', 'arch', 'built_as_bottle', 'poured_from_bottle', 'built_on', 'used_options', 'runtime_dependencies'].map(key => [key, receipt[key]]));
31新增: return { spec, formula, receipt: { ...selected, source: { spec: 'stable', version: spec.version, tap: receipt.source.tap, tap_git_head: receipt.source.tap_git_head } } };
32新增:}
33新增:
34新增:function download(url, expected, dest) {
35新增: mkdirSync(dirname(dest), { recursive: true });
36新增: run('curl', ['--fail', '--location', '--silent', '--show-error', '--proto', '=https', '--proto-redir', '=https', '--retry', '2', '--connect-timeout', '20', '--max-time', '240', url, '-o', dest]);
37新增: if (sha256(dest) !== expected) throw new Error(`Source checksum mismatch: ${basename(dest)}`);
38新增:}
39新增:
40新增:export function extractLicenses(archive, output, component) {
41新增: const selectors = {
42新增: sshfs: [/^(COPYING|AUTHORS|LICENSE[^/]*)$/],
43新增: glib: [/^COPYING$/, /^LICENSES\//],
44新增: gettext: [/^COPYING$/, /^gettext-runtime\/(COPYING|intl\/(COPYING.LIB|AUTHORS))$/],
45新增: pcre2: [/^COPYING$/, /^LICENCE(?:\.md)?$/, /^deps\/sljit\/LICENSE$/],
46新增: }[component];
47新增: const names = run('tar', ['-tf', archive]).trim().split('\n');
48新增: const selected = names.filter(name => !name.endsWith('/') && selectors.some(match => match.test(name.replace(/^[^/]+\//, ''))));
49新增: if (!selected.length) throw new Error(`No license material in ${basename(archive)}`);
50新增: const temp = mkdtempSync(join(tmpdir(), 'cage-sshfs-licenses-'));
51新增: try {
52新增: // GLib's COPYING is a symlink to LICENSES/. Extract together and read its
53新增: // target instead of publishing the empty output of tar -xOf on a symlink.
54新增: run('tar', ['-xf', archive, '-C', temp, ...selected]);
55新增: for (const name of selected) {
56新增: const relative = name.replace(/^[^/]+\//, '');
57新增: const dest = join(output, relative);
58新增: mkdirSync(dirname(dest), { recursive: true });
59新增: writeFileSync(dest, readFileSync(join(temp, name)));
60新增: }
61新增: } finally { rmSync(temp, { recursive: true, force: true }); }
62新增:}
63新增:
64新增:export function prepare(sdk, output) {
65新增: if (existsSync(output)) throw new Error('Source materials destination already exists.');
66新增: // Resolve and verify all installed recipes before downloading or compiling.
67新增: const installed = Object.fromEntries(['glib', 'gettext', 'pcre2'].map(name => {
68新增: const prefix = realpathSync(run('brew', ['--prefix', name]).trim());
69新增: return [name, { prefix, ...inspectDependency(name, prefix) }];
70新增: }));
71新增: mkdirSync(output, { recursive: true });
72新增: copy(join(here, 'rebuild-macos-sshfs.sh'), join(output, 'rebuild-macos-sshfs.sh'));
73新增: copy(join(here, '../../LICENSE'), join(output, 'cage/LICENSE'));
74新增: for (const file of ['sshfs-openwith.patch', 'macos-fuse-media.sh', 'macos-sshfs-dependencies.json']) copy(join(here, file), join(output, 'cage', file));
75新增: copy(join(here, 'macos-sshfs-source-README'), join(output, 'README'));
76新增: download(lock.sshfs.url, lock.sshfs.sha256, join(output, 'upstream/sshfs.tar.gz'));
77新增: extractLicenses(join(output, 'upstream/sshfs.tar.gz'), join(output, 'licenses/sshfs'), 'sshfs');
78新增: const archives = { glib: 'glib.tar.xz', gettext: 'gettext.tar.gz', pcre2: 'pcre2.tar.bz2' };
79新增: const inputs = { glib: ['lib/libgthread-2.0.a', 'lib/libglib-2.0.a', 'include/glib-2.0', 'lib/glib-2.0/include'], gettext: ['lib/libintl.a', 'include/libintl.h'], pcre2: ['lib/libpcre2-8.a', 'include/pcre2.h', 'include/pcre2posix.h'] };
80新增: for (const [name, { prefix, spec, formula, receipt }] of Object.entries(installed)) {
81新增: copy(formula, join(output, 'homebrew', `${name}.rb`));
82新增: saveJSON(join(output, 'homebrew', `${name}-receipt.json`), receipt);
83新增: const archive = join(output, 'upstream', archives[name]);
84新增: download(spec.url, spec.sha256, archive);
85新增: extractLicenses(archive, join(output, 'licenses', name), name);
86新增: for (const resource of spec.resources ?? []) download(resource.url, resource.sha256, join(output, 'upstream', `${resource.name}.tar.xz`));
87新增: for (const patch of spec.patches ?? []) download(patch.url, patch.sha256, join(output, 'homebrew', patch.file));
88新增: for (const file of inputs[name]) {
89新增: const target = join(output, 'dependencies', name, file);
90新增: copy(join(prefix, file), target);
91新增: // Detect an in-place package update during the snapshot. Compilation uses
92新增: // the frozen copy, never /opt/homebrew/opt symlinks that can change later.
93新增: for (const path of statSync(target).isDirectory() ? files(target) : ['']) {
94新增: if (sha256(join(target, path)) !== sha256(join(prefix, file, path))) throw new Error(`${name}: dependency changed while collecting sources.`);
95新增: }
96新增: }
97新增: }
98新增: download('https://raw.githubusercontent.com/Homebrew/homebrew-core/68093a0680c21eb19fb034af0d8c5104848315e7/LICENSE.txt', 'f80329e58613ad669c0e73cb132d8060b9b2c55e339c73848068e4d1567f4627', join(output, 'licenses/homebrew/LICENSE.txt'));
99新增: const sdkFiles = [...files(join(sdk, 'include')).map(path => `include/${path}`), 'lib/libfuse3.dylib'];
100新增: saveJSON(join(output, 'build.json'), {
101新增: cageVersion: readFileSync(join(here, '../../VERSION'), 'utf8').trim(),
102新增: dependencies: lock,
103新增: toolchain: { clang: run('clang', ['--version']).split('\n')[0], sdk: run('xcrun', ['--show-sdk-version']).trim(), deploymentTarget: process.env.MACOSX_DEPLOYMENT_TARGET ?? '14.0' },
104新增: macfuse: { version: '5.5.0', url: 'https://github.com/macfuse/macfuse/releases/download/macfuse-5.5.0/macfuse-5.5.0.dmg', sha256: '92c21ef2db4199bcf5bddc8e6efb57b23ecb9715f74ab38cba2c77ab226d3830', files: sdkFiles.map(path => ({ path, sha256: sha256(join(sdk, path)) })) },
105新增: });
106新增: writeFileSync(join(output, 'NOTICE'), `Cage macOS SSHFS corresponding source and relink materials\n\nSSHFS ${lock.sshfs.version} (${lock.sshfs.commit}): GNU GPL version 2 (see licenses/sshfs/COPYING).\nCage changes: cage/sshfs-openwith.patch (guest-local file-opening metadata).\nStatically linked GLib ${lock.glib.version} and GNU gettext libintl ${lock.gettext.version}: LGPL-2.1-or-later.\nPCRE2 ${lock.pcre2.version}: BSD-3-Clause WITH PCRE2-exception; bundled SLJIT: BSD-2-Clause.\nUpstream copyright and license notices are retained in licenses/ and the complete upstream archives.\nHomebrew recipes are under the BSD 2-Clause license in licenses/homebrew/LICENSE.txt.\nThe source archive includes the exact static libraries and headers used by the build.\nThe external macFUSE runtime is installed separately; its pinned SDK acquisition instructions are in README.\nThe final signed executable hash and every distributed source/relink input hash are in manifest.json.\n`);
107新增:}
108新增:
109新增:export function finish(materials, binary, archive, licenses) {
110新增: const build = JSON.parse(readFileSync(join(materials, 'build.json')));
111新增: const manifest = { format: 1, cageVersion: build.cageVersion, executable: { path: 'project/cage-sshfs', sha256: sha256(binary) }, files: files(materials).filter(path => path !== 'manifest.json').map(path => ({ path, sha256: sha256(join(materials, path)) })) };
112新增: saveJSON(join(materials, 'manifest.json'), manifest);
113新增: copy(join(materials, 'licenses'), licenses);
114新增: copy(join(materials, 'NOTICE'), join(licenses, 'NOTICE'));
115新增: copy(join(materials, 'build.json'), join(licenses, 'build.json'));
116新增: mkdirSync(dirname(archive), { recursive: true });
117新增: run('tar', ['-czf', archive, '-C', materials, '.']);
118新增: verifyArchive(archive, binary, build.cageVersion);
119新增:}
120新增:
121新增:export function verifyArchive(archive, binary, version) {
122新增: const temp = mkdtempSync(join(tmpdir(), 'cage-sshfs-source-verify-'));
123新增: try {
124新增: run('tar', ['-xzf', archive, '-C', temp]);
125新增: const manifest = JSON.parse(readFileSync(join(temp, 'manifest.json')));
126新增: if (manifest.format !== 1 || manifest.cageVersion !== version || manifest.executable?.sha256 !== sha256(binary)) throw new Error('macOS guest source does not match this signed executable/version.');
127新增: for (const item of manifest.files) {
128新增: if (!item.path.split('/').every(part => part && part !== '.' && part !== '..') || item.path.startsWith('/') || sha256(join(temp, item.path)) !== item.sha256) throw new Error(`macOS guest source integrity check failed: ${item.path}`);
129新增: }
130新增: } finally { rmSync(temp, { recursive: true, force: true }); }
131新增:}
132新增:
133新增:if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
134新增: const [action, ...args] = process.argv.slice(2);
135新增: if (action === 'prepare' && args.length === 2) prepare(...args);
136新增: else if (action === 'finish' && args.length === 4) finish(...args);
137新增: else if (action === 'verify' && args.length === 3) verifyArchive(...args);
138新增: else throw new Error('Usage: collect-macos-sshfs-sources.mjs prepare SDK DIRECTORY | finish DIRECTORY BINARY ARCHIVE LICENSES | verify ARCHIVE BINARY VERSION');
139新增:}
新增scripts/guest-os/macos-sshfs-dependencies.json+36 −0看文件
@@ -0,0 +1,36 @@
1新增:{
2新增: "sshfs": {
3新增: "version": "3.7.6",
4新增: "commit": "9b68e5f1b978c1d3c6ef7632b68d580a52ec0232",
5新增: "url": "https://codeload.github.com/libfuse/sshfs/tar.gz/9b68e5f1b978c1d3c6ef7632b68d580a52ec0232",
6新增: "sha256": "9be20256ac841c6e5b4cd8aefbf57c325f93e9ff01f7c7691edfe9f02700338b"
7新增: },
8新增: "glib": {
9新增: "version": "2.90.1",
10新增: "formulaSha256": "7352a67a6a1a15554d996d38886812e858bebbbcbf3985901724cab444ee3b3b",
11新增: "url": "https://download.gnome.org/sources/glib/2.90/glib-2.90.1.tar.xz",
12新增: "sha256": "93c941aa17d5eb1d53fe838365f29a8b4e539c222a256d974ec8f30fc413e396",
13新增: "resources": [{
14新增: "name": "gobject-introspection",
15新增: "url": "https://download.gnome.org/sources/gobject-introspection/1.86/gobject-introspection-1.86.0.tar.xz",
16新增: "sha256": "920d1a3fcedeadc32acff95c2e203b319039dd4b4a08dd1a2dfd283d19c0b9ae"
17新增: }],
18新增: "patches": [{
19新增: "file": "Patches/glib/hardcoded-paths.diff",
20新增: "url": "https://raw.githubusercontent.com/Homebrew/homebrew-core/68093a0680c21eb19fb034af0d8c5104848315e7/Patches/glib/hardcoded-paths.diff",
21新增: "sha256": "d846efd0bf62918350da94f850db33b0f8727fece9bfaf8164566e3094e80c97"
22新增: }]
23新增: },
24新增: "gettext": {
25新增: "version": "1.0",
26新增: "formulaSha256": "dd8d1b5914bb96c9c59140dd8cf76ad1d270f65a88111a395f79fe22106367c6",
27新增: "url": "https://ftp.gnu.org/gnu/gettext/gettext-1.0.tar.gz",
28新增: "sha256": "85d99b79c981a404874c02e0342176cf75c7698e2b51fe41031cf6526d974f1a"
29新增: },
30新增: "pcre2": {
31新增: "version": "10.49",
32新增: "formulaSha256": "94c19a0d869da4990a8f3f371e37c986ad72124d2d94032e061c4a9019f9e174",
33新增: "url": "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.49/pcre2-10.49.tar.bz2",
34新增: "sha256": "53c156e1ba416a20da8e65395daa132da0d80e76910424caca3fcdae7831d384"
35新增: }
36新增:}
新增scripts/guest-os/macos-sshfs-source-README+61 −0看文件
@@ -0,0 +1,61 @@
1新增:Cage macOS guest: SSHFS source and relink materials
2新增:
3新增:This distribution contains the complete SSHFS, GLib, GNU gettext and PCRE2
4新增:upstream source archives, the Cage SSHFS patch, installed Homebrew recipes and
5新增:their external patch/resource, and the exact static libraries and headers used
6新增:to link Cage's SSHFS helper. build.json records source URLs, SHA256 digests,
7新增:versions and the build toolchain. manifest.json binds all these files to the
8新增:final signed project/cage-sshfs executable. Receipts retain build identity
9新增:without the developer's personal filesystem paths.
10新增:
11新增:Rebuild or modify SSHFS on an Apple Silicon Mac with Xcode command-line tools:
12新增:
13新增:1. Obtain the external macFUSE 5.5.0 SDK from its official installer. It is not
14新增: installed by these commands. The pinned image and package hashes are checked
15新增: by the included extraction script. Set SOURCE to this extracted directory,
16新增: and WORK to a new, empty absolute directory:
17新增:
18新增: mkdir -p "$WORK"
19新增: curl -fL https://github.com/macfuse/macfuse/releases/download/macfuse-5.5.0/macfuse-5.5.0.dmg -o "$WORK/macfuse.dmg"
20新增: bash "$SOURCE/cage/macos-fuse-media.sh" "$WORK/macfuse.dmg" "$WORK/fuse.pkg"
21新增: pkgutil --expand-full "$WORK/fuse.pkg" "$WORK/sdk"
22新增:
23新增:2. Relink using the frozen static libraries and headers:
24新增:
25新增: bash "$SOURCE/rebuild-macos-sshfs.sh" "$SOURCE" "$WORK/sdk/Core.pkg/Payload/usr/local" "$WORK/cage-sshfs"
26新增: codesign --force --sign - "$WORK/cage-sshfs"
27新增:
28新增: No Homebrew installation or network access is needed for this compile step.
29新增: To modify SSHFS, first extract upstream/sshfs.tar.gz, apply
30新增: cage/sshfs-openwith.patch with patch -p1, edit the files, then pass that source
31新增: directory as the fourth argument to rebuild-macos-sshfs.sh.
32新增:
33新增:The helper dynamically loads the separately installed macFUSE runtime. macFUSE
34新增:must be available on the machine where it runs. Xcode, the macOS SDK and macFUSE
35新增:are external system/build prerequisites; they are not redistributed here.
36新增:Rebuilding with another compiler or replacing the Developer ID signature will
37新增:change the executable hash. The manifest describes the shipped executable.
38新增:
39新增:To rebuild the static dependencies, the complete upstream archives are in
40新增:upstream/. The exact Homebrew install methods, configure/Meson flags, inline
41新增:source changes, and versions used for the installed bottles are preserved in
42新增:homebrew/{glib,gettext,pcre2}.rb. GLib's separate introspection resource and
43新增:hardcoded-paths patch are also included. With Homebrew and its recipe build
44新增:tools, copy these recipes to a local tap (Formula/ and Patches/ retain their
45新增:relative paths) and run:
46新增:
47新增: brew install --build-from-source your/local/pcre2
48新增: brew install --build-from-source your/local/gettext
49新增: brew install --build-from-source your/local/glib
50新增:
51新增:The formula install methods list their build prerequisites. As with ordinary
52新增:Homebrew builds, these general-purpose tools and the other formula runtime
53新增:dependencies can be installed separately. The source archives and required
54新增:GLib patch/resource are frozen here; configure local source URLs if building
55新增:without network access. Replace dependencies/* with your rebuilt static
56新增:libraries/headers before relinking. The frozen originals are provided so users
57新增:can relink modified SSHFS immediately, without having to reproduce Homebrew's
58新增:bottle build environment.
59新增:
60新增:Copyright and license texts are under licenses/ and within each complete
61新增:upstream archive. See NOTICE for the shipped components and Cage modification.
修改scripts/guest-os/package-macos-guest.sh+6 −1看文件
@@ -21,7 +21,7 @@ else
2121fi
2222bash "$src/macos-fuse-media.sh" "$fuse" "$work/fuse.pkg"
2323pkgutil --expand-full "$work/fuse.pkg" "$work/sdk"
24删除:bash "$src/build-macos-sshfs.sh" "$work/sdk/Core.pkg/Payload/usr/local" "$dest/project/cage-sshfs"
24新增:bash "$src/build-macos-sshfs.sh" "$work/sdk/Core.pkg/Payload/usr/local" "$dest/project/cage-sshfs" "$work/sshfs-source"
2525xcrun clang -arch arm64 -mmacosx-version-min=14.0 -O2 -fobjc-arc -framework Foundation -framework OpenDirectory \
2626 "$src/macos-setup-account.m" -o "$dest/cage-finish-initial-setup"
2727xcrun clang -arch arm64 -O2 "$src/macos-ipv6-check.c" -o "$dest/cage-macos-ipv6-check"
@@ -36,3 +36,8 @@ cp "$src/configure-macos-session.sh" "$dest/"
3636# Final signing runs after every helper has been built. Component manifests are
3737# computed from these final bytes by RequiredNativeComponents at installation.
3838bash "$src/sign-macos-guest.sh" "$dest" "${CAGE_SIGNING_IDENTITY:--}"
39新增:# Bind the source distribution to the final Developer ID bytes, after the kit
40新增:# has signed SSHFS. The outer host App signature does not change this helper.
41新增:version=$(tr -d '\n\r' < "$src/../../VERSION")
42新增:node "$src/collect-macos-sshfs-sources.mjs" finish "$work/sshfs-source" "$dest/project/cage-sshfs" \
43新增: "$dest/sources/cage-macos-guest-$version-source.tar.gz" "$dest/licenses/sshfs"
新增scripts/guest-os/rebuild-macos-sshfs.sh+30 −0看文件
@@ -0,0 +1,30 @@
1新增:#!/bin/bash
2新增:# Relink SSHFS from the frozen source distribution. An optional fourth argument
3新增:# selects an already extracted/patched source tree for local modifications.
4新增:set -euo pipefail
5新增:[[ $# == 3 || $# == 4 ]] || { echo 'Usage: rebuild-macos-sshfs.sh /source-bundle /macfuse-sdk/usr/local /output [patched-source-tree]' >&2; exit 2; }
6新增:materials=$1
7新增:sdk=$2
8新增:output=$3
9新增:[[ $materials == /* && $sdk == /* && $output == /* && ! -e $output && -f $sdk/include/fuse3/fuse.h ]]
10新增:work=$(mktemp -d)
11新增:trap 'rm -rf "$work"' EXIT
12新增:if [[ $# == 4 ]]; then
13新增: cd "$4"
14新增:else
15新增: tar -xf "$materials/upstream/sshfs.tar.gz" -C "$work" --strip-components 1
16新增: cd "$work"
17新增: patch -p1 < "$materials/cage/sshfs-openwith.patch"
18新增:fi
19新增:cat > config.h <<'HEADER'
20新增:#define PACKAGE_VERSION "3.7.6"
21新增:#define IDMAP_DEFAULT "user"
22新增:HEADER
23新增:export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-14.0}
24新增:glib=$materials/dependencies/glib
25新增:intl=$materials/dependencies/gettext
26新增:pcre=$materials/dependencies/pcre2
27新增:clang -arch arm64 -O2 -D_REENTRANT -DHAVE_CONFIG_H -DFUSE_DARWIN_ENABLE_EXTENSIONS=0 -DFUSE_USE_VERSION=31 \
28新增: -I. -Icompat -I"$sdk/include/fuse3" -I"$glib/include/glib-2.0" -I"$glib/lib/glib-2.0/include" -I"$intl/include" \
29新增: sshfs.c cache.c compat/darwin_compat.c "$glib/lib/libgthread-2.0.a" "$glib/lib/libglib-2.0.a" "$intl/lib/libintl.a" "$pcre/lib/libpcre2-8.a" \
30新增: -L"$sdk/lib" -lfuse3 -liconv -framework Foundation -framework CoreFoundation -framework AppKit -framework Carbon -o "$output"
新增scripts/macos-sshfs-sources.test.mjs+61 −0看文件
@@ -0,0 +1,61 @@
1新增:import test from 'node:test';
2新增:import assert from 'node:assert/strict';
3新增:import { execFileSync } from 'node:child_process';
4新增:import { mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
5新增:import { tmpdir } from 'node:os';
6新增:import { join } from 'node:path';
7新增:import { extractLicenses, finish, inspectDependency, verifyArchive } from './guest-os/collect-macos-sshfs-sources.mjs';
8新增:
9新增:test('macOS guest source is bound to the final signed binary and release version', t => {
10新增: const root = mkdtempSync(join(tmpdir(), 'cage-sshfs-source-test-'));
11新增: t.after(() => rmSync(root, { recursive: true, force: true }));
12新增: const source = join(root, 'source');
13新增: mkdirSync(join(source, 'licenses'), { recursive: true });
14新增: writeFileSync(join(source, 'build.json'), JSON.stringify({ cageVersion: '0.1.7-rc.1' }));
15新增: writeFileSync(join(source, 'NOTICE'), 'copyright and license notices');
16新增: writeFileSync(join(source, 'licenses/LICENSE'), 'upstream license');
17新增: writeFileSync(join(source, 'dependency.a'), 'the actual linked static library');
18新增: const binary = join(root, 'cage-sshfs');
19新增: writeFileSync(binary, 'final Developer ID signed executable');
20新增: const archive = join(root, 'source.tar.gz');
21新增: finish(source, binary, archive, join(root, 'app-licenses'));
22新增: assert.equal(readFileSync(join(root, 'app-licenses/LICENSE'), 'utf8'), 'upstream license');
23新增: assert.doesNotThrow(() => verifyArchive(archive, binary, '0.1.7-rc.1'));
24新增: assert.throws(() => verifyArchive(archive, binary, '0.1.7-rc.2'), /does not match/);
25新增: writeFileSync(binary, 'earlier ad-hoc signed executable');
26新增: assert.throws(() => verifyArchive(archive, binary, '0.1.7-rc.1'), /does not match/);
27新增: writeFileSync(binary, 'final Developer ID signed executable');
28新增: writeFileSync(join(source, 'dependency.a'), 'different static library');
29新增: execFileSync('tar', ['-czf', archive, '-C', source, '.']);
30新增: assert.throws(() => verifyArchive(archive, binary, '0.1.7-rc.1'), /integrity check failed: dependency.a/);
31新增:});
32新增:
33新增:test('same-version Homebrew formula changes cannot silently substitute another build', t => {
34新增: const root = mkdtempSync(join(tmpdir(), 'cage-sshfs-formula-test-'));
35新增: t.after(() => rmSync(root, { recursive: true, force: true }));
36新增: mkdirSync(join(root, '.brew'));
37新增: writeFileSync(join(root, 'INSTALL_RECEIPT.json'), JSON.stringify({ source: { spec: 'stable', versions: { stable: '2.90.1' } } }));
38新增: writeFileSync(join(root, '.brew/glib.rb'), 'same version, unreviewed upstream patch');
39新增: assert.throws(() => inspectDependency('glib', root), /installed formula\/version differs/);
40新增:});
41新增:
42新增:test('upstream license symlinks and PCRE2 LICENCE.md are distributed as readable texts', t => {
43新增: const root = mkdtempSync(join(tmpdir(), 'cage-sshfs-license-test-'));
44新增: t.after(() => rmSync(root, { recursive: true, force: true }));
45新增: const upstream = join(root, 'upstream');
46新增: mkdirSync(join(upstream, 'glib/LICENSES'), { recursive: true });
47新增: writeFileSync(join(upstream, 'glib/LICENSES/LGPL-2.1-or-later.txt'), 'full LGPL text');
48新增: symlinkSync('LICENSES/LGPL-2.1-or-later.txt', join(upstream, 'glib/COPYING'));
49新增: mkdirSync(join(upstream, 'pcre2/deps/sljit'), { recursive: true });
50新增: writeFileSync(join(upstream, 'pcre2/COPYING'), 'See LICENCE.md');
51新增: writeFileSync(join(upstream, 'pcre2/LICENCE.md'), 'BSD-3-Clause WITH PCRE2-exception');
52新增: writeFileSync(join(upstream, 'pcre2/deps/sljit/LICENSE'), 'SLJIT license');
53新增: for (const component of ['glib', 'pcre2']) {
54新增: const archive = join(root, `${component}.tar.gz`);
55新增: execFileSync('tar', ['-czf', archive, '-C', upstream, component]);
56新增: extractLicenses(archive, join(root, 'licenses', component), component);
57新增: }
58新增: assert.equal(readFileSync(join(root, 'licenses/glib/COPYING'), 'utf8'), 'full LGPL text');
59新增: assert.equal(readFileSync(join(root, 'licenses/pcre2/LICENCE.md'), 'utf8'), 'BSD-3-Clause WITH PCRE2-exception');
60新增: assert.equal(readFileSync(join(root, 'licenses/pcre2/deps/sljit/LICENSE'), 'utf8'), 'SLJIT license');
61新增:});
修改scripts/package-macos.sh+9 −2看文件
@@ -31,6 +31,13 @@ if [[ "$actual_version" != "$version" ]]; then echo 'App version differs from VE
3131codesign --verify --deep --strict --verbose=2 "$bundle"
3232xcrun stapler validate "$bundle"
3333spctl --assess --type execute --verbose=2 "$bundle"
34新增:guest_source="cage-macos-guest-$version-source.tar.gz"
35新增:guest_materials="$bundle/Contents/Resources/guest-os/sources/$guest_source"
36新增:node 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.
40新增:cp "$guest_materials" "$release/$guest_source"
3441
3542stage="$(mktemp -d "$PWD/_output/dmg-stage.XXXXXX")"
3643trap 'rm -rf "$stage"' EXIT
@@ -78,6 +85,6 @@ curl --fail --location --retry 2 --connect-timeout 15 --max-time 180 \
7885 -o "$release/$core_source.part"
7986mv "$release/$core_source.part" "$release/$core_source"
8087tar -tzf "$release/$core_source" > /dev/null
81删除:(cd "$release" && shasum -a 256 "$artifact" "$core_source" > SHA256SUMS)
88新增:(cd "$release" && shasum -a 256 "$artifact" "$core_source" "$guest_source" > SHA256SUMS)
8289node scripts/cleanup-apps.mjs --keep "$bundle" --root "$PWD/_output"
83删除:printf 'Verified release artifacts:\n%s/%s\n%s/%s\n%s/SHA256SUMS\n' "$release" "$artifact" "$release" "$core_source" "$release"
90新增:printf '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"
修改scripts/prepare-release-assets.mjs+3 −1看文件
@@ -31,6 +31,7 @@ async function releaseNames() {
3131 linux: `Cage-${version}-linux-amd64.deb`,
3232 linuxSource: linuxDependencies.mihomoSource.file,
3333 macSource: `mihomo-${macCore}-source.tar.gz`,
34新增: macGuestSource: `cage-macos-guest-${version}-source.tar.gz`,
3435 windowsSource: `mihomo-${dependencies.mihomo.version}-source.tar.gz`,
3536 qemuPrefix: `qemu-${dependencies.qemu.version}-windows-full-source.`,
3637 qemuSource: `${dependencies.qemuSource.file}.gz`,
@@ -116,12 +117,13 @@ export async function prepareReleaseAssets({ inputs, output }) {
116117 if (!mac && !windows && !linux) throw new Error(`No supported package name for VERSION ${names.version}: ${directory}`);
117118 if (linux && !entries.has(names.linuxSource)) throw new Error(`Missing Linux Mihomo source in SHA256SUMS: ${directory}`);
118119 if (mac && !entries.has(names.macSource)) throw new Error(`Missing macOS Mihomo source in SHA256SUMS: ${directory}`);
120新增: if (mac && !entries.has(names.macGuestSource)) throw new Error(`Missing macOS guest corresponding source in SHA256SUMS: ${directory}`);
119121 if (windows && (!entries.has(names.windowsSource) || ![...entries.keys()].some(name => isQemuArchive(name, names)))) {
120122 throw new Error(`Windows release requires its Mihomo and complete QEMU source archives in the same SHA256SUMS: ${directory}`);
121123 }
122124 for (const [name, digest] of entries) {
123125 const installer = name === names.mac || name === names.windows || name === names.linux;
124删除: if (!installer && ![names.macSource, names.windowsSource, names.linuxSource, names.qemuSource, names.qemuKeymap, names.qemuChanges].includes(name) && !isQemuArchive(name, names)) {
126新增: if (!installer && ![names.macSource, names.macGuestSource, names.windowsSource, names.linuxSource, names.qemuSource, names.qemuKeymap, names.qemuChanges].includes(name) && !isQemuArchive(name, names)) {
125127 throw new Error(`Unsupported asset or version in SHA256SUMS: ${name}`);
126128 }
127129 const existing = all.get(name);
修改scripts/prepare-release-assets.test.mjs+12 −2看文件
@@ -14,6 +14,7 @@ const names = {
1414 mac: `Cage-${version}-macos-arm64.dmg`,
1515 windows: `Cage-${version}-windows-amd64-setup.exe`,
1616 macSource: `mihomo-${macCore}-source.tar.gz`,
17新增: macGuestSource: `cage-macos-guest-${version}-source.tar.gz`,
1718 windowsSource: `mihomo-${dependencies.mihomo.version}-source.tar.gz`,
1819 qemu: `qemu-${dependencies.qemu.version}-windows-full-source.zip`,
1920};
@@ -31,7 +32,7 @@ async function platform(directory, assets) {
3132 await writeFile(join(directory, 'SHA256SUMS'), Object.entries(assets).map(([name, data]) => `${digest(data)} ${name}\n`).join(''));
3233}
3334
34删除:const macAssets = () => ({ [names.mac]: 'mac package fixture', [names.macSource]: 'Mihomo source fixture' });
35新增:const macAssets = () => ({ [names.mac]: 'mac package fixture', [names.macSource]: 'Mihomo source fixture', [names.macGuestSource]: 'macOS guest source fixture' });
3536const windowsAssets = () => ({ [names.windows]: 'Windows package fixture', [names.windowsSource]: 'Mihomo source fixture', [names.qemu]: 'complete QEMU source fixture' });
3637
3738test('includes Linux deb only with its verified corresponding source and merges common sources', async t => {
@@ -75,7 +76,7 @@ test('supports a single Windows or macOS platform with its corresponding sources
7576 const f = await fixture(t);
7677 await platform(f.mac, macAssets());
7778 await platform(f.windows, windowsAssets());
78删除: assert.equal((await prepareReleaseAssets({ inputs: [f.mac], output: f.output })).assets.length, 2);
79新增: assert.equal((await prepareReleaseAssets({ inputs: [f.mac], output: f.output })).assets.length, 3);
7980 assert.equal((await prepareReleaseAssets({ inputs: [f.windows], output: join(f.root, 'windows-only') })).assets.length, 3);
8081});
8182
@@ -125,6 +126,15 @@ test('requires Windows complete QEMU source in the same verified manifest', asyn
125126 await assert.rejects(prepareReleaseAssets({ inputs: [f.windows], output: f.output }), /complete QEMU source/);
126127});
127128
129新增:test('requires the shipped macOS guest corresponding source in the verified manifest', async t => {
130新增: const f = await fixture(t);
131新增: const assets = macAssets();
132新增: delete assets[names.macGuestSource];
133新增: await platform(f.mac, assets);
134新增: await writeFile(join(f.mac, names.macGuestSource), 'unlisted source is not verified');
135新增: await assert.rejects(prepareReleaseAssets({ inputs: [f.mac], output: f.output }), /macOS guest corresponding source/);
136新增:});
137新增:
128138test('rejects wrong versions and manifest paths outside the release directory', async t => {
129139 const f = await fixture(t);
130140 await platform(f.mac, { ...macAssets(), 'Cage-99.0.0-macos-arm64.dmg': 'wrong version' });
修改scripts/release-control.test.mjs+1 −1看文件
@@ -264,7 +264,7 @@ async function artifactFixture(t) {
264264 const root = await temporary(t);
265265 const commitSha = 'a'.repeat(40);
266266 const packages = {
267删除: macos: { [`Cage-${currentVersion}-macos-arm64.dmg`]: 'mac installer', [`mihomo-${macCoreVersion}-source.tar.gz`]: 'same core source' },
267新增: macos: { [`Cage-${currentVersion}-macos-arm64.dmg`]: 'mac installer', [`mihomo-${macCoreVersion}-source.tar.gz`]: 'same core source', [`cage-macos-guest-${currentVersion}-source.tar.gz`]: 'mac guest corresponding source' },
268268 windows: { [`Cage-${currentVersion}-windows-amd64-setup.exe`]: 'windows installer', [`mihomo-${windowsDependencies.mihomo.version}-source.tar.gz`]: 'same core source', [`qemu-${windowsDependencies.qemu.version}-windows-full-source.zip`]: 'complete qemu source' },
269269 linux: { [`Cage-${currentVersion}-linux-amd64.deb`]: 'linux installer', [linuxDependencies.mihomoSource.file]: 'same core source' },
270270 };
修改www/scripts/sync-release.mjs+1 −0看文件
@@ -12,6 +12,7 @@ const repository = 'Lee-xeo/Claude-Cage';
1212const repoURL = `https://github.com/${repository}`;
1313const apiURL = `https://api.github.com/repos/${repository}/releases`;
1414const sourceArchive = name => /^mihomo-v[\d.]+-source\.tar\.gz$/.test(name) ||
15新增: /^cage-macos-guest-\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?-source\.tar\.gz$/.test(name) ||
1516 /^qemu-[0-9a-f]{40}-source\.tar\.gz$/.test(name) ||
1617 /^qemu-keycodemapdb-[0-9a-f]{40}-source\.tar\.gz$/.test(name) ||
1718 /^qemu-\d+\.\d+\.\d+-cage-changes-source\.tar\.gz$/.test(name) ||
修改www/scripts/sync-release.test.mjs+1 −1看文件
@@ -198,7 +198,7 @@ test('macOS verification checks both owned archives without requiring other-plat
198198
199199test('explicit RC manifest exposes signed Windows and all platforms with complete QEMU sources', async () => {
200200 const tag = 'v0.1.7-rc.1', version = tag.slice(1);
201删除: const names = [`Cage-${version}-macos-arm64.dmg`, `Cage-${version}-windows-amd64-setup.exe`, `Cage-${version}-linux-amd64.deb`, 'mihomo-v1.19.33-source.tar.gz', 'qemu-11.1.0-windows-full-source.tar.gz', `qemu-${'a'.repeat(40)}-source.tar.gz`, `qemu-keycodemapdb-${'b'.repeat(40)}-source.tar.gz`, 'qemu-11.1.0-cage-changes-source.tar.gz'];
201新增: const names = [`Cage-${version}-macos-arm64.dmg`, `Cage-${version}-windows-amd64-setup.exe`, `Cage-${version}-linux-amd64.deb`, `cage-macos-guest-${version}-source.tar.gz`, 'mihomo-v1.19.33-source.tar.gz', 'qemu-11.1.0-windows-full-source.tar.gz', `qemu-${'a'.repeat(40)}-source.tar.gz`, `qemu-keycodemapdb-${'b'.repeat(40)}-source.tar.gz`, 'qemu-11.1.0-cage-changes-source.tar.gz'];
202202 const manifest = names.map(name => `${hash} ${name}\n`).join('');
203203 const release = await publicManifestRelease(tag, async (url, options = {}) => {
204204 assert.equal(options.headers?.Authorization, undefined);