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 <thomas.devoogdt@barco.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Thomas Devoogdt
2025-03-06 21:31:50 +01:00
committed by Julien Olivain
parent e070406523
commit 1713472621

View File

@@ -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__":