diff mbox series

[2/3] bitbake-setup: Fix extracting config name

Message ID 20250912204559.10360-2-reatmon@ti.com
State New
Headers show
Series [1/3] bitbake-setup: Tweak user inputs | expand

Commit Message

Ryan Eatmon Sept. 12, 2025, 8:45 p.m. UTC
When extracting the config name from from the filename, just splitting
on . does not allow for . in the config name.  For example:

coresdk-11.01.08-config.json -> coresdk-11

when it should be:

coresdk-11.01.08-config.json -> coresdk-11.01.08-config

os.path.splitext() already does this logic correctly, so use that
instead.

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
---
 bin/bitbake-setup | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Kanavin Sept. 15, 2025, 9:51 a.m. UTC | #1
On Fri, 12 Sept 2025 at 22:46, Ryan Eatmon via lists.openembedded.org
<reatmon=ti.com@lists.openembedded.org> wrote:
>
> When extracting the config name from from the filename, just splitting
> on . does not allow for . in the config name.  For example:
>
> coresdk-11.01.08-config.json -> coresdk-11
>
> when it should be:
>
> coresdk-11.01.08-config.json -> coresdk-11.01.08-config
>
> os.path.splitext() already does this logic correctly, so use that
> instead.

The files are explicitly expected to end with .conf.json. Otherwise
the tool could potentially pick up unrelated json files in registries.
There's probably a missing check for that condition somewhere?

Alex
Ryan Eatmon Sept. 15, 2025, 11:50 a.m. UTC | #2
On 9/15/2025 4:51 AM, Alexander Kanavin wrote:
> On Fri, 12 Sept 2025 at 22:46, Ryan Eatmon via lists.openembedded.org
> <reatmon=ti.com@lists.openembedded.org> wrote:
>>
>> When extracting the config name from from the filename, just splitting
>> on . does not allow for . in the config name.  For example:
>>
>> coresdk-11.01.08-config.json -> coresdk-11
>>
>> when it should be:
>>
>> coresdk-11.01.08-config.json -> coresdk-11.01.08-config
>>
>> os.path.splitext() already does this logic correctly, so use that
>> instead.
> 
> The files are explicitly expected to end with .conf.json. Otherwise
> the tool could potentially pick up unrelated json files in registries.
> There's probably a missing check for that condition somewhere?

I'll update my code then to remove the .conf.json only then and send a v2.


> Alex
Alexander Kanavin Sept. 15, 2025, 1:51 p.m. UTC | #3
On Mon, 15 Sept 2025 at 13:50, Ryan Eatmon <reatmon@ti.com> wrote:

> > The files are explicitly expected to end with .conf.json. Otherwise
> > the tool could potentially pick up unrelated json files in registries.
> > There's probably a missing check for that condition somewhere?
>
> I'll update my code then to remove the .conf.json only then and send a v2.

Thanks, I've already fixed this locally. Files with . in them should work now.

 def get_config_name(config):
-    return os.path.basename(config).split('.')[0]
+    suffix = '.conf.json'
+    config_file = os.path.basename(config)
+    if config_file.endswith(suffix):
+        return config_file[:-len(suffix)]
+    else:
+        raise Exception("Config file {} does not end with
{}".format(config, suffix))


Alex
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 36103f1e8..342251bd5 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -50,7 +50,7 @@  def save_bb_cache():
     bb.fetch2.fetcher_parse_done()
 
 def get_config_name(config):
-    return os.path.basename(config).split('.')[0]
+    return os.path.splitext(os.path.basename(config))[0]
 
 def write_config(config, config_dir):
     with open(os.path.join(config_dir, "config-upstream.json"),'w') as s: