Skip to content

Commit

Permalink
Improve output of sbom generation
Browse files Browse the repository at this point in the history
The script now provides a warning that the initial nix sbom generation
can take very long. It also shortens and extends the output of the
script in various other places.

Signed-off-by: Mr-Kanister <[email protected]>
  • Loading branch information
Mr-Kanister committed Nov 6, 2024
1 parent d3eae01 commit d518ca4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions utils/generate_sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def generate_kotlin_sbom(path: Path):


def generate_nix_sbom():
print(("Generating SBOM for nix.\n\n"
"Running this script the first time can take a very long time and"
" will download a few GBs of data. You won't get any output until the"
" generation has been finished.\n"
))
result = subprocess.run(
["nix", "build", ".#toolsSbom", "-o", sub_bom_file_name + ".json"],
capture_output=True,
Expand All @@ -56,7 +61,7 @@ def generate_nix_sbom():
print(f"Error generating SBOM for nix: {result.stderr}")
return None

print(f"Generated SBOM for nix")
print(f"Generated SBOM for nix.\n")

return

Expand Down Expand Up @@ -97,6 +102,7 @@ def generate_sboms(path_for_recursive: list[Tuple[Path, bool]]) -> list[Path]:
print("Generating SBOMs for:")
for _, path in sbom_able_projects:
print(" -{}".format(str(path)))
print()

return list(filter(lambda x: x, map(lambda x: x[0](x[1]), sbom_able_projects)))

Expand All @@ -115,9 +121,6 @@ def merge_sboms(rel_sbom_files):
return None

def main():
print(" START")
print(" _______________________")

# traverse back to base project folder
base_dir = Path(__file__).resolve().parent.parent

Expand Down Expand Up @@ -146,8 +149,7 @@ def main():
except FileNotFoundError:
pass

print(" _______________________")
print(" DONE")
print("\nDone generating and merging the SBOMs. The final file is located at the root of the project: \"" + output_file_name + ".json\"")


if __name__ == "__main__":
Expand Down

0 comments on commit d518ca4

Please sign in to comment.