Skip to content

Commit

Permalink
Applied kirkstone patch for FOSSA integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan link committed Oct 30, 2024
1 parent 1ec388f commit 2d0b0c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions classes/fossa.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
12 changes: 7 additions & 5 deletions classes/fossa_upload.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions recipes-extended/fossa/fossa-cli.bb
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ do_install() {
}

INSANE_SKIP_${PN}:append = "already-stripped"

BBCLASSEXTEND = "native"

0 comments on commit 2d0b0c9

Please sign in to comment.