From 2d0b0c914fef62b613686d32480125985ccda673 Mon Sep 17 00:00:00 2001 From: ryan link Date: Wed, 30 Oct 2024 11:08:31 -0500 Subject: [PATCH 1/3] Applied kirkstone patch for FOSSA integration --- classes/fossa.bbclass | 9 ++++++--- classes/fossa_upload.bbclass | 12 +++++++----- recipes-extended/fossa/fossa-cli.bb | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/classes/fossa.bbclass b/classes/fossa.bbclass index e239893..b4d27f8 100644 --- a/classes/fossa.bbclass +++ b/classes/fossa.bbclass @@ -82,6 +82,8 @@ python do_fossa_pkg() { # this way it is able to capture the output of `do_fossa_pkg` for every # package that was processed. python do_fossa() { + from oe.rootfs import image_list_installed_packages + if not is_fossa_enabled(d): bb.debug(1, "Since FOSSA_ENABLED is 0, skipping: creating fossa-deps.json") return @@ -93,13 +95,14 @@ python do_fossa() { metadata_dir = d.getVar('FOSSA_METADATA_RECIPES') pkg_metadata = all_pkg_metadata(d, metadata_dir) + pkgs = image_list_installed_packages(d) installed_pkgs = [] - for pkg in pkg_metadata: + for pkg in pkgs: 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") 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" From 31659557a34b4c360d32ded6edde3c265c1ed664 Mon Sep 17 00:00:00 2001 From: ryan link Date: Mon, 11 Nov 2024 12:27:44 -0600 Subject: [PATCH 2/3] Apply new patch to kirkstone-patch-new --- classes/fossa.bbclass | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/fossa.bbclass b/classes/fossa.bbclass index b4d27f8..b235c83 100644 --- a/classes/fossa.bbclass +++ b/classes/fossa.bbclass @@ -95,10 +95,15 @@ python do_fossa() { metadata_dir = d.getVar('FOSSA_METADATA_RECIPES') pkg_metadata = all_pkg_metadata(d, metadata_dir) - pkgs = image_list_installed_packages(d) + pkg_metadata = all_pkg_metadata(d, metadata_dir) installed_pkgs = [] - for pkg in 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: From 07ecd0753bed9aee50f9dd7cafbc6ae85c74df66 Mon Sep 17 00:00:00 2001 From: spatten Date: Mon, 18 Nov 2024 13:13:59 -0800 Subject: [PATCH 3/3] remove duplicated line and unnecessary import --- classes/fossa.bbclass | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/classes/fossa.bbclass b/classes/fossa.bbclass index b235c83..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 @@ -82,20 +82,17 @@ python do_fossa_pkg() { # this way it is able to capture the output of `do_fossa_pkg` for every # package that was processed. python do_fossa() { - from oe.rootfs import image_list_installed_packages - 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) - pkg_metadata = all_pkg_metadata(d, metadata_dir) installed_pkgs = [] for pkg in pkg_metadata: @@ -122,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}") }