跳到主要内容

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

浏览文件

bundle-qemu-sources.sh

72 行 · 5.0 KB历史下载
1#!/usr/bin/env bash
2# Bundle the exact QEMU/firmware revisions and the packages owning its DLLs.
3set -euo pipefail
4repository=$(cygpath -u "$1")
5runtime=$(cygpath -u "$2")
6archive=$(cygpath -u "$3")
7node_command=${CAGE_NODE:-node}
8if [[ -n ${CAGE_NODE:-} ]]; then node_command=$(cygpath -u "$CAGE_NODE"); fi
9for tool in "$node_command" git curl tar sha256sum find sort xargs pacman-key pacman-conf mkdir mktemp cp mv rm grep; do
10 command -v "$tool" >/dev/null 2>&1 || { echo "Missing source-collection tool: $tool" >&2; exit 1; }
11done
12commit=$("$node_command" -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuSource.commit" "$repository/packaging/windows/dependencies.json")
13source_repository=$("$node_command" -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuSource.repository" "$repository/packaging/windows/dependencies.json")
14[[ $commit =~ ^[a-f0-9]{40}$ && -s "$runtime/build-source-packages.txt" ]] || { echo 'QEMU source/package identity is missing.' >&2; exit 1; }
15stage=$(mktemp -d)
16trap 'rm -rf "$stage"' EXIT
17mkdir -p "$stage/source/packages" "$stage/source/cage"
18# pacman-key requires lock-never for verification. Keep the installed public
19# keys and trust database intact; only the private verification copy gets it.
20installed_keyring=$(pacman-conf gpgdir)
21mkdir -p "$stage/keyring"
22cp "$installed_keyring/pubring.gpg" "$installed_keyring/trustdb.gpg" "$stage/keyring/"
23printf 'lock-never\n' > "$stage/keyring/gpg.conf"
24git -c core.autocrlf=false init -q "$stage/source/qemu"
25git -C "$stage/source/qemu" fetch --depth=1 "$source_repository" "$commit"
26git -c core.autocrlf=false -C "$stage/source/qemu" checkout -q --detach FETCH_HEAD
27[[ $(git -C "$stage/source/qemu" rev-parse HEAD) == "$commit" ]]
28# All shipped firmware comes from QEMU's pinned ROM submodules. Include nested
29# submodules (EDK2 libraries etc.), not only the superproject's empty gitlinks.
30git_options=(-c core.autocrlf=false)
31for module in QemuMacDrivers edk2 ipxe opensbi qboot qemu-palcode seabios seabios-hppa skiboot u-boot vbootrom; do
32 git_options+=(-c "url.https://github.com/qemu/$module.insteadOf=https://gitlab.com/qemu-project/$module")
33done
34git_options+=(-c url.https://github.com/openbios/openbios.insteadOf=https://gitlab.com/qemu-project/openbios)
35git_options+=(-c url.https://github.com/zbalaton/u-boot-sam460ex.insteadOf=https://gitlab.com/qemu-project/u-boot-sam460ex)
36git_options+=(-c url.https://github.com/tianocore/edk2-cmocka.git.insteadOf=https://gitlab.com/cmocka/cmocka.git)
37# SLOF has no current official GitHub mirror. Its GitLab smart-Git endpoint
38# remains usable even when archive downloads receive an HTML challenge.
39git "${git_options[@]}" -C "$stage/source/qemu" submodule update --init --recursive --depth=1 -- roms
40git -C "$stage/source/qemu" submodule status --recursive -- roms > "$stage/source/firmware-revisions.txt"
41if grep -Eq '^[-+U]' "$stage/source/firmware-revisions.txt"; then echo 'Firmware source revisions are incomplete.' >&2; exit 1; fi
42cp "$runtime/build-source-packages.txt" "$runtime/build-packages.txt" "$runtime/cage-build.json" "$stage/source/cage/"
43cp "$repository/scripts/build-qemu-windows.sh" "$repository/scripts/build-qemu-windows.ps1" "$repository/scripts/bundle-qemu-sources.sh" "$stage/source/cage/"
44cp -R "$repository/patches/qemu" "$stage/source/cage/patches"
45keymap_url=$("$node_command" -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuKeycodemap.url" "$repository/packaging/windows/dependencies.json")
46keymap_hash=$("$node_command" -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuKeycodemap.hash" "$repository/packaging/windows/dependencies.json")
47curl --fail --location --retry 3 -o "$stage/source/keycodemapdb.tar.gz" "$keymap_url"
48printf '%s %s\n' "$keymap_hash" "$stage/source/keycodemapdb.tar.gz" | sha256sum -c -
49while read -r base version; do
50 [[ $base =~ ^[a-zA-Z0-9+_.-]+$ && $version =~ ^[a-zA-Z0-9+_.:-]+$ ]] || exit 1
51 found=false
52 for extension in zst xz gz; do
53 name="$base-$version.src.tar.$extension"
54 url="https://repo.msys2.org/mingw/sources/$name"
55 if curl --fail --location --retry 2 -o "$stage/source/packages/$name" "$url"; then
56 curl --fail --location --retry 3 -o "$stage/source/packages/$name.sig" "$url.sig"
57 pacman-key --gpgdir "$stage/keyring" --verify "$stage/source/packages/$name.sig" "$stage/source/packages/$name"
58 found=true
59 break
60 fi
61 done
62 $found || { echo "No verified corresponding source for $base $version" >&2; exit 1; }
63done < "$runtime/build-source-packages.txt"
64# Firmware sources remain unmodified; the Cage patch and reproducible build
65# commands travel beside them. The manifest covers every distributed source.
66find "$stage/source" -name .git -type d -prune -exec rm -rf {} +
67find "$stage/source" -name .git -type f -delete
68(cd "$stage/source" && find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS)
69mkdir -p "$(dirname "$archive")"
70tar -czf "$archive.partial" -C "$stage" source
71mv "$archive.partial" "$archive"
72sha256sum "$archive"