跳到主要内容

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

浏览文件

efi_darwin_arm64_test.go

54 行 · 1.5 KB历史下载
1package e2eqemu
2
3import (
4 "fmt"
5 "os"
6 "path/filepath"
7)
8
9func efiArgs() (string, error) {
10 // file may not exist, that's ok
11 _ = os.Remove("ovmf_vars.fd")
12 ovmfVars, err := os.Create("ovmf_vars.fd")
13 if err != nil {
14 return "", err
15 }
16 defer ovmfVars.Close()
17 if err := ovmfVars.Truncate(67108864); err != nil {
18 return "", err
19 }
20
21 edk2Path := getEdk2CodeFd("edk2-aarch64-code.fd")
22 return fmt.Sprintf(`-drive file=%s,if=pflash,format=raw,readonly=on -drive file=%s,if=pflash,format=raw `, edk2Path, ovmfVars.Name()), nil
23}
24
25/*
26 * When QEmu is installed in a non-default location in the system
27 * we can use the qemu-system-* binary path to figure the install
28 * location for Qemu and use it to look for edk2-code-fd
29 */
30func getEdk2CodeFdPathFromQemuBinaryPath() string {
31 return filepath.Clean(filepath.Join(filepath.Dir(qemuExecutable()), "..", "share", "qemu"))
32}
33
34/*
35 * QEmu can be installed in multiple locations on MacOS, especially on
36 * Apple Silicon systems. A build from source will likely install it in
37 * /usr/local/bin, whereas Homebrew package management standard is to
38 * install in /opt/homebrew
39 */
40func getEdk2CodeFd(name string) string {
41 dirs := []string{
42 getEdk2CodeFdPathFromQemuBinaryPath(),
43 "/opt/homebrew/opt/podman/libexec/share/qemu",
44 "/usr/local/share/qemu",
45 "/opt/homebrew/share/qemu",
46 }
47 for _, dir := range dirs {
48 fullpath := filepath.Join(dir, name)
49 if _, err := os.Stat(fullpath); err == nil {
50 return fullpath
51 }
52 }
53 return name
54}