-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Handle architecture-specific license dependencies #1581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the license generation script to properly handle architecture-specific dependency differences across GOOS/GOARCH combinations. The script now generates separate reports per architecture, groups identical results with comma-separated headers, and adds a table of contents to each platform file.
Key changes:
- Multi-architecture license generation for Linux (amd64, arm64, 386), Darwin (amd64, arm64), and Windows (amd64, arm64, 386)
- Grouping logic that consolidates architectures with identical dependency lists
- Automated table of contents generation with anchor links
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| script/licenses | Complete rewrite to support multi-architecture license generation with grouping logic, TOC generation, and per-arch report handling |
| third-party-licenses.linux.md | Restructured with TOC and architecture sections; packages reordered alphabetically |
| third-party-licenses.darwin.md | Restructured with TOC and architecture sections; packages reordered alphabetically |
| third-party-licenses.windows.md | Restructured with TOC and architecture sections; packages reordered alphabetically |
Address review feedback: - Remove bash 4.0+ associative array requirement for macOS compatibility - Add cross-platform hash function (md5sum on Linux, md5 on macOS) - Ensure deterministic iteration order using sorted groups file - Add better error handling for failed go-licenses commands - Fix grammar: 'architecture(s)' -> 'architectures' - Add documentation for third-party/ being a union of all architectures - Use file-based state instead of associative arrays for portability
ee28e6d to
8855c2c
Compare
- Check now regenerates using ./script/licenses and compares - Add GOROOT/PATH setup in CI to fix go-licenses module info errors - Check both license files AND third-party directory for changes - See: google/go-licenses#244
8855c2c to
eb7d73c
Compare
The sort command uses locale-specific ordering which can differ between systems. Use LC_ALL=C to ensure consistent ordering in CI and locally.
Summary
This PR improves the license script to handle architecture-specific dependency differences. Some dependencies have different module graphs for different GOARCH values (e.g.,
x/sys/cpuvsx/sys/unix), which can result in different licenses being exported per architecture.Problem
As discovered in github/cli, some deps change which changes the mod graph for different GOARCH values. For example:
amd64might havex/sys/cpuandx/sys/unixso the common ancestor isx/sysarm64might just havex/sys/unixso the common ancestor isx/sys/unixThis means license reports can differ between architectures on the same platform.
Solution
Updated
script/licensesto:Changes
script/licenses: Enhanced to handle multi-architecture license generation with groupingthird-party-licenses.*.md: Updated with architecture sections and indexthird-party/: Contains architecture-specific license foldersExample Output
When all architectures have the same deps:
When architectures differ: