跳到主要内容

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

浏览文件

build-linux.sh

46 行 · 2.1 KB历史下载
1#!/usr/bin/env bash
2set -euo pipefail
3cd "$(dirname "$0")/.."
4[[ "$(uname -s)" == Linux && "$(uname -m)" == x86_64 ]] || { echo 'Build on x86_64 Linux (Ubuntu 22.04 baseline).' >&2; exit 1; }
5case "${1:-}" in ''|--prebuilt-backend) ;; *) echo 'Usage: scripts/build-linux.sh [--prebuilt-backend]' >&2; exit 2 ;; esac
6version=$(tr -d '\r\n' < VERSION)
7[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$ ]] || { echo 'Invalid VERSION.' >&2; exit 1; }
8pkg-config --atleast-version=2.40 webkit2gtk-4.1
9pkg-config --exists gtk+-3.0 json-glib-1.0
10bash scripts/fetch-linux-proxy-core.sh
11if [[ "${1:-}" != --prebuilt-backend ]]; then
12 make cage GOOS=linux GOARCH=amd64 CGO_ENABLED=0 VERSION="$version"
13else
14 # For constrained remote test hosts. The caller supplies the backend built
15 # from this exact source tree, and npm licenses from a locked npm ci.
16 [[ -x _output/bin/cage ]] || { echo 'Missing prebuilt Linux backend.' >&2; exit 1; }
17 _output/bin/cage help >/dev/null
18fi
19_output/bin/cage verify-web-assets
20mkdir -p _output/linux-amd64
21stage=$(mktemp -d "$PWD/_output/linux-amd64/build.XXXXXX")
22trap 'rm -rf "$stage"' EXIT
23app="$stage/app"
24mkdir -p "$app/licenses/mihomo"
25cc -std=c11 -O2 -Wall -Wextra -Werror -Wno-deprecated-declarations \
26 "-DCAGE_VERSION=\"$version\"" desktop/linux/cage-desktop.c \
27 $(pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.1 json-glib-1.0) \
28 -o "$app/cage-desktop"
29install -m 755 _output/bin/cage "$app/cage"
30node scripts/bundle-cloud-kit.mjs "$app"
31install -m 755 _output/linux-deps/mihomo "$app/mihomo"
32cp _output/linux-deps/{LICENSE,NOTICE} "$app/licenses/mihomo/"
33if [[ "${1:-}" == --prebuilt-backend && -d _output/linux-amd64/prebuilt-licenses ]]; then
34 cp -a _output/linux-amd64/prebuilt-licenses/. "$app/licenses/"
35else
36 node scripts/collect-app-licenses.mjs "$app/licenses"
37fi
38"$app/cage" help >/dev/null
39"$app/cage-desktop" --version
40"$app/cage-desktop" --self-test
41"$app/mihomo" -v
42printf '%s\n' "$version" > "$app/VERSION"
43# Build output only; installed files are changed exclusively by dpkg/apt.
44rm -rf _output/linux-amd64/app
45mv "$app" _output/linux-amd64/app
46printf 'Built: %s/_output/linux-amd64/app\n' "$PWD"