[honister,4/5] create-spdx: Protect against None from LICENSE_PATH

Message ID 123ee0fc0d1470427cc563f512f621e0172cc232.1637569916.git.anuj.mittal@intel.com
State Accepted, archived
Commit 123ee0fc0d1470427cc563f512f621e0172cc232
Headers show
Series [honister,1/5] cups: Fix missing installation of cups sysv init scripts | expand

Commit Message

Mittal, Anuj Nov. 22, 2021, 8:34 a.m. UTC
From: Saul Wold <Saul.Wold@windriver.com>

If LICENSE_PATH is not set, then the split() will fail on a NoneType.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit d6260decae6d2654f6e058f12ca02d582a8ef5a4)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
 meta/classes/create-spdx.bbclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Patch

diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass
index 1d5c8b3bc1..d0cc5b1ca2 100644
--- a/meta/classes/create-spdx.bbclass
+++ b/meta/classes/create-spdx.bbclass
@@ -92,7 +92,7 @@  def convert_license_to_spdx(lic, document, d, existing={}):
             extracted_info.extractedText = "Software released to the public domain"
         elif name in available_licenses:
             # This license can be found in COMMON_LICENSE_DIR or LICENSE_PATH
-            for directory in [d.getVar('COMMON_LICENSE_DIR')] + d.getVar('LICENSE_PATH').split():
+            for directory in [d.getVar('COMMON_LICENSE_DIR')] + (d.getVar('LICENSE_PATH') or '').split():
                 try:
                     with (Path(directory) / name).open(errors="replace") as f:
                         extracted_info.extractedText = f.read()
@@ -145,7 +145,6 @@  def convert_license_to_spdx(lic, document, d, existing={}):
 
     return ' '.join(convert(l) for l in lic_split)
 
-
 def process_sources(d):
     pn = d.getVar('PN')
     assume_provided = (d.getVar("ASSUME_PROVIDED") or "").split()