mbox series

[0/7] go-mod-update-modules: identify licenses with licensecheck

Message ID 20261201034910.25521-1-tim.orling@konsulko.com
Headers show
Series go-mod-update-modules: identify licenses with licensecheck | expand

Message

Tim Orling Dec. 1, 2026, 3:49 a.m. UTC
go-mod-update-modules identifies the license files of Go module
dependencies by hash. Variant license texts, several licenses in one
file and several license files in one directory end up as spdx=Unknown,
which fails do_populate_lic, or are left out.

This series adds licensecheck, the license detection library of
pkg.go.dev, and an opt-in GO_MOD_LICENSE_SCANNER = "licensecheck" that
scans each license file with it. Hash matching stays the default. It
also:

- keeps every license file of the nearest directory
- stops files with no license text from matching "Proprietary"
- adds GO_MOD_LICENSE_STRICT, to fail do_update_modules on a license
  that is not identified
- otherwise names such a license LicenseRef-go-<module>-<file>, with
  NO_GENERIC_LICENSE, so that the recipe builds

Tested on qemux86-64: licensecheck and licensecheck-native build, and
the oelib.license_finder, distrodata test_maintainers and recipetool
test_recipetool_create_go selftests pass. For yq, hash matching leaves 5
of 30 license files unidentified (MPL-2.0, BSD-2-Clause, MIT,
Apache-2.0, BSD-3-Clause variants); licensecheck identifies all 5. With
either result, yq builds and do_create_spdx passes.

AI-Generated: Uses Claude Code (Claude Opus 5.5, Claude Fable 5.2)

Tim Orling (7):
  license_finder: keep all license files of the nearest directory
  licensecheck: add recipe
  license_finder: do not match files that have no license text
  go-mod-update-modules: identify licenses with licensecheck
  go-mod-update-modules: add GO_MOD_LICENSE_STRICT
  go-mod-update-modules: name unidentified licenses with a LicenseRef
  oeqa/selftest/oelib: add tests for license_finder

 .../go-mod-update-modules.bbclass             |  84 +++++++++-
 meta/conf/distro/include/maintainers.inc      |   1 +
 meta/lib/oe/license_finder.py                 | 115 +++++++++++++-
 .../selftest/cases/oelib/license_finder.py    | 146 ++++++++++++++++++
 .../licensecheck/files/main.go                |  49 ++++++
 .../licensecheck/licensecheck_0.3.1.bb        |  31 ++++
 6 files changed, 416 insertions(+), 10 deletions(-)
 create mode 100644 meta/lib/oeqa/selftest/cases/oelib/license_finder.py
 create mode 100644 meta/recipes-devtools/licensecheck/files/main.go
 create mode 100644 meta/recipes-devtools/licensecheck/licensecheck_0.3.1.bb