🌐 AI搜索 & 代理 主页
Skip to content

Commit 87ea319

Browse files
fix: handle architecture-specific license differences
The licenses script now: - Generates separate license reports per GOOS/GOARCH combination - Groups identical reports together (comma-separated arch names) - Adds a Table of Contents at the top of each platform file - Handles cases where different architectures have different dependencies (e.g., x/sys/unix vs x/sys/windows, mousetrap on Windows only) This addresses the issue discovered in cli/cli where some deps changed which changed the mod graph for different GOARCH and affected the exported licenses because go-licenses tries to find common ancestors.
1 parent 5cd95dc commit 87ea319

File tree

4 files changed

+148
-27
lines changed

4 files changed

+148
-27
lines changed

script/licenses

Lines changed: 115 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
#!/bin/bash
2+
#
3+
# Generate license files for all platform/arch combinations.
4+
# This script handles architecture-specific dependency differences by:
5+
# 1. Generating separate license reports per GOOS/GOARCH combination
6+
# 2. Grouping identical reports together (comma-separated arch names)
7+
# 3. Creating an index at the top of each platform file
8+
# 4. Copying all license files to third-party/
9+
#
10+
# Note: we ignore warnings because we want the command to succeed, however the output should be checked
11+
# for any new warnings, and potentially we may need to add license information.
12+
#
13+
# Normally these warnings are packages containing non go code, which may or may not require explicit attribution,
14+
# depending on the license.
15+
16+
set -e
217

318
go install github.com/google/go-licenses@latest
419

@@ -8,14 +23,105 @@ export TEMPDIR="$(mktemp -d)"
823

924
trap "rm -fr ${TEMPDIR}" EXIT
1025

