fix: Handle architecture-specific license dependencies#1581
Merged
SamMorrowDrums merged 5 commits intomainfrom Dec 12, 2025
Merged
fix: Handle architecture-specific license dependencies#1581SamMorrowDrums merged 5 commits intomainfrom
SamMorrowDrums merged 5 commits intomainfrom
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.
Contributor
There was a problem hiding this comment.
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.
tommaso-moro
approved these changes
Dec 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: