From patchwork Wed Feb 18 13:15:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonin Godard X-Patchwork-Id: 81294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E634EE9A04D for ; Wed, 18 Feb 2026 13:15:41 +0000 (UTC) Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11587.1771420537257771110 for ; Wed, 18 Feb 2026 05:15:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=h3ZQOkTD; spf=pass (domain: bootlin.com, ip: 185.171.202.116, mailfrom: antonin.godard@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 55270C23D8E for ; Wed, 18 Feb 2026 13:15:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6C8596074B for ; Wed, 18 Feb 2026 13:15:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AF0FD10368B8A; Wed, 18 Feb 2026 14:15:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771420535; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=EihjeVjz8HLRaZuqRiCvB/nZfjUibujeTDope6pB6VI=; b=h3ZQOkTDmV6sWbvoE34pAQpqgzVAe1munIB9N5hfD9Dkh9E/1/uw8QS/cKBvSeR8B7YT0D B8nnnHPlglnLEUOqATXUhViy6ods7BVhDLdcOqTpV3UibSh60Hvk3Z0qyqI4YoRuY6NuTJ TSOmIsg1idXDgPAYz+Okykdb6xASrfAeRyuGlkh5eZhRQQEcUNDTX7skLc9CHFRIXP5RJl c5ax4037fRyMvNsjrWqSur+B4qnLS9ep3eo+SYVji4/QA13AXLWm6mo7RtBq7qnLuJbbE6 nXGceQA6DLQnS5X75v17LxIFV7j997lcc1NqzNoV6KwPTKlUI+l1bbNtYdgwqw== From: Antonin Godard Date: Wed, 18 Feb 2026 14:15:26 +0100 Subject: [PATCH v2 1/4] bitbake-setup: define a color_enabled() helper function MIME-Version: 1.0 Message-Id: <20260218-improve-bbsetup-readability-v2-1-351584e5df9c@bootlin.com> References: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> In-Reply-To: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> To: bitbake-devel@lists.openembedded.org Cc: Thomas Petazzoni , Antonin Godard X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=919; i=antonin.godard@bootlin.com; h=from:subject:message-id; bh=AYFaZ1u2gByNcSF1OQHT9ZvSOIcpCARVNMv/0nm9k7o=; b=owEBbQKS/ZANAwAKAdGAQUApo6g2AcsmYgBplbt0CAC+L1JE4vPr+6Ampc/lAOfM1pgGRLqt2 ekVPl7HgAyJAjMEAAEKAB0WIQSGSHJRiN1AG7mg0//RgEFAKaOoNgUCaZW7dAAKCRDRgEFAKaOo NuXWEAC9l4pGi5pgkRgkf+Wkr9vibzFCcm/DTBmhcH93lgaYjZyrKiBwzhJUrf82goi0/CKt+4s leBzHBA8IJRuE6TDzNXMCqDqUIrpwbtp3ghhsYUdi0nDxjckxJbV5J6EvW9nTcRzRWQQv7JrUhm /xuls60Br9PEK4HKgeIQ7VceXe/vuyB1nkvl9HUIrNQQ2zvBZ8gyjA1CqA4tQ2JOdBH/DDxhTI6 jG0eM2MQGhlkPIVhsiEQVCLJNhP7//Bbe5P+Z3sm1nldmpJrlWq7BboXalLopzgaM3rlkyk9AXj FJWRTe5mPkIJDN2HMz2mavN2y/lqE+rmWoushurTIGE9g6m0h5fk8edMbv3MphO0W1ORgfDi2gc R92aOUfvp5DVVU0yGsYFbJtOEi+dmjaVxgTXxFJb5B4pjJ38jdckTz8fwOEtfCmhz01+828XuxL Oj+AGJKfmpIKrJR4qoSpw/PNVaiOH7suvCVzcBQfN3DwHzFy+OeHFCy1E5/gkrLARiRa03wTTiB Q3/UgE5vYPGmdbwnRHMSW+acQ4VQKnxybA2BsouCyrqbgaylTfpjUaPwFgT14GFGijLPrtLfEAN +EFOPEwL/PmmnfzgF0SGmAg+Ln4bGaJ6bWQfJZgEF+VwgANWzcFJvHaozfLv4bwwHQQiQk0akTQ p4MlfpdiR7dsxeA== X-Developer-Key: i=antonin.godard@bootlin.com; a=openpgp; fpr=8648725188DD401BB9A0D3FFD180414029A3A836 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Feb 2026 13:15:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/19060 This will be re-used in the next commits to force subprocess commands to color their outputs, as passing --color=auto in them always render without coloring. Signed-off-by: Antonin Godard --- bin/bitbake-setup | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 927c03a1033..3e17e631bfb 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -35,6 +35,13 @@ GLOBAL_ONLY_SETTINGS = ( "top-dir-name", ) +def color_enabled() -> bool: + """ + Our logger has a BBLogFormatter formatter which holds whether color is + enabled or not. Return this value. + """ + return logger.handlers[0].formatter.color_enabled + # If bitbake is from a release tarball or somewhere like pypi where # updates may not be straightforward, prefer to use the git repo as the # default registry From patchwork Wed Feb 18 13:15:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonin Godard X-Patchwork-Id: 81293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2611E9A047 for ; Wed, 18 Feb 2026 13:15:41 +0000 (UTC) Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.11680.1771420537363245699 for ; Wed, 18 Feb 2026 05:15:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=NjJSmWqh; spf=pass (domain: bootlin.com, ip: 185.171.202.116, mailfrom: antonin.godard@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id BF532C237EE for ; Wed, 18 Feb 2026 13:15:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D614A6074B for ; Wed, 18 Feb 2026 13:15:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4E11E10368B8C; Wed, 18 Feb 2026 14:15:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771420535; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ZOqZfS29BsvQ+cebMw84hV/TWudO6JWMqr8Jx+Gyt/8=; b=NjJSmWqh9OM2VVdcqZvDm0x0i+BwHhd+vCDk+uo8Pdq3fOE8cIOdoZ8IiUEcYa6ecKKsat PJ8v5orz6pUKP2hchSZHx5d17/Mvw3LIv4zsn8BCLp+HB6tuwFz8IOt9V3l0cMOlTGcCkX 8e/794XVZ+h6zTsrF6Bm8M/UmaabwYVg9E8vSWhwoCN6++6vZHET5yf4IoG9ydjTaXvZo8 tAx1P7ODwn64yl5pmdT0+gk5xzMYPRUlXEOiSEchFRRRdA9x4Z5I2S/HPqkenFijhWA/Uq yD3coQ3zf29dYsabb0OgwlqLFWtAb58hOMLx2bV7JU7OB0f8eGjpg3sCSipf+Q== From: Antonin Godard Date: Wed, 18 Feb 2026 14:15:27 +0100 Subject: [PATCH v2 2/4] bitbake-setup: improve readability of choices MIME-Version: 1.0 Message-Id: <20260218-improve-bbsetup-readability-v2-2-351584e5df9c@bootlin.com> References: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> In-Reply-To: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> To: bitbake-devel@lists.openembedded.org Cc: Thomas Petazzoni , Antonin Godard X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5682; i=antonin.godard@bootlin.com; h=from:subject:message-id; bh=1quA5f/DLTqmFNZ1fqFLGQfZviq0mSW19f1EWd1fmvg=; b=owEBbQKS/ZANAwAKAdGAQUApo6g2AcsmYgBplbt08qyyU6wjPoFTghO5QI0KlVtFoUIFHZvlw 3CB9xCWDT2JAjMEAAEKAB0WIQSGSHJRiN1AG7mg0//RgEFAKaOoNgUCaZW7dAAKCRDRgEFAKaOo NndUEACwuwzwr6eFhQ0xQggsu7HadawJpnFyy4pO4Y18TuT16qjtZFFK9WxeDGIjP+UdV/MIGMi GNY/A9bsNTH/GrIPIZjAQAOniG213xMTV3kv0aZXEGmeDgSSHmeYluqnvMyXX3hcp2psYB+juE2 9htFq9Br/Lkz7INN07kHQO/OEMqQSoFBb5fUJXyfpgs/ZJ9ucbHvM5YMvP5fVkcJnnfGsjhq+4l 0F6asWXibKY0BqLy4S56u8Fjub805n60N5etSY2ILESErOTPYGCcpHvNiJ8XEeYIoPUtOZ5CIVJ 9yrItMVp37sGI1BbcKOIdjKiwM70KXKrR8D8Va/s6uE/bNU84+r7HAmXm2PhsA4d64pnuTLyi1L 6R/L3r4JfweYe4UrIU/yWnAnSlNN2e3sBNsCBvMLOUOaUB/okEuo/xvKnp7GpLQETHb/VvRdW/d W1IQI7nY71qDjJK6lkkLHugjcThTb5wR2rW0dVzqn0ewElpTHPvw2WN3peWPgPuDhZLjOWvDCx6 1QPVJ9ggJ7uqkTt2BVxgSo2Dn4nI4nQ0mFrT3nNUkDSAXmeDsynKwhNpnELkilzudRz7upv5SzV BZKr5Pyb4jjvAxpItubiYnuU1JBN70oadUf3dL1zFcHa3CPKp119zHpKzUBcTjlnm9RPrcdaJum wxx56WbgKIgn4MA== X-Developer-Key: i=antonin.godard@bootlin.com; a=openpgp; fpr=8648725188DD401BB9A0D3FFD180414029A3A836 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Feb 2026 13:15:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/19059 Bold the configuration names and align the descriptions for improved readability. For this, define a print_configs() function which should also help factorizing the code as this is done in multiple places. If color_enabled() is false, keep the text plain. Signed-off-by: Antonin Godard --- bin/bitbake-setup | 74 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 3e17e631bfb..9b0ecc8d0e4 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -42,6 +42,33 @@ def color_enabled() -> bool: """ return logger.handlers[0].formatter.color_enabled +def print_configs(prompt: str, choices: list[str], descriptions: list[str] = []): + """ + Helper function to print a list of choices and align the output. + Each option name is made bold to stand out, unless color is not enabled in + our logger. + """ + if not prompt.endswith(':'): + prompt += ":" + logger.plain(prompt) + + if not descriptions: + descriptions = ["" for _ in choices] + + # maximum size of all choices, for alignment + cmax = max([len(c) for c in choices]) + 1 + + for n, c in enumerate(choices): + msg = f"{n + 1}. " + if color_enabled(): + # make it bold + msg += "\033[1m" + msg += f"{c:<{cmax}}" + if color_enabled(): + msg += "\033[0m" + msg += f" {descriptions[n]}" + logger.plain(msg) + # If bitbake is from a release tarball or somewhere like pypi where # updates may not be straightforward, prefer to use the git repo as the # default registry @@ -497,36 +524,39 @@ def choose_bitbake_config(configs, parameters, non_interactive): if non_interactive: raise Exception("Unable to choose from bitbake configurations in non-interactive mode: {}".format(configs_dict)) - logger.plain("\nAvailable bitbake configurations:") - for n, config_data in enumerated_configs: - logger.plain("{}. {}\t{}".format(n, config_data["name"], config_data["description"])) + logger.plain("") + print_configs("Available bitbake configurations", + [c["name"] for c in flattened_configs], + [c["description"] for c in flattened_configs]) config_n = int_input([i[0] for i in enumerated_configs], "\nPlease select one of the above bitbake configurations by its number: ") - 1 return flattened_configs[config_n] def choose_config(configs, non_interactive): not_expired_configs = [k for k in sorted(configs.keys()) if not has_expired(configs[k].get("expires", None))] - config_list = list(enumerate(not_expired_configs, 1)) - if len(config_list) == 1: - only_config = config_list[0][1] + if len(not_expired_configs) == 1: + only_config = not_expired_configs[0] logger.plain("\nSelecting the only available configuration {}\n".format(only_config)) return only_config if non_interactive: raise Exception("Unable to choose from configurations in non-interactive mode: {}".format(not_expired_configs)) - logger.plain("\nAvailable Configuration Templates:") - for n, config_name in config_list: - config_data = configs[config_name] - expiry_date = config_data.get("expires", None) - config_desc = config_data["description"] + descs = [] + for c in not_expired_configs: + d = configs[c]["description"] + expiry_date = configs[c].get("expires", None) if expiry_date: - logger.plain("{}. {}\t{} (supported until {})".format(n, config_name, config_desc, expiry_date)) - else: - logger.plain("{}. {}\t{}".format(n, config_name, config_desc)) - config_n = int_input([i[0] for i in config_list], - "\nPlease select one of the above Configuration Templates by its number: ") - 1 - return config_list[config_n][1] + d += f" (supported until {expiry_date})" + descs.append(d) + + logger.plain("") + print_configs("Available Configuration Templates", + [c for c in not_expired_configs], + descs) + config_n = int_input([i[0] for i in list(enumerate(not_expired_configs, 1))], + "\nPlease select one of the above configurations by its number: ") - 1 + return not_expired_configs[config_n] def choose_fragments(possibilities, parameters, non_interactive, skip_selection): choices = {} @@ -552,13 +582,11 @@ def choose_fragments(possibilities, parameters, non_interactive, skip_selection) if non_interactive: raise Exception(f"Unable to choose from options in non-interactive mode: {[o['name'] for o in options]}") - logger.plain("\n" + v["description"] + ":") + logger.plain("") + print_configs(v["description"], + [o['name'] for o in options], + [o['description'] for o in options]) options_enumerated = list(enumerate(options, 1)) - for n,o in options_enumerated: - opt_str = f"{n}. {o['name']}" - if o["description"]: - opt_str += f"\t{o['description']}" - logger.plain(opt_str) option_n = int_input([i[0] for i in options_enumerated], "\nPlease select one of the above options by its number: ") - 1 choices[k] = options_enumerated[option_n][1]["name"] From patchwork Wed Feb 18 13:15:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonin Godard X-Patchwork-Id: 81295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED025E9A04E for ; Wed, 18 Feb 2026 13:15:41 +0000 (UTC) Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.11588.1771420537929904333 for ; Wed, 18 Feb 2026 05:15:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=mamjmGUx; spf=pass (domain: bootlin.com, ip: 185.171.202.116, mailfrom: antonin.godard@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 51531C211D2 for ; Wed, 18 Feb 2026 13:15:48 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 65B906074B for ; Wed, 18 Feb 2026 13:15:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BA23410368B8E; Wed, 18 Feb 2026 14:15:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771420536; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ev4DfHpYsx39ok5s2cor/WtMF8lP+iWvNdX187dNy28=; b=mamjmGUxKFA9qpB/D6etRw6wHzdSeSseEQ9CMW+MHeMeZanoFf9k7U9825aBt80kyG/WjY n8Bz9fZoHcKJyRShYGqUtFW6JJeFNUAS+VY9VYeHEWJmOuZ+70F+G4GCK+KAygdKKM93xS Pft05oxraPFiB4DVpuU7LTDhhoSVfS+htJgIYapZ8iA1yS42PC4wDrv3k1F+9KRBdj9+F9 BsfYlkWp7ncL7q1otmSB8ML+9/HMM1GOPjlcIAgo+spA1TDvXDg9Hnj3ne9sqpiI4tThU+ v+D/zEj2ZBkwo0KQ7Fp2dZXdvqTgX4EdzX6tUtxB04yl6iCKkuJ8FSVkqHnXrw== From: Antonin Godard Date: Wed, 18 Feb 2026 14:15:28 +0100 Subject: [PATCH v2 3/4] bitbake-setup: print colored diffs MIME-Version: 1.0 Message-Id: <20260218-improve-bbsetup-readability-v2-3-351584e5df9c@bootlin.com> References: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> In-Reply-To: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> To: bitbake-devel@lists.openembedded.org Cc: Thomas Petazzoni , Antonin Godard X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3535; i=antonin.godard@bootlin.com; h=from:subject:message-id; bh=jbM+2WoZ5OGtfQPoPYPIqXJ3RRrE+F4vjwACRmzV8cI=; b=owEBbQKS/ZANAwAKAdGAQUApo6g2AcsmYgBplbt17Hus0K98IAe0PWTo70a1SOMDZzpbk9r0h /da6Y0wLqWJAjMEAAEKAB0WIQSGSHJRiN1AG7mg0//RgEFAKaOoNgUCaZW7dQAKCRDRgEFAKaOo NmW4EADAkT6djWrpZ7/8UREMNm346PCYV1LqZqXQ8HvxvvWDj+npA8rIG4RwfwGdJ4yWM+k+bAz SHR3KXjJEQ0AxHbATr9WKIfKzN3dCPO9xWNjnpJVYpKcbLg6buw3Uiy+mgw9knloEzTaZzfDbSP RMolC0M6SpnnEToqaFSCM98WYoWfMtKUkWrMcvAKbtTe/YRSLrLpyHmswZi26dNm0rKQuno2sw5 +/8Iis4yRv6dCseATIxLT8Kbb5P8x3izH2skFCNh2ozUnDXCGNYjlzQslxAfGuJle+V4cfQr+3V dnaq5kUiZKLhjSlRVvZ2KzZ6N8Upmc3RDnFgZHjSjWYUsAkdpuvwDgnVO2STfMvL9AAtdoaoYJw tUrlv5A10uf2p+cgVFFd6PQ95O6s3mxjbI10VhIZOu8izqhg5fQ2cRrbE0QkTF5E7x6w35R5STv 8pcGn2mvI2L7GUjsct/1aZ0G5ywSjuf3bN0n496FKsexE0cgeX4M6SLCyZuZqjB0yjCxefX1ft3 HfLhQAD4lm/SdNztnvueOS8jSLw+MS0KhycS5ZU4K35AIutKnPhDzkEFkMfcQTVpvFkFEd0TsqM MMMgL+++Irjm7yQvxM+hf7g+RvWFxje54KsvgfypkbP68FRlKIcHWVlsB2DXmIl8ZfM/W0tK/7B jZsuIOi5Pw3b5CQ== X-Developer-Key: i=antonin.godard@bootlin.com; a=openpgp; fpr=8648725188DD401BB9A0D3FFD180414029A3A836 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Feb 2026 13:15:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/19061 Define a new run_git_diff() function that can be used to print diffs between two paths (files or directories), or show a diff in a Git repository. This function also uses color_enabled() to force showing color or not in the subprocess. Replace the different calls of `diff` and `git diff` by this helper function. Signed-off-by: Antonin Godard --- bin/bitbake-setup | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 9b0ecc8d0e4..e456aa93bf3 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -69,6 +69,39 @@ def print_configs(prompt: str, choices: list[str], descriptions: list[str] = []) msg += f" {descriptions[n]}" logger.plain(msg) +def run_git_diff(revision: str = "", path1: str = "", path2: str = "", repo_path: str = "") -> str: + """ + Run git diff from either the current working directory, or in the path + specified by repo_path. + Then, run git diff with either: + - no argument, + - or a revision, + - or two files / two directories. + """ + assert not (revision and (path1 or path2)), \ + "run_git_diff can only be called with a revision or two paths, not both" + assert not (path1 and not path2), \ + "run_git_diff only received one path, two expected" + + path = f"-C {repo_path}" if repo_path else "" + color = "--color=always" if color_enabled() else "--color=never" + git_cmd = f"git {path} diff {color}" + if revision: + git_cmd += f" {revision}" + elif path1: + git_cmd += f" {path1} {path2}" + + diff = "" + try: + diff = bb.process.run(f"{git_cmd}")[0].strip() + except bb.process.ExecutionError as e: + if e.exitcode == 1: + diff = e.stdout + else: + raise e + + return diff + # If bitbake is from a release tarball or somewhere like pypi where # updates may not be straightforward, prefer to use the git repo as the # default registry @@ -202,7 +235,7 @@ be preserved in a backup directory.""".format(r_name, r_path)) status = bb.process.run('git -C {} status --porcelain'.format(r_path))[0] if status: return True - diff = bb.process.run('git -C {} diff {}'.format(r_path, rev))[0] + diff = run_git_diff(revision=rev, repo_path=r_path) if diff: return True return False @@ -728,7 +761,9 @@ def init_config(top_dir, settings, args): def get_diff(file1, file2): try: - bb.process.run('diff -uNr {} {}'.format(file1, file2)) + bb.process.run('diff --color={} -uNr {} {}'.format("always" if BBSETUP_COLOR else "never", + file1, + file2)) except bb.process.ExecutionError as e: if e.exitcode == 1: return e.stdout @@ -786,7 +821,7 @@ def build_status(top_dir, settings, args, d, update=False): new_upstream_config = obtain_config(top_dir, registry, args, source_overrides, d) write_upstream_config(confdir, new_upstream_config) - config_diff = bb.process.run('git -C {} diff'.format(confdir))[0] + config_diff = run_git_diff(repo_path=confdir) if config_diff: logger.plain('\nConfiguration in {} has changed:\n{}'.format(setupdir, config_diff)) From patchwork Wed Feb 18 13:15:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonin Godard X-Patchwork-Id: 81292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3FDEE9A049 for ; Wed, 18 Feb 2026 13:15:41 +0000 (UTC) Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.11682.1771420538932565673 for ; Wed, 18 Feb 2026 05:15:39 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=mBajMpIB; spf=pass (domain: bootlin.com, ip: 185.171.202.116, mailfrom: antonin.godard@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 44F33C10F46 for ; Wed, 18 Feb 2026 13:15:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5C2256074B for ; Wed, 18 Feb 2026 13:15:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4871910368B90; Wed, 18 Feb 2026 14:15:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771420536; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=76RXd3jeHr8FJ8Sp2GOSjOr1XCug/lBjSYxNjzqUxfs=; b=mBajMpIBtbyPKQd27nEVogQWQ2jDt5/ZBIN5iuc1yPUGIxE4Kiq0EIcuRycD68AhEep+Gs ierSljalK6EvKxHSvo/RHMSK++4sr7AfoWCA78hZuybsnxrQJCBbrD3/yfO6n38jbnV5z0 rMU3xnwAgHVVShjKA95w7NwrnaY9um9/FmNNFcEWeSSalINVYKv+W3owxVtg+LJgQVksvc 1xQ932z8AQjjWrl9DcqY2bwzCtt2CIu2W1AXwWj2llFRhRY3ijF+vqkTc77S6sVBE0a3z2 ElotxnrZNmcZVyGArnECMYN51orsG8y/ZQSlBCQWIhv8rtAkg0tuarHhRZw2bQ== From: Antonin Godard Date: Wed, 18 Feb 2026 14:15:29 +0100 Subject: [PATCH v2 4/4] bitbake-setup: drop get_diff and replace by run_git_diff MIME-Version: 1.0 Message-Id: <20260218-improve-bbsetup-readability-v2-4-351584e5df9c@bootlin.com> References: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> In-Reply-To: <20260218-improve-bbsetup-readability-v2-0-351584e5df9c@bootlin.com> To: bitbake-devel@lists.openembedded.org Cc: Thomas Petazzoni , Antonin Godard X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1901; i=antonin.godard@bootlin.com; h=from:subject:message-id; bh=auJhwDgYVWeHQY7B8MndgeBym8zdwl7wT8Vq9TwcR6M=; b=owEBbQKS/ZANAwAKAdGAQUApo6g2AcsmYgBplbt11xyeDXQ8UZWe862FUPReTKShMXy7z07K6 BEV6Lk+R/KJAjMEAAEKAB0WIQSGSHJRiN1AG7mg0//RgEFAKaOoNgUCaZW7dQAKCRDRgEFAKaOo NgKcD/94It7ApsyNfW0fTlGebLC3xBzRB805emStGhQH94LIg/4EpiDVuKX9gDDH1SQDyqaKSpg c70bF4wnpJQTzVFn3L98GIkyXVUkRE8bbk1S5cQauYaN06S9VQwfwFUufofnviJ4b+MUmMFCOZd WfLnJB5aeo7d+n7NdbaNO+JMkZTVp6ba9H4Kaqn3uwta0Z2xqEFDcpTTAJA0nk1lip43CJlTdwX 0CWJUcnQMfhbT8kMiqzB2A2FiCibS1pYtSb6wjZOLESq+J8cvSnnrWYd4OORVnMFKNyLkoB51qF t+p1HRXL22OZU43a1CuYjzaBPp40WO7Td5EwNvUi7h1MHnQOe3f/gi1YZYpyb5LgpOGYfz0g90j w8YfuvJYjT8Bl+fnDjfU5CgVrVHAQF+ZssymMif6okz5Q4mcvOX6jOHUcG0YIhzjCRIHNLA2J73 B2dA/8MLGYjGPtwqpKn9tFbyfdYOXsyZ5fSwKqo6nxhIWKVsEF2krBDirXd3GtBXE7SEBQeMcmv 8tY3POOIkOD1BQ4GRnS4OomQ7uikNdhKbOqpVjqST0qxzbjClufRhTnWPFgXHWOGiOVV4BedVTe PfPNOvIdbxiDZFMVAtrKlQKJAnfELs1xCIDXJCmv+5tFB+Y94Bgw+h0F8Y8CT7iphAtI17Koeap KOfR6GPou7ujKQg== X-Developer-Key: i=antonin.godard@bootlin.com; a=openpgp; fpr=8648725188DD401BB9A0D3FFD180414029A3A836 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Feb 2026 13:15:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/19062 We have a new run_git_diff() function that can be used both for showing diffs in git repositories, but also for printing diffs between two directories or files, making get_diff() redundant. Replace the single call to get_diff() by run_git_diff(). Signed-off-by: Antonin Godard --- bin/bitbake-setup | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/bin/bitbake-setup b/bin/bitbake-setup index e456aa93bf3..56c579d19f7 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -430,7 +430,7 @@ def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_c bb.process.run("{} -c '. {} && bitbake-config-build enable-fragment {}'".format(shell, init_script, " ".join(fragments))) if os.path.exists(backup_bitbake_confdir): - conf_diff = get_diff(backup_bitbake_confdir, bitbake_confdir) + conf_diff = run_git_diff(path1=backup_bitbake_confdir, path2=bitbake_confdir) if not conf_diff: logger.plain('New bitbake configuration from upstream is the same as the current one, no need to update it.') shutil.rmtree(bitbake_confdir) @@ -759,18 +759,6 @@ def init_config(top_dir, settings, args): bb.event.remove("bb.build.TaskProgress", None) -def get_diff(file1, file2): - try: - bb.process.run('diff --color={} -uNr {} {}'.format("always" if BBSETUP_COLOR else "never", - file1, - file2)) - except bb.process.ExecutionError as e: - if e.exitcode == 1: - return e.stdout - else: - raise e - return None - def are_layers_changed(layers, layerdir, d): def _is_git_remote_changed(r_remote, repodir): changed = False