diff mbox series

[kirkstone,2.0] bitbake-getvar: Add a quiet command line argument

Message ID 20230824084100.1822478-1-Markus.Niebel@ew.tq-group.com
State Accepted, archived
Commit d677daa0770c66010fc4ed0af5bbbb94752ba590
Headers show
Series [kirkstone,2.0] bitbake-getvar: Add a quiet command line argument | expand

Commit Message

Markus Niebel Aug. 24, 2023, 8:41 a.m. UTC
From: Paulo Neves <ptsneves@gmail.com>

bitbake-getvar does not have a way to silence bitbake
server's logger and that makes the tool hard to use for
text processing. This is especially true when one wants to
get a bitbake value to be piped to some other utility and
instead we get uncontrolled logging messages or warnings
together with bitbake's variable value.

Example without quiet:
bitbake-getvar --value MACHINE
NOTE: Starting bitbake server...

With quiet:
bitbake-getvar --value MACHINE --quiet

Signed-off-by: Paulo Neves <ptsneves@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit af354e975d0b4c26d0e91e3c82946b093bc11b45)
Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
 bin/bitbake-getvar | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/bin/bitbake-getvar b/bin/bitbake-getvar
index 5435a8d7..4a9eb4f3 100755
--- a/bin/bitbake-getvar
+++ b/bin/bitbake-getvar
@@ -25,6 +25,7 @@  if __name__ == "__main__":
     parser.add_argument('-u', '--unexpand', help='Do not expand the value (with --value)', action="store_true")
     parser.add_argument('-f', '--flag', help='Specify a variable flag to query (with --value)', default=None)
     parser.add_argument('--value', help='Only report the value, no history and no variable name', action="store_true")
+    parser.add_argument('-q', '--quiet', help='Silence bitbake server logging', action="store_true")
     args = parser.parse_args()
     if args.unexpand and not args.value:
@@ -35,7 +36,7 @@  if __name__ == "__main__":
         print("--flag only makes sense with --value")
-    with bb.tinfoil.Tinfoil(tracking=True) as tinfoil:
+    with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not args.quiet) as tinfoil:
         if args.recipe:
             d = tinfoil.parse_recipe(args.recipe)