summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMike Crowe <mac@mcrowe.com>2021-10-15 15:39:54 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-17 11:56:33 +0100
commitcdeb02654fbaa47677b5c68521d05a5a575ac90d (patch)
treea8951fd93b91b0a3c64336a79bd74c68fba7c8d3 /meta
parent51b1611e204b32b3e65176ef86d4562e2f330835 (diff)
downloadpoky-cdeb02654fbaa47677b5c68521d05a5a575ac90d.tar.gz
insane,license,license_image: Allow treating license problems as errors
Use the same WARN_WA and ERROR_QA variables as insane.bbclass to allow individual recipes, the distro or other configuration to determine whether the various detected license errors should be treated as a warning (as now) or as an error. oe.qa.handle_error isn't immediately fatal, so oe.qa.exit_if_errors must be called at the end of do_populate_lic to fail the task. (From OE-Core rev: bb164adca94b5a43751aabe6b6d702a3d60dfdc7) Signed-off-by: Mike Crowe <mac@mcrowe.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/insane.bbclass2
-rw-r--r--meta/classes/license.bbclass20
-rw-r--r--meta/classes/license_image.bbclass11
3 files changed, 21 insertions, 12 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 9ad9771dfa..1e2f1b768a 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -26,6 +26,8 @@ WARN_QA ?= " libdir xorg-driver-abi \
26 invalid-packageconfig host-user-contaminated uppercase-pn patch-fuzz \ 26 invalid-packageconfig host-user-contaminated uppercase-pn patch-fuzz \
27 mime mime-xdg unlisted-pkg-lics unhandled-features-check \ 27 mime mime-xdg unlisted-pkg-lics unhandled-features-check \
28 missing-update-alternatives native-last missing-ptest \ 28 missing-update-alternatives native-last missing-ptest \
29 license-exists license-no-generic license-syntax license-format \
30 license-incompatible license-file-missing \
29 " 31 "
30ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \ 32ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
31 perms dep-cmp pkgvarcheck perm-config perm-line perm-link \ 33 perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 7a34e185c7..d5480d87e2 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -29,6 +29,7 @@ python do_populate_lic() {
29 with open(os.path.join(destdir, "recipeinfo"), "w") as f: 29 with open(os.path.join(destdir, "recipeinfo"), "w") as f:
30 for key in sorted(info.keys()): 30 for key in sorted(info.keys()):
31 f.write("%s: %s\n" % (key, info[key])) 31 f.write("%s: %s\n" % (key, info[key]))
32 oe.qa.exit_if_errors(d)
32} 33}
33 34
34PSEUDO_IGNORE_PATHS .= ",${@','.join(((d.getVar('COMMON_LICENSE_DIR') or '') + ' ' + (d.getVar('LICENSE_PATH') or '') + ' ' + d.getVar('COREBASE') + '/meta/COPYING').split())}" 35PSEUDO_IGNORE_PATHS .= ",${@','.join(((d.getVar('COMMON_LICENSE_DIR') or '') + ' ' + (d.getVar('LICENSE_PATH') or '') + ' ' + d.getVar('COREBASE') + '/meta/COPYING').split())}"
@@ -182,7 +183,8 @@ def find_license_files(d):
182 # The user may attempt to use NO_GENERIC_LICENSE for a generic license which doesn't make sense 183 # The user may attempt to use NO_GENERIC_LICENSE for a generic license which doesn't make sense
183 # and should not be allowed, warn the user in this case. 184 # and should not be allowed, warn the user in this case.
184 if d.getVarFlag('NO_GENERIC_LICENSE', license_type): 185 if d.getVarFlag('NO_GENERIC_LICENSE', license_type):
185 bb.warn("%s: %s is a generic license, please don't use NO_GENERIC_LICENSE for it." % (pn, license_type)) 186 oe.qa.handle_error("license-no-generic",
187 "%s: %s is a generic license, please don't use NO_GENERIC_LICENSE for it." % (pn, license_type), d)
186 188
187 elif non_generic_lic and non_generic_lic in lic_chksums: 189 elif non_generic_lic and non_generic_lic in lic_chksums:
188 # if NO_GENERIC_LICENSE is set, we copy the license files from the fetched source 190 # if NO_GENERIC_LICENSE is set, we copy the license files from the fetched source
@@ -194,7 +196,8 @@ def find_license_files(d):
194 # Add explicity avoid of CLOSED license because this isn't generic 196 # Add explicity avoid of CLOSED license because this isn't generic
195 if license_type != 'CLOSED': 197 if license_type != 'CLOSED':
196 # And here is where we warn people that their licenses are lousy 198 # And here is where we warn people that their licenses are lousy
197 bb.warn("%s: No generic license file exists for: %s in any provider" % (pn, license_type)) 199 oe.qa.handle_error("license-exists",
200 "%s: No generic license file exists for: %s in any provider" % (pn, license_type), d)
198 pass 201 pass
199 202
200 if not generic_directory: 203 if not generic_directory:
@@ -219,7 +222,8 @@ def find_license_files(d):
219 except oe.license.InvalidLicense as exc: 222 except oe.license.InvalidLicense as exc:
220 bb.fatal('%s: %s' % (d.getVar('PF'), exc)) 223 bb.fatal('%s: %s' % (d.getVar('PF'), exc))
221 except SyntaxError: 224 except SyntaxError:
222 bb.warn("%s: Failed to parse it's LICENSE field." % (d.getVar('PF'))) 225 oe.qa.handle_error("license-syntax",
226 "%s: Failed to parse it's LICENSE field." % (d.getVar('PF')), d)
223 # Add files from LIC_FILES_CHKSUM to list of license files 227 # Add files from LIC_FILES_CHKSUM to list of license files
224 lic_chksum_paths = defaultdict(OrderedDict) 228 lic_chksum_paths = defaultdict(OrderedDict)
225 for path, data in sorted(lic_chksums.items()): 229 for path, data in sorted(lic_chksums.items()):
@@ -410,14 +414,16 @@ def check_license_format(d):
410 for pos, element in enumerate(elements): 414 for pos, element in enumerate(elements):
411 if license_pattern.match(element): 415 if license_pattern.match(element):
412 if pos > 0 and license_pattern.match(elements[pos - 1]): 416 if pos > 0 and license_pattern.match(elements[pos - 1]):
413 bb.warn('%s: LICENSE value "%s" has an invalid format - license names ' \ 417 oe.qa.handle_error('license-format',
418 '%s: LICENSE value "%s" has an invalid format - license names ' \
414 'must be separated by the following characters to indicate ' \ 419 'must be separated by the following characters to indicate ' \
415 'the license selection: %s' % 420 'the license selection: %s' %
416 (pn, licenses, license_operator_chars)) 421 (pn, licenses, license_operator_chars), d)
417 elif not license_operator.match(element): 422 elif not license_operator.match(element):
418 bb.warn('%s: LICENSE value "%s" has an invalid separator "%s" that is not ' \ 423 oe.qa.handle_error('license-format',
424 '%s: LICENSE value "%s" has an invalid separator "%s" that is not ' \
419 'in the valid list of separators (%s)' % 425 'in the valid list of separators (%s)' %
420 (pn, licenses, element, license_operator_chars)) 426 (pn, licenses, element, license_operator_chars), d)
421 427
422SSTATETASKS += "do_populate_lic" 428SSTATETASKS += "do_populate_lic"
423do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}" 429do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"
diff --git a/meta/classes/license_image.bbclass b/meta/classes/license_image.bbclass
index 5490d121f1..bf70bee99b 100644
--- a/meta/classes/license_image.bbclass
+++ b/meta/classes/license_image.bbclass
@@ -75,7 +75,7 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True):
75 pkg_dic[pkg]["LICENSES"] = re.sub(r' *', ' ', pkg_dic[pkg]["LICENSES"]) 75 pkg_dic[pkg]["LICENSES"] = re.sub(r' *', ' ', pkg_dic[pkg]["LICENSES"])
76 pkg_dic[pkg]["LICENSES"] = pkg_dic[pkg]["LICENSES"].split() 76 pkg_dic[pkg]["LICENSES"] = pkg_dic[pkg]["LICENSES"].split()
77 if pkg in whitelist: 77 if pkg in whitelist:
78 bb.warn("Including %s with an incompatible license %s into the image, because it has been whitelisted." %(pkg, pkg_dic[pkg]["LICENSE"])) 78 oe.qa.handle_error('license-incompatible', "Including %s with an incompatible license %s into the image, because it has been whitelisted." %(pkg, pkg_dic[pkg]["LICENSE"]), d)
79 79
80 if not "IMAGE_MANIFEST" in pkg_dic[pkg]: 80 if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
81 # Rootfs manifest 81 # Rootfs manifest
@@ -105,10 +105,10 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True):
105 continue 105 continue
106 106
107 if not os.path.exists(lic_file): 107 if not os.path.exists(lic_file):
108 bb.warn("The license listed %s was not in the "\ 108 oe.qa.handle_error('license-file-missing',
109 "licenses collected for recipe %s" 109 "The license listed %s was not in the "\
110 % (lic, pkg_dic[pkg]["PN"])) 110 "licenses collected for recipe %s"
111 111 % (lic, pkg_dic[pkg]["PN"]), d)
112 # Two options here: 112 # Two options here:
113 # - Just copy the manifest 113 # - Just copy the manifest
114 # - Copy the manifest and the license directories 114 # - Copy the manifest and the license directories
@@ -274,6 +274,7 @@ do_rootfs[recrdeptask] += "do_populate_lic"
274 274
275python do_populate_lic_deploy() { 275python do_populate_lic_deploy() {
276 license_deployed_manifest(d) 276 license_deployed_manifest(d)
277 oe.qa.exit_if_errors(d)
277} 278}
278 279
279addtask populate_lic_deploy before do_build after do_image_complete 280addtask populate_lic_deploy before do_build after do_image_complete