summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2024-12-10 10:33:07 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-12-12 12:55:56 +0000
commit102743c4dfe2ceedd4c0663ee6f6b14bb1f9f745 (patch)
treea21be43869aafb1f243ce3d8434705df43c16aa3 /meta/lib/oeqa
parent9b80c039add2bdd7ed70774a4c379030df6538a5 (diff)
downloadpoky-102743c4dfe2ceedd4c0663ee6f6b14bb1f9f745.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: 838d64c09657ac53175737fc4e7fd6f01f3dcf47) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-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 9b35793d13..f3b955ed2b 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):