From 17134726213a2188946a07b73ff2e2d0363ad636 Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Thu, 6 Mar 2025 21:31:50 +0100 Subject: [PATCH] utils/generate-cyclonedx: use indent 2 by default By default, use an indent of 2, which is the same as what 'jq' uses. This omits the need for 'jq' in the example usage. Also, add a new line to the output while at it. Signed-off-by: Thomas Devoogdt Signed-off-by: Julien Olivain --- utils/generate-cyclonedx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/generate-cyclonedx b/utils/generate-cyclonedx index 39d59173d2..46f68ac63d 100755 --- a/utils/generate-cyclonedx +++ b/utils/generate-cyclonedx @@ -5,7 +5,7 @@ # to CycloneDX format. # # Example usage: -# > make show-info | utils/generate-cyclonedx | jq '.' +# $ make show-info | utils/generate-cyclonedx > sbom.json import argparse @@ -270,7 +270,7 @@ def br2_parse_deps_recursively(ref, show_info_dict, virtual=False, deps=[]): def main(): parser = argparse.ArgumentParser( description='''Create a CycloneDX SBoM for the Buildroot configuration. - Example usage: make show-info | utils/generate-cyclonedx | jq > sbom.json + Example usage: make show-info | utils/generate-cyclonedx > sbom.json ''' ) parser.add_argument("-i", "--in-file", nargs="?", type=argparse.FileType("r"), @@ -316,7 +316,8 @@ def main(): }, } - args.out_file.write(json.dumps(cyclonedx_dict)) + args.out_file.write(json.dumps(cyclonedx_dict, indent=2)) + args.out_file.write('\n') if __name__ == "__main__":