跳到主要内容

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

浏览文件

toolexec-for-codesign.sh

57 行 · 1.7 KB历史下载
1#!/bin/sh
2
3# SPDX-FileCopyrightText: Copyright The Lima Authors
4# SPDX-License-Identifier: Apache-2.0
5
6# This script is used to wrap the compiler and linker commands in the build
7# process. It captures the output of the command and logs it to a file.
8# The script's primary purpose is codesigning the output of the linker command
9# with the entitlements file if it exists.
10# If the OS is macOS, the result of the command is 0, the entitlements file
11# exists, and codesign is available, sign the output of the linker command with
12# the entitlements file.
13#
14# Usage:
15# go build -toolexec hack/toolexec-to-codesign.sh
16
17repository_root="$(dirname "$(dirname "$0")")"
18logfile="${repository_root}/.toolexec-to-codesign.log"
19
20echo $$: cmd: "$@" >>"${logfile}"
21
22output="$("$@")"
23result=$?
24
25echo $$: output: "${output}" >>"${logfile}"
26
27entitlements="${repository_root}/vz.entitlements"
28
29# If the OS is macOS, the result of the command is 0, the entitlements file
30# exists, and codesign is available, sign the output of the linker command.
31if OS=$(uname -s) && [ "${OS}" = "Darwin" ] && [ "${result}" -eq 0 ] && [ -f "${entitlements}" ] && command -v codesign >/dev/null 2>&1; then
32 # Check if the command is a linker command.
33 case "$1" in
34 *link)
35 shift
36 # Find a parameter that is a output file.
37 while [ $# -gt 1 ]; do
38 case "$1" in
39 -o)
40 # If the output file is a executable, sign it with the entitlements file.
41 if [ -x "$2" ]; then
42 codesign_output="$(codesign -v --entitlements "${entitlements}" -s - "$2" 2>&1)"
43 echo "$$: ${codesign_output}" >>"${logfile}"
44 fi
45 break
46 ;;
47 *) shift ;;
48 esac
49 done
50 ;;
51 *) ;;
52 esac
53fi
54
55# Print the output of the command and exit with the result of the command.
56echo "${output}"
57exit "${result}"