diff mbox series

[auh,02/11] upgrade-helper.py: use scripts path to locate oe-core directory

Message ID 20260311063557.229656-2-Qi.Chen@windriver.com
State New
Headers show
Series [auh,01/11] upgrade-helper.py: remove unused self.poky_git settings | expand

Commit Message

ChenQi March 11, 2026, 6:35 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

Using the first element in PATH is really awkward and prone to
errors. As we have already located the scripts directory by
using shutil.which('devtool'), we could well make use of it to
locate oe-core directory.

Note that the scripts could be a symbolic link to the real location
under oe-core. So we need to use os.path.realpath() to get its
real location.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 upgrade-helper.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/upgrade-helper.py b/upgrade-helper.py
index 3b98f7c..27e1f48 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -67,7 +67,7 @@  if not os.getenv('BUILDDIR', False):
     exit(1)
 
 # Use the location of devtool to find scriptpath and hence bb/oe libs
-scripts_path = os.path.abspath(os.path.dirname(shutil.which("devtool")))
+scripts_path = os.path.realpath(os.path.abspath(os.path.dirname(shutil.which("devtool"))))
 sys.path = sys.path + [scripts_path + '/lib']
 import scriptpath
 scriptpath.add_bitbake_lib_path()
@@ -185,8 +185,8 @@  class Updater(object):
 
             self.git = Git(self.opts['layer_dir'])
         else:
-            # XXX: assume that the poky directory is the first entry in the PATH
-            self.git = Git(os.path.dirname(os.getenv('PATH', False).split(':')[0]))
+            # use scripts_path to get oe-core directory
+            self.git = Git(os.path.dirname(scripts_path))
         self.opts['machines'] = settings.get('machines', 'qemux86-64 qemuarm_musl').split()
 
         self.opts['send_email'] = self.args.send_emails