diff mbox series

[oe] classes/create-spdx-2.2: allow absolute paths in NO_GENERIC_LICENSE

Message ID 20230809081806.1813479-1-max.oss.09@gmail.com
State New
Headers show
Series [oe] classes/create-spdx-2.2: allow absolute paths in NO_GENERIC_LICENSE | expand

Commit Message

Max Krummenacher Aug. 9, 2023, 8:18 a.m. UTC
From: Max Krummenacher <max.krummenacher@toradex.com>

The current implementation expects the license file in NO_GENERIC_LICENSE
specified as being relative to ${S}.
Assuming that there are two source locations this gets confusing to
specify, e.g. ${WORKDIR}/other_tree/file looks more natural than
${S}/../other_tree/file.

Check if the filename specified is not absolute and only then assume
it is relative to ${S}.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
---
 meta/classes/create-spdx-2.2.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index 844b674f6f..42d4ef54b0 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -134,7 +134,8 @@  def convert_license_to_spdx(lic, document, d, existing={}):
                 # If it's not SPDX or PD, then NO_GENERIC_LICENSE must be set
                 filename = d.getVarFlag('NO_GENERIC_LICENSE', name)
                 if filename:
-                    filename = d.expand("${S}/" + filename)
+                    if not Path(filename).is_absolute():
+                        filename = d.expand("${S}/" + filename)
                     with open(filename, errors="replace") as f:
                         extracted_info.extractedText = f.read()
                 else: