summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2025-11-07 14:14:48 +0100
committerSteve Sakoman <steve@sakoman.com>2025-11-14 06:45:30 -0800
commit71aca87ca73e4a6e47b121702e99e59e426e713b (patch)
tree2a044451ff830dbc3773659efff765b56a43d601 /meta
parent1919d76f68524390decf84f1f8b900b31397d43a (diff)
downloadpoky-71aca87ca73e4a6e47b121702e99e59e426e713b.tar.gz
spdx 3.0: Rework how SPDX aliases are linked
The SPDX code needs to be able to look up an Element by its SPDX ID, locating the file that (should) contain the SPDX ID and opening it for parsing. Previously, the code would do this be hashing each Element SPDX ID and Alias, and the creating a symbolic link to the file that contains the element with a name of the hash. This worked well as it was possible to look up any arbitrary SPDX ID or alias by simply hashing it and following the symbolic link to get the file. However, the down side of this approach is that it creates a lot of symbolic links, since it will make one or two per Element in the document. This can be a problem when using SPDX_INCLUDE_SOURCES, for example. This change reworks this strategy so that the only Element that gets a symbolic link based on the hash is the singular SpdxDocument that is create for each file. All other Elements are assigned an alias with a special prefix that encodes the hash of SpdxDocument alias. Thus, when attempting to look up an arbitrary alias, the code sees the special prefix, extract the hash, opens the file based on the symlink with that hash name, then finds the matching Element in the file. This drastically reduces the number of symbolic links by making only one per file. This also means that the custom link extension can be removed since it is now superfluous. (From OE-Core rev: 551433c7a1eddf5090c87a243ea104bf091992b0) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 838d64c09657ac53175737fc4e7fd6f01f3dcf47) Signed-off-by: Kamel Bouhara (Schneider Electric) <kamel.bouhara@bootlin.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/cases/spdx.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py
index a54b74a59c..f22bd6c275 100644
--- a/meta/lib/oeqa/selftest/cases/spdx.py
+++ b/meta/lib/oeqa/selftest/cases/spdx.py
@@ -143,35 +143,31 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
143 def test_base_files(self): 143 def test_base_files(self):
144 self.check_recipe_spdx( 144 self.check_recipe_spdx(
145 "base-files", 145 "base-files",
146 "{DEPLOY_DIR_SPDX}/{MACHINE_ARCH}/packages/base-files.spdx.json", 146 "{DEPLOY_DIR_SPDX}/{MACHINE_ARCH}/packages/package-base-files.spdx.json",
147 ) 147 )
148 148
149
150 def test_gcc_include_source(self): 149 def test_gcc_include_source(self):
151 import oe.spdx30
152
153 objset = self.check_recipe_spdx( 150 objset = self.check_recipe_spdx(
154 "gcc", 151 "gcc",
155 "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/recipes/gcc.spdx.json", 152 "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/recipes/recipe-gcc.spdx.json",
156 extraconf=textwrap.dedent( 153 extraconf="""\
157 """\
158 SPDX_INCLUDE_SOURCES = "1" 154 SPDX_INCLUDE_SOURCES = "1"
159 """ 155 """,
160 ),
161 ) 156 )
162 157
163 gcc_pv = get_bb_var("PV", "gcc") 158 gcc_pv = get_bb_var("PV", "gcc")
164 filename = f'gcc-{gcc_pv}/README' 159 filename = f"gcc-{gcc_pv}/README"
165 found = False 160 found = False
166 for software_file in objset.foreach_type(oe.spdx30.software_File): 161 for software_file in objset.foreach_type(oe.spdx30.software_File):
167 if software_file.name == filename: 162 if software_file.name == filename:
168 found = True 163 found = True
169 self.logger.info(f"The spdxId of {filename} in gcc.spdx.json is {software_file.spdxId}") 164 self.logger.info(
165 f"The spdxId of {filename} in recipe-gcc.spdx.json is {software_file.spdxId}"
166 )
170 break 167 break
171 168
172 self.assertTrue( 169 self.assertTrue(
173 found, 170 found, f"Not found source file {filename} in recipe-gcc.spdx.json\n"
174 f"Not found source file {filename} in gcc.spdx.json\n"
175 ) 171 )
176 172
177 def test_core_image_minimal(self): 173 def test_core_image_minimal(self):