From: Richard Purdie <[email protected]> Change do_package to:
a) Save the debug object -> source file mapping information (in TEMPDBGSRCMAPPING) b) Save a .srclist file continaing that information (in json format) c) Perform a grep of all the sources in the build of this recipe looking for SPDX license headers d) Save out a file listing the SPDX headers found for each file Signed-off-by: Richard Purdie <[email protected]> --- meta/classes/package.bbclass | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 247bdc7bbf..42bd38f948 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass @@ -1232,6 +1232,9 @@ python split_and_strip_files () { for file in staticlibs: results.append( (file,source_info(file, d)) ) + # Stash this for emit_pkgdata + d.setVar('TEMPDBGSRCMAPPING', results) + sources = set() for r in results: sources.update(r[1]) @@ -1544,6 +1547,7 @@ PKGDATA_VARS = "PN PE PV PR PKGE PKGV PKGR LICENSE DESCRIPTION SUMMARY RDEPENDS python emit_pkgdata() { from glob import glob import json + import subprocess def process_postinst_on_target(pkg, mlprefix): pkgval = d.getVar('PKG_%s' % pkg) @@ -1695,6 +1699,33 @@ fi and not bb.data.inherits_class('packagegroup', d): write_extra_runtime_pkgs(global_variants, packages, pkgdatadir) + sourceresult = d.getVar('TEMPDBGSRCMAPPING', False) + sources = {} + if sourceresult: + for r in sourceresult: + sources[r[0]] = r[1] + with open(data_file + ".srclist", 'w') as f: + f.write(json.dumps(sources, sort_keys=True)) + + filelics = {} + for dirent in [d.getVar('PKGD'), d.getVar('STAGING_DIR_TARGET')]: + p = subprocess.Popen(["grep", 'SPDX-License-Identifier:', '-R', '-I'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=dirent) + out, err = p.communicate() + if p.returncode == 0: + for l in out.decode("utf-8").split("\n"): + l = l.strip() + if not l: + continue + l = l.split(":") + if len(l) < 3: + bb.warn(str(l)) + continue + fn = "/" + l[0] + lic = l[2] + filelics[fn] = lic + with open(data_file + ".filelics", 'w') as f: + f.write(json.dumps(filelics, sort_keys=True)) + } emit_pkgdata[dirs] = "${PKGDESTWORK}/runtime ${PKGDESTWORK}/runtime-reverse ${PKGDESTWORK}/runtime-rprovides" -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#149554): https://lists.openembedded.org/g/openembedded-core/message/149554 Mute This Topic: https://lists.openembedded.org/mt/81371628/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
