From 2ffe673cf64e3a551f5aa2d93ebc69023e07343f Mon Sep 17 00:00:00 2001 From: Ryan Link <47920994+ryanlink@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:58:26 -0600 Subject: [PATCH] Kirkstone patch provided by Baxter (#12) * Applied kirkstone patch for FOSSA integration * Apply new patch to kirkstone-patch-new * remove duplicated line and unnecessary import --------- Co-authored-by: ryan link Co-authored-by: spatten --- classes/fossa.bbclass | 19 ++++++++++++------- classes/fossa_upload.bbclass | 12 +++++++----- recipes-extended/fossa/fossa-cli.bb | 2 ++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/classes/fossa.bbclass b/classes/fossa.bbclass index e239893..50c8284 100644 --- a/classes/fossa.bbclass +++ b/classes/fossa.bbclass @@ -14,7 +14,7 @@ do_fossa_archive[rdeptask] += "do_patch" # This task runs after the `do_patch` task. # # The `do_patch` task is executed for each package in the build; in this way -# `do_fossa_archive` is able to save the package information and source code +# `do_fossa_archive` is able to save the package information and source code # for every package that goes into the build. # # The temporary files containing this metadata are then combined into a @@ -84,22 +84,27 @@ python do_fossa_pkg() { python do_fossa() { if not is_fossa_enabled(d): bb.debug(1, "Since FOSSA_ENABLED is 0, skipping: creating fossa-deps.json") - return + return import errno import os import json import glob - + metadata_dir = d.getVar('FOSSA_METADATA_RECIPES') pkg_metadata = all_pkg_metadata(d, metadata_dir) installed_pkgs = [] for pkg in pkg_metadata: + + for ignored_suffix in (d.getVar("SPECIAL_PKGSUFFIX") or "").split(): + if pkg.endswith(ignored_suffix): + pass + try: installed_pkgs.append(mk_user_dependencies(pkg_metadata[pkg])) - except Exception as err: - bb.error(f'failed to retrieve pkg metadata for {pkg} because: {err}') + except Exception: + pass # Ensure path exists fossa_deps_dir = d.getVar("FOSSA_STAGING_DIR") @@ -114,10 +119,10 @@ python do_fossa() { with open(fossa_deps_path, 'w+') as fd: json.dump(fossa_deps_dict, fd, indent=4, sort_keys=False) - + with open(fossa_deps_raw, 'w+') as fr: json.dump(pkg_metadata, fr, indent=4, sort_keys=False) - + bb.debug(1, "Wrote fossa-deps at: {fossa_deps_path}") } diff --git a/classes/fossa_upload.bbclass b/classes/fossa_upload.bbclass index ab3afbc..efa192b 100644 --- a/classes/fossa_upload.bbclass +++ b/classes/fossa_upload.bbclass @@ -6,16 +6,16 @@ inherit fossa_utils addtask do_fossa_analyze before do_build after do_rootfs do_fossa_analyze[doc] = "Analyze via fossa-cli" do_fossa_analyze[nostamp] = "1" -do_fossa_analyze[depends] = "fossa-cli:do_populate_sysroot" do_fossa_analyze[network] = "1" +do_fossa_analyze[depends] = "fossa-cli-native:do_populate_sysroot" addtask do_fossa_test before do_build after do_fossa_analyze do_fossa_test[doc] = "Test via fossa-cli" do_fossa_test[nostamp] = "1" -do_fossa_test[deptask] += "fossa-cli:do_populate_sysroot" do_fossa_test[network] = "1" +do_fossa_test[deptask] += "fossa-cli-native:do_populate_sysroot" -# This task runs `fossa-cli` against the `fossa-deps` file generated by `fossa:do_fossa`, +# This task runs `fossa-cli-native` against the `fossa-deps` file generated by `fossa:do_fossa`, # analyzing the file and storing its results in the FOSSA backend. # # This task is run after `do_rootfs` is finalized (`fossa:do_fossa` runs as a post-processing @@ -56,8 +56,10 @@ def run_fossa_cli(d, cli_args): BINDIR = d.getVar("bindir") WORKDIR = d.getVar("WORKDIR") - cli_path = (f"{WORKDIR}/recipe-sysroot{BINDIR}/fossa") - cmds = [cli_path] + cli_args + # We don't need to specify the whole path here. The sysroot-native + # directory is already in our PATH. + fossa_cli = ("fossa") + cmds = [fossa_cli] + cli_args bb.plain(f"running: {' '.join(cmds)}") out = subprocess.run(cmds, cwd=d.getVar("FOSSA_STAGING_DIR"), capture_output=True, text=True, shell=False) diff --git a/recipes-extended/fossa/fossa-cli.bb b/recipes-extended/fossa/fossa-cli.bb index 5b36c87..8fbc8b7 100644 --- a/recipes-extended/fossa/fossa-cli.bb +++ b/recipes-extended/fossa/fossa-cli.bb @@ -38,3 +38,5 @@ do_install() { } INSANE_SKIP_${PN}:append = "already-stripped" + +BBCLASSEXTEND = "native"