@@ -19,6 +19,10 @@ do_update_modules[network] = "1"
GO_MOD_LICENSE_SCANNER ??= ""
do_update_modules[depends] += "${@'licensecheck-native:do_populate_sysroot' if d.getVar('GO_MOD_LICENSE_SCANNER') == 'licensecheck' else ''}"
+# Set to "1" to fail, without writing the files, when the license of a file is
+# not identified. The error lists the hashes to add to a license-hashes.csv.
+GO_MOD_LICENSE_STRICT ??= "0"
+
python do_update_modules() {
import subprocess, tempfile, json, re, urllib.parse
from oe.license_finder import find_licenses_up
@@ -120,6 +124,15 @@ python do_update_modules() {
bb.note(f"{lic_file}: no license beyond {' '.join(sorted(declared))}, left out")
del lic_files[lic_file]
+ unknown = [(f, md5) for f, (node, md5) in lic_files.items()
+ if isinstance(node, oe.spdx_license.UnknownId)]
+ if unknown and bb.utils.to_boolean(d.getVar("GO_MOD_LICENSE_STRICT")):
+ bb.fatal("Licenses not identified, %s-licenses.inc not written:\n%s\n"
+ "Once each license is verified, add md5,SPDX lines like these to a "
+ "files/license-hashes.csv in a layer:\n%s" % (
+ bpn, "\n".join(f" {f}" for f, _ in unknown),
+ "\n".join(sorted({f" {md5},Unknown" for _, md5 in unknown}))))
+
licenses = []
lic_files_chksum = []
for lic_file in lic_files:
A license file that is not identified only gives a warning, which is easy to miss in an upgrade. Add GO_MOD_LICENSE_STRICT. Set to "1", do_update_modules fails without writing the files, and lists the unidentified files and the md5,SPDX lines to complete and add to a license-hashes.csv. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- meta/classes-recipe/go-mod-update-modules.bbclass | 13 +++++++++++++ 1 file changed, 13 insertions(+)