diff mbox series

[10/10] bitbake-setup: improve robustness of loading/writing settings

Message ID 20250929125616.1751116-10-alex.kanavin@gmail.com
State New
Headers show
Series [01/10] bitbake-setup: add the initial implementation | expand

Commit Message

Alexander Kanavin Sept. 29, 2025, 12:56 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

Particularly:

- ensure global settings command line argument is always expanded to
full path
- ensure any errors that happen when loading settings are reported
at that point, otherwise we get an empty dictionary and cryptic
key errors later

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 bin/bitbake-setup | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 8ceacada9..1fbb65494 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -635,11 +635,11 @@  def load_settings(top_dir, non_interactive):
     settings_path = default_settings_path(top_dir)
     settings = configparser.ConfigParser()
     print('Loading settings from\n    {}\n'.format(settings_path))
-    settings.read([settings_path])
+    settings.read_file(open(settings_path))
     return settings
 
 def global_settings_path(args):
-    return args.global_settings if args.global_settings else os.path.join(os.path.expanduser('~'), '.config', 'bitbake-setup', 'config')
+    return os.path.abspath(args.global_settings) if args.global_settings else os.path.join(os.path.expanduser('~'), '.config', 'bitbake-setup', 'config')
 
 def write_global_settings(settings_path, force_replace, non_interactive=True):
     if not os.path.exists(settings_path) or force_replace:
@@ -673,7 +673,7 @@  def load_global_settings(settings_path, non_interactive):
 
     settings = configparser.ConfigParser()
     print('Loading global settings from\n    {}\n'.format(settings_path))
-    settings.read([settings_path])
+    settings.read_file(open(settings_path))
     return settings
 
 def change_settings(top_dir, new_settings):