11-
for goos in linux darwin windows ; do
12-
# Note: we ignore warnings because we want the command to succeed, however the output should be checked
13-
# for any new warnings, and potentially we may need to add license information.
14-
#
15-
# Normally these warnings are packages containing non go code, which may or may not require explicit attribution,
16-
# depending on the license.
17-
GOOS="${goos}" GOFLAGS=-mod=mod go-licenses save ./... --save_path="${TEMPDIR}/${goos}" --force || echo "Ignore warnings"
18-
GOOS="${goos}" GOFLAGS=-mod=mod go-licenses report ./... --template .github/licenses.tmpl > third-party-licenses.${goos}.md || echo "Ignore warnings"
19-
cp -fR "${TEMPDIR}/${goos}"/* third-party/
26+
# Define platforms and their architectures
27+
declare -A PLATFORM_ARCHS
28+
PLATFORM_ARCHS["linux"]="amd64 arm64 386"
29+
PLATFORM_ARCHS["darwin"]="amd64 arm64"
30+
PLATFORM_ARCHS["windows"]="amd64 arm64 386"
31+
32+
# Generate reports for each platform/arch combination
33+
for goos in linux darwin windows; do
34+
echo "Processing ${goos}..."
35+
36+
# Store reports per arch for this platform
37+
declare -A ARCH_REPORTS
38+
declare -A ARCH_HASHES
39+
40+
for goarch in ${PLATFORM_ARCHS[$goos]}; do
41+
echo " Generating for ${goos}/${goarch}..."
42+
43+
# Generate the license report for this arch
44+
report_file="${TEMPDIR}/${goos}_${goarch}_report.md"
45+
GOOS="${goos}" GOARCH="${goarch}" GOFLAGS=-mod=mod go-licenses report ./... --template .github/licenses.tmpl > "${report_file}" 2>/dev/null || echo " (warnings ignored for ${goos}/${goarch})"
46+
47+
# Save licenses to temp directory
48+
GOOS="${goos}" GOARCH="${goarch}" GOFLAGS=-mod=mod go-licenses save ./... --save_path="${TEMPDIR}/${goos}_${goarch}" --force 2>/dev/null || echo " (warnings ignored for ${goos}/${goarch})"
49+
50+
# Copy to third-party (accumulate all)
51+
if [ -d "${TEMPDIR}/${goos}_${goarch}" ]; then
52+
cp -fR "${TEMPDIR}/${goos}_${goarch}"/* third-party/ 2>/dev/null || true
53+
fi
54+
55+
# Extract just the package list (skip header) and hash it
56+
packages=$(grep -E '^ - \[' "${report_file}" 2>/dev/null | sort || echo "")
57+
hash=$(echo "${packages}" | md5sum | cut -d' ' -f1)
58+
59+
ARCH_REPORTS["${goarch}"]="${packages}"
60+
ARCH_HASHES["${goarch}"]="${hash}"
61+
done
62+
63+
# Group architectures with identical reports
64+
declare -A HASH_TO_ARCHS
65+
for goarch in ${PLATFORM_ARCHS[$goos]}; do
66+
hash="${ARCH_HASHES[$goarch]}"
67+
if [ -n "${HASH_TO_ARCHS[$hash]}" ]; then
68+
HASH_TO_ARCHS["${hash}"]="${HASH_TO_ARCHS[$hash]}, ${goarch}"
69+
else
70+
HASH_TO_ARCHS["${hash}"]="${goarch}"
71+
fi
72+
done
73+
74+
# Generate the combined report for this platform
75+
output_file="third-party-licenses.${goos}.md"
76+
77+
cat > "${output_file}" << 'EOF'
78+
# GitHub MCP Server dependencies
79+
80+
The following open source dependencies are used to build the [github/github-mcp-server][] GitHub Model Context Protocol Server.
81+
82+
## Table of Contents
83+
84+
EOF
85+
86+
# Build table of contents
87+
for hash in "${!HASH_TO_ARCHS[@]}"; do
88+
archs="${HASH_TO_ARCHS[$hash]}"
89+
# Create anchor-friendly name
90+
anchor=$(echo "${archs}" | tr ', ' '-' | tr -s '-')
91+
echo "- [${archs}](#${anchor})" >> "${output_file}"
92+
done
93+
94+
echo "" >> "${output_file}"
95+
echo "---" >> "${output_file}"
96+
echo "" >> "${output_file}"
97+
98+
# Add each unique report section
99+
for hash in "${!HASH_TO_ARCHS[@]}"; do
100+
archs="${HASH_TO_ARCHS[$hash]}"
101+
# Get the packages from the first arch in this group
102+
first_arch=$(echo "${archs}" | cut -d',' -f1 | tr -d ' ')
103+
packages="${ARCH_REPORTS[$first_arch]}"
104+
105+
cat >> "${output_file}" << EOF
106+
## ${archs}
107+
108+
The following packages are included for the ${archs} architecture(s).
109+
110+
${packages}
111+
112+
EOF
113+
done
114+
115+
# Add footer
116+
echo "[github/github-mcp-server]: https://github.com/github/github-mcp-server" >> "${output_file}"
117+
118+
echo "Generated ${output_file}"
119+
120+
# Clean up associative arrays for next platform
121+
unset ARCH_REPORTS
122+
unset ARCH_HASHES
123+
unset HASH_TO_ARCHS
20124
done
21125

126+
echo "Done! License files generated."
127+

third-party-licenses.darwin.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22

33
The following open source dependencies are used to build the [github/github-mcp-server][] GitHub Model Context Protocol Server.
44

5-
## Go Packages
5+
## Table of Contents
66

7-
Some packages may only be included on certain architectures or operating systems.
7+
- [amd64, arm64](#amd64-arm64)
88

9+
---
10+
11+
## amd64, arm64
12+
13+
The following packages are included for the amd64, arm64 architecture(s).
914

1015
- [github.com/aymerick/douceur](https://pkg.go.dev/github.com/aymerick/douceur) ([MIT](https://github.com/aymerick/douceur/blob/v0.2.0/LICENSE))
1116
- [github.com/fsnotify/fsnotify](https://pkg.go.dev/github.com/fsnotify/fsnotify) ([BSD-3-Clause](https://github.com/fsnotify/fsnotify/blob/v1.9.0/LICENSE))
1217
- [github.com/github/github-mcp-server](https://pkg.go.dev/github.com/github/github-mcp-server) ([MIT](https://github.com/github/github-mcp-server/blob/HEAD/LICENSE))
13-
- [github.com/go-openapi/jsonpointer](https://pkg.go.dev/github.com/go-openapi/jsonpointer) ([Apache-2.0](https://github.com/go-openapi/jsonpointer/blob/v0.19.5/LICENSE))
14-
- [github.com/go-openapi/swag](https://pkg.go.dev/github.com/go-openapi/swag) ([Apache-2.0](https://github.com/go-openapi/swag/blob/v0.21.1/LICENSE))
15-
- [github.com/go-viper/mapstructure/v2](https://pkg.go.dev/github.com/go-viper/mapstructure/v2) ([MIT](https://github.com/go-viper/mapstructure/blob/v2.4.0/LICENSE))
1618
- [github.com/google/go-github/v71/github](https://pkg.go.dev/github.com/google/go-github/v71/github) ([BSD-3-Clause](https://github.com/google/go-github/blob/v71.0.0/LICENSE))
1719
- [github.com/google/go-github/v79/github](https://pkg.go.dev/github.com/google/go-github/v79/github) ([BSD-3-Clause](https://github.com/google/go-github/blob/v79.0.0/LICENSE))
1820
- [github.com/google/go-querystring/query](https://pkg.go.dev/github.com/google/go-querystring/query) ([BSD-3-Clause](https://github.com/google/go-querystring/blob/v1.1.0/LICENSE))
1921
- [github.com/google/jsonschema-go/jsonschema](https://pkg.go.dev/github.com/google/jsonschema-go/jsonschema) ([MIT](https://github.com/google/jsonschema-go/blob/v0.3.0/LICENSE))
22+
- [github.com/go-openapi/jsonpointer](https://pkg.go.dev/github.com/go-openapi/jsonpointer) ([Apache-2.0](https://github.com/go-openapi/jsonpointer/blob/v0.19.5/LICENSE))
23+
- [github.com/go-openapi/swag](https://pkg.go.dev/github.com/go-openapi/swag) ([Apache-2.0](https://github.com/go-openapi/swag/blob/v0.21.1/LICENSE))
2024
- [github.com/gorilla/css/scanner](https://pkg.go.dev/github.com/gorilla/css/scanner) ([BSD-3-Clause](https://github.com/gorilla/css/blob/v1.0.1/LICENSE))
2125
- [github.com/gorilla/mux](https://pkg.go.dev/github.com/gorilla/mux) ([BSD-3-Clause](https://github.com/gorilla/mux/blob/v1.8.0/LICENSE))
26+
- [github.com/go-viper/mapstructure/v2](https://pkg.go.dev/github.com/go-viper/mapstructure/v2) ([MIT](https://github.com/go-viper/mapstructure/blob/v2.4.0/LICENSE))
2227
- [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v1.9.2/LICENSE))
2328
- [github.com/josharian/intern](https://pkg.go.dev/github.com/josharian/intern) ([MIT](https://github.com/josharian/intern/blob/v1.0.0/license.md))
2429
- [github.com/mailru/easyjson](https://pkg.go.dev/github.com/mailru/easyjson) ([MIT](https://github.com/mailru/easyjson/blob/v0.7.7/LICENSE))
@@ -39,12 +44,12 @@ Some packages may only be included on certain architectures or operating systems
3944
- [github.com/subosito/gotenv](https://pkg.go.dev/github.com/subosito/gotenv) ([MIT](https://github.com/subosito/gotenv/blob/v1.6.0/LICENSE))
4045
- [github.com/yosida95/uritemplate/v3](https://pkg.go.dev/github.com/yosida95/uritemplate/v3) ([BSD-3-Clause](https://github.com/yosida95/uritemplate/blob/v3.0.2/LICENSE))
4146
- [github.com/yudai/golcs](https://pkg.go.dev/github.com/yudai/golcs) ([MIT](https://github.com/yudai/golcs/blob/ecda9a501e82/LICENSE))
42-
- [go.yaml.in/yaml/v3](https://pkg.go.dev/go.yaml.in/yaml/v3) ([MIT](https://github.com/yaml/go-yaml/blob/v3.0.4/LICENSE))
4347
- [golang.org/x/exp](https://pkg.go.dev/golang.org/x/exp) ([BSD-3-Clause](https://cs.opensource.google/go/x/exp/+/8a7402ab:LICENSE))
4448
- [golang.org/x/net/html](https://pkg.go.dev/golang.org/x/net/html) ([BSD-3-Clause](https://cs.opensource.google/go/x/net/+/v0.38.0:LICENSE))
4549
- [golang.org/x/sys/unix](https://pkg.go.dev/golang.org/x/sys/unix) ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.31.0:LICENSE))
4650
- [golang.org/x/text](https://pkg.go.dev/golang.org/x/text) ([BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.28.0:LICENSE))
4751
- [golang.org/x/time/rate](https://pkg.go.dev/golang.org/x/time/rate) ([BSD-3-Clause](https://cs.opensource.google/go/x/time/+/v0.5.0:LICENSE))
4852
- [gopkg.in/yaml.v2](https://pkg.go.dev/gopkg.in/yaml.v2) ([Apache-2.0](https://github.com/go-yaml/yaml/blob/v2.4.0/LICENSE))
53+
- [go.yaml.in/yaml/v3](https://pkg.go.dev/go.yaml.in/yaml/v3) ([MIT](https://github.com/yaml/go-yaml/blob/v3.0.4/LICENSE))
4954

5055
[github/github-mcp-server]: https://github.com/github/github-mcp-server

third-party-licenses.linux.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22

33
The following open source dependencies are used to build the [github/github-mcp-server][] GitHub Model Context Protocol Server.
44

5-
## Go Packages
5+
## Table of Contents
66

7-
Some packages may only be included on certain architectures or operating systems.
7+
- [amd64, arm64, 386](#amd64-arm64-386)
88

9+
---
10+
11+
## amd64, arm64, 386
12+
13+
The following packages are included for the amd64, arm64, 386 architecture(s).
914

1015
- [github.com/aymerick/douceur](https://pkg.go.dev/github.com/aymerick/douceur) ([MIT](https://github.com/aymerick/douceur/blob/v0.2.0/LICENSE))
1116
- [github.com/fsnotify/fsnotify](https://pkg.go.dev/github.com/fsnotify/fsnotify) ([BSD-3-Clause](https://github.com/fsnotify/fsnotify/blob/v1.9.0/LICENSE))
1217
- [github.com/github/github-mcp-server](https://pkg.go.dev/github.com/github/github-mcp-server) ([MIT](https://github.com/github/github-mcp-server/blob/HEAD/LICENSE))
13-
- [github.com/go-openapi/jsonpointer](https://pkg.go.dev/github.com/go-openapi/jsonpointer) ([Apache-2.0](https://github.com/go-openapi/jsonpointer/blob/v0.19.5/LICENSE))
14-
- [github.com/go-openapi/swag](https://pkg.go.dev/github.com/go-openapi/swag) ([Apache-2.0](https://github.com/go-openapi/swag/blob/v0.21.1/LICENSE))
15-
- [github.com/go-viper/mapstructure/v2](https://pkg.go.dev/github.com/go-viper/mapstructure/v2) ([MIT](https://github.com/go-viper/mapstructure/blob/v2.4.0/LICENSE))
1618
- [github.com/google/go-github/v71/github](https://pkg.go.dev/github.com/google/go-github/v71/github) ([BSD-3-Clause](https://github.com/google/go-github/blob/v71.0.0/LICENSE))
1719
- [github.com/google/go-github/v79/github](https://pkg.go.dev/github.com/google/go-github/v79/github) ([BSD-3-Clause](https://github.com/google/go-github/blob/v79.0.0/LICENSE))
1820
- [github.com/google/go-querystring/query](https://pkg.go.dev/github.com/google/go-querystring/query) ([BSD-3-Clause](https://github.com/google/go-querystring/blob/v1.1.0/LICENSE))
1921
- [github.com/google/jsonschema-go/jsonschema](https://pkg.go.dev/github.com/google/jsonschema-go/jsonschema) ([MIT](https://github.com/google/jsonschema-go/blob/v0.3.0/LICENSE))
22+
- [github.com/go-openapi/jsonpointer](https://pkg.go.dev/github.com/go-openapi/jsonpointer) ([Apache-2.0](https://github.com/go-openapi/jsonpointer/blob/v0.19.5/LICENSE))
23+
- [github.com/go-openapi/swag](https://pkg.go.dev/github.com/go-openapi/swag) ([Apache-2.0](https://github.com/go-openapi/swag/blob/v0.21.1/LICENSE))
2024
- [github.com/gorilla/css/scanner](https://pkg.go.dev/github.com/gorilla/css/scanner) ([BSD-3-Clause](https://github.com/gorilla/css/blob/v1.0.1/LICENSE))
2125
- [github.com/gorilla/mux](https://pkg.go.dev/github.com/gorilla/mux) ([BSD-3-Clause](https://github.com/gorilla/mux/blob/v1.8.0/LICENSE))
26+
- [github.com/go-viper/mapstructure/v2](https://pkg.go.dev/github.com/go-viper/mapstructure/v2) ([MIT](https://github.com/go-viper/mapstructure/blob/v2.4.0/LICENSE))
2227
- [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v1.9.2/LICENSE))
2328
- [github.com/josharian/intern](https://pkg.go.dev/github.com/josharian/intern) ([MIT](https://github.com/josharian/intern/blob/v1.0.0/license.md))
2429
- [github.com/mailru/easyjson](https://pkg.go.dev/github.com/mailru/easyjson) ([MIT](https://github.com/mailru/easyjson/blob/v0.7.7/LICENSE))
@@ -39,12 +44,12 @@ Some packages may only be included on certain architectures or operating systems
3944
- [github.com/subosito/gotenv](https://pkg.go.dev/github.com/subosito/gotenv) ([MIT](https://github.com/subosito/gotenv/blob/v1.6.0/LICENSE))
4045
- [github.com/yosida95/uritemplate/v3](https://pkg.go.dev/github.com/yosida95/uritemplate/v3) ([BSD-3-Clause](https://github.com/yosida95/uritemplate/blob/v3.0.2/LICENSE))
4146
- [github.com/yudai/golcs](https://pkg.go.dev/github.com/yudai/golcs) ([MIT](https://github.com/yudai/golcs/blob/ecda9a501e82/LICENSE))
42-
- [go.yaml.in/yaml/v3](https://pkg.go.dev/go.yaml.in/yaml/v3) ([MIT](https://github.com/yaml/go-yaml/blob/v3.0.4/LICENSE))
4347
- [golang.org/x/exp](https://pkg.go.dev/golang.org/x/exp) ([BSD-3-Clause](https://cs.opensource.google/go/x/exp/+/8a7402ab:LICENSE))
4448
- [golang.org/x/net/html](https://pkg.go.dev/golang.org/x/net/html) ([BSD-3-Clause](https://cs.opensource.google/go/x/net/+/v0.38.0:LICENSE))
4549
- [golang.org/x/sys/unix](https://pkg.go.dev/golang.org/x/sys/unix) ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.31.0:LICENSE))
4650
- [golang.org/x/text](https://pkg.go.dev/golang.org/x/text) ([BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.28.0:LICENSE))
4751
- [golang.org/x/time/rate](https://pkg.go.dev/golang.org/x/time/rate) ([BSD-3-Clause](https://cs.opensource.google/go/x/time/+/v0.5.0:LICENSE))
4852
- [gopkg.in/yaml.v2](https://pkg.go.dev/gopkg.in/yaml.v2) ([Apache-2.0](https://github.com/go-yaml/yaml/blob/v2.4.0/LICENSE))
53+
- [go.yaml.in/yaml/v3](https://pkg.go.dev/go.yaml.in/yaml/v3) ([MIT](https://github.com/yaml/go-yaml/blob/v3.0.4/LICENSE))
4954

5055
[github/github-mcp-server]: https://github.com/github/github-mcp-server

0 commit comments

Comments
 (0)