diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2024-10-29 22:07:44 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-01 12:07:12 +0000 |
commit | ce192383d5ace25f50462341165340052097108a (patch) | |
tree | 9ccefca643a7cf6663b4feb04bd5ddbba7d85c7b | |
parent | 8f4759806ee868a32a063943059345641eb26f22 (diff) | |
download | poky-ce192383d5ace25f50462341165340052097108a.tar.gz |
create-spdx-{2.2,3.0}: support SPDX include source for work-share directory
Originally, while SPDX_INCLUDE_SOURCES = "1" [1], there is bug in scan
for gcc, libgcc in which the sources locates in work-share directory.
Copy source from ${WORKDIR} to ${SPDXWORK} did not satisfy the situation
while ${S} was not included in ${WORKDIR}
This commit aim to support SPDX include source for work-share directory
1. If is_work_shared_spdx, Copy source from ${S} to ${SPDXWORK},
normally the dest dir in ${SPDXWORK} has the same basename dir of ${S};
but for kernel source, rename basename dir 'kernel-source' to ${BP} (${BPN}-${PV})
2. For SPDX source copy, do hard link copy to save copy time
3. Move do_patch to no work shared situation along with do_unpack
4. Tweak task do_create_spdx dependencies to assure the patched source
in work share is ready for SPDX source copy
5. Remove bb.data.inherits_class('kernel', d) from is_work_shared_spdx,
the kernel source locates in 'work-shared', test kernel.bbclass is not
necessary
[1] https://docs.yoctoproject.org/dev/ref-manual/variables.html#term-SPDX_INCLUDE_SOURCES
(From OE-Core rev: 64454b1956a9b50d6c89a3f3d7c594c1272cb289)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Reviewed-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/spdx-common.bbclass | 9 | ||||
-rw-r--r-- | meta/lib/oe/spdx_common.py | 41 |
2 files changed, 24 insertions, 26 deletions
diff --git a/meta/classes/spdx-common.bbclass b/meta/classes/spdx-common.bbclass index ad02da5cd6..d3cdc8b6ce 100644 --- a/meta/classes/spdx-common.bbclass +++ b/meta/classes/spdx-common.bbclass | |||
@@ -57,6 +57,15 @@ def create_spdx_source_deps(d): | |||
57 | if oe.spdx_common.has_task(d, "do_shared_workdir"): | 57 | if oe.spdx_common.has_task(d, "do_shared_workdir"): |
58 | deps.append("%s:do_shared_workdir" % pn) | 58 | deps.append("%s:do_shared_workdir" % pn) |
59 | 59 | ||
60 | # For gcc-source-${PV} source code | ||
61 | if oe.spdx_common.has_task(d, "do_preconfigure"): | ||
62 | deps.append("%s:do_preconfigure" % pn) | ||
63 | elif oe.spdx_common.has_task(d, "do_patch"): | ||
64 | deps.append("%s:do_patch" % pn) | ||
65 | # For gcc-cross-x86_64 source code | ||
66 | elif oe.spdx_common.has_task(d, "do_configure"): | ||
67 | deps.append("%s:do_configure" % pn) | ||
68 | |||
60 | return " ".join(deps) | 69 | return " ".join(deps) |
61 | 70 | ||
62 | 71 | ||
diff --git a/meta/lib/oe/spdx_common.py b/meta/lib/oe/spdx_common.py index 7a85579f64..ff18d91780 100644 --- a/meta/lib/oe/spdx_common.py +++ b/meta/lib/oe/spdx_common.py | |||
@@ -38,7 +38,7 @@ def extract_licenses(filename): | |||
38 | 38 | ||
39 | 39 | ||
40 | def is_work_shared_spdx(d): | 40 | def is_work_shared_spdx(d): |
41 | return bb.data.inherits_class("kernel", d) or ("work-shared" in d.getVar("WORKDIR")) | 41 | return '/work-shared/' in d.getVar('S') |
42 | 42 | ||
43 | 43 | ||
44 | def load_spdx_license_data(d): | 44 | def load_spdx_license_data(d): |
@@ -74,11 +74,6 @@ def process_sources(d): | |||
74 | if d.getVar("PN") == "shadow-sysroot": | 74 | if d.getVar("PN") == "shadow-sysroot": |
75 | return False | 75 | return False |
76 | 76 | ||
77 | # We just archive gcc-source for all the gcc related recipes | ||
78 | if d.getVar("BPN") in ["gcc", "libgcc"]: | ||
79 | bb.debug(1, "spdx: There is bug in scan of %s is, do nothing" % pn) | ||
80 | return False | ||
81 | |||
82 | return True | 77 | return True |
83 | 78 | ||
84 | 79 | ||
@@ -190,34 +185,28 @@ def get_patched_src(d): | |||
190 | bb.utils.mkdirhier(d.getVar("B")) | 185 | bb.utils.mkdirhier(d.getVar("B")) |
191 | 186 | ||
192 | bb.build.exec_func("do_unpack", d) | 187 | bb.build.exec_func("do_unpack", d) |
193 | # Copy source of kernel to spdx_workdir | 188 | |
189 | if d.getVar("SRC_URI") != "": | ||
190 | bb.build.exec_func("do_patch", d) | ||
191 | |||
192 | # Copy source from work-share to spdx_workdir | ||
194 | if is_work_shared_spdx(d): | 193 | if is_work_shared_spdx(d): |
195 | share_src = d.getVar("WORKDIR") | 194 | share_src = d.getVar('S') |
196 | d.setVar("WORKDIR", spdx_workdir) | 195 | d.setVar("WORKDIR", spdx_workdir) |
197 | d.setVar("STAGING_DIR_NATIVE", spdx_sysroot_native) | 196 | d.setVar("STAGING_DIR_NATIVE", spdx_sysroot_native) |
197 | # Copy source to ${SPDXWORK}, same basename dir of ${S}; | ||
198 | src_dir = ( | 198 | src_dir = ( |
199 | spdx_workdir | 199 | spdx_workdir |
200 | + "/" | 200 | + "/" |
201 | + d.getVar("PN") | 201 | + os.path.basename(share_src) |
202 | + "-" | ||
203 | + d.getVar("PV") | ||
204 | + "-" | ||
205 | + d.getVar("PR") | ||
206 | ) | 202 | ) |
207 | bb.utils.mkdirhier(src_dir) | 203 | # For kernel souce, rename suffix dir 'kernel-source' |
204 | # to ${BP} (${BPN}-${PV}) | ||
208 | if bb.data.inherits_class("kernel", d): | 205 | if bb.data.inherits_class("kernel", d): |
209 | share_src = d.getVar("STAGING_KERNEL_DIR") | 206 | src_dir = spdx_workdir + "/" + d.getVar('BP') |
210 | cmd_copy_share = "cp -rf " + share_src + "/* " + src_dir + "/" | 207 | |
211 | cmd_copy_shared_res = os.popen(cmd_copy_share).read() | 208 | bb.note(f"copyhardlinktree {share_src} to {src_dir}") |
212 | bb.note("cmd_copy_shared_result = " + cmd_copy_shared_res) | 209 | oe.path.copyhardlinktree(share_src, src_dir) |
213 | |||
214 | git_path = src_dir + "/.git" | ||
215 | if os.path.exists(git_path): | ||
216 | shutils.rmtree(git_path) | ||
217 | |||
218 | # Make sure gcc and kernel sources are patched only once | ||
219 | if not (d.getVar("SRC_URI") == "" or is_work_shared_spdx(d)): | ||
220 | bb.build.exec_func("do_patch", d) | ||
221 | 210 | ||
222 | # Some userland has no source. | 211 | # Some userland has no source. |
223 | if not os.path.exists(spdx_workdir): | 212 | if not os.path.exists(spdx_workdir): |