utils/generate-cyclonedx: fix wrong example usage
PATCH 1/2 utils/generate-cyclonedx: fix wrong example usage
The real file is utils/generate-cyclonedx,
not utils/generate-cyclonedx.py.
--- utils/generate-cyclonedx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
utils/generate-cyclonedx +2 -2
@@ -5,7 +5,7 @@ # to CycloneDX format. # # Example usage: -# > make show-info | utils/generate-cyclonedx.py | jq '.' +# > make show-info | utils/generate-cyclonedx | jq '.' 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.py | jq > sbom.json + Example usage: make show-info | utils/generate-cyclonedx | jq > sbom.json ''' ) parser.add_argument("-i", "--in-file", nargs="?", type=argparse.FileType("r"),
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 utils/generate-cyclonedx: add an option to pretty print the output
The indent is passed to json.dump, as described in:
https://docs.python.org/3/library/json.html#json.dump
--- utils/generate-cyclonedx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
utils/generate-cyclonedx +4 -1
@@ -277,6 +277,9 @@ def main(): default=(None if sys.stdin.isatty() else sys.stdin)) parser.add_argument("-o", "--out-file", nargs="?", type=argparse.FileType("w"), default=sys.stdout) + parser.add_argument("--indent", default=None, type=int, + help="If given, then JSON array elements and object members will be pretty-printed with that " + "indent level") parser.add_argument("--virtual", default=False, action='store_true', help="This option includes virtual packages to the CycloneDX output")
@@ -316,7 +319,7 @@ def main(): }, } - args.out_file.write(json.dumps(cyclonedx_dict)) + args.out_file.write(json.dumps(cyclonedx_dict, indent=args.indent)) if __name__ == "__main__":
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] utils/generate-cyclonedx: add an option to pretty print the output
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Devoogdt <[email protected]> writes:
The indent is passed to json.dump, as described in:
https://docs.python.org/3/library/json.html#json.dumpSigned-off-by Thomas Devoogdt <[email protected]>
I take it this is meant as an alternative to piping it to jq? Maybe we should just always indent with a "sane" level (I believe jq uses 2) and the comments about using jq dropped?
Quoted 35 lines
--- utils/generate-cyclonedx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)utils/generate-cyclonedx +4
-1@@ -277,6 +277,9 @@ def main(): default=(None if sys.stdin.isatty() else sys.stdin)) parser.add_argument("-o", "--out-file", nargs="?", type=argparse.FileType("w"), default=sys.stdout) + parser.add_argument("--indent", default=None, type=int, + help="If given, then JSON array elements and object members will be pretty-printed with that " + "indent level") parser.add_argument("--virtual", default=False, action='store_true', help="This option includes virtual packages to the CycloneDX output")@@ -316,7 +319,7 @@ def main(): }, } - args.out_file.write(json.dumps(cyclonedx_dict)) + args.out_file.write(json.dumps(cyclonedx_dict, indent=args.indent)) if __name__ == "__main__":Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] utils/generate-cyclonedx: add an option to pretty print the output
Hi Peter
Quoted 3 lines
I take it this is meant as an alternative to piping it to jq? Maybe we should just always indent with a "sane" level (I believe jq uses 2) and the comments about using jq dropped?
This is indeed an alternative to jq. I'm also in favour of just defaulting to 2, which is indeed the default used by jq.
Kind regards,
Thomas Devoogdt
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/1 utils/generate-cyclonedx: use indent 2 by default
In reply to Thomas DevoogdtBy 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.
---
v2: replacement for https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
--- utils/generate-cyclonedx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
utils/generate-cyclonedx +4 -3
@@ -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
@@ -280,7 +280,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"),
@@ -326,7 +326,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__":
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2] utils/generate-cyclonedx: use indent 2 by default
Quoted 5 lines · Thomas Devoogdt
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 <[email protected]>
Applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Devoogdt <[email protected]> writes:
The real file is utils/generate-cyclonedx,
notutils/generate-cyclonedx.py.Signed-off-by Thomas Devoogdt <[email protected]>
Ups, indeed - The script got renamed when applied. Committed, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot