* [PATCH 1/3] scripts/runqemu: raise an error when bitbake was not found
@ 2025-10-07 12:46 Alexander Kanavin
2025-10-07 12:46 ` [PATCH 2/3] runqemu: ensure that bitbake environment is either returned, or an exception is raised Alexander Kanavin
2025-10-07 12:46 ` [PATCH 3/3] scripts/runqemu: remove the code block that works around the missing bitbake environment Alexander Kanavin
0 siblings, 2 replies; 3+ messages in thread
From: Alexander Kanavin @ 2025-10-07 12:46 UTC (permalink / raw)
To: openembedded-core
Cc: Richard Grünert, Richard Purdie, Alexander Kanavin,
Mathieu Dubois-Briand
From: Richard Grünert <r.gruenert@pironex.com>
Running 'scrupts/runqemu' without bitbake in PATH causes the
following error:
```
Traceback (most recent call last):
File "/home/rg/temp_stuff/oe_2/./scripts/runqemu", line 1807, in main
config.check_args()
~~~~~~~~~~~~~~~~~^^
File "/home/rg/temp_stuff/oe_2/./scripts/runqemu", line 624, in check_args
s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M)
File "/usr/lib/python3.13/re/__init__.py", line 177, in search
return _compile(pattern, flags).search(string)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
```
This patch adds a more helpful error message to inform the user that
bitbake was not found, e.g. because oe-init-build-env was not sourced.
This is an example of the new error message after the patch:
```
runqemu - ERROR - In order for this script to dynamically infer paths
kernels or filesystem images, you either need bitbake in your PATH
or to source oe-init-build-env before running this script.
Dynamic path inference can be avoided by passing a *.qemuboot.conf to
runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
Bitbake is needed to run 'bitbake -e', but it is not found in PATH. Please source the bitbake build environment.
```
CC: Richard Purdie <richard.purdie@linuxfoundation.org>
CC: Alexander Kanavin <alex.kanavin@gmail.com>
(From OE-Core rev: c9744f2d294f5baa8c4c9c795eb73d269f943b0c)
Signed-off-by: Richard Grünert <r.gruenert@pironex.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
scripts/runqemu | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index 32c7a2aab3b..c28980e6163 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1714,9 +1714,6 @@ to your build configuration.
self.cleaned = True
def run_bitbake_env(self, mach=None, target=''):
- bitbake = shutil.which('bitbake')
- if not bitbake:
- return
if not mach:
mach = self.get('MACHINE')
@@ -1733,6 +1730,10 @@ to your build configuration.
else:
cmd = 'bitbake -e %s %s' % (multiconfig, target)
+ bitbake = shutil.which('bitbake')
+ if not bitbake:
+ raise OEPathError("Bitbake is needed to run '%s', but it is not found in PATH. Please source the bitbake build environment." % cmd.strip())
+
logger.info('Running %s...' % cmd)
try:
return subprocess.check_output(cmd, shell=True).decode('utf-8')
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/3] runqemu: ensure that bitbake environment is either returned, or an exception is raised
2025-10-07 12:46 [PATCH 1/3] scripts/runqemu: raise an error when bitbake was not found Alexander Kanavin
@ 2025-10-07 12:46 ` Alexander Kanavin
2025-10-07 12:46 ` [PATCH 3/3] scripts/runqemu: remove the code block that works around the missing bitbake environment Alexander Kanavin
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Kanavin @ 2025-10-07 12:46 UTC (permalink / raw)
To: openembedded-core; +Cc: Alexander Kanavin
From: Alexander Kanavin <alex@linutronix.de>
This eliminates the other remaining code path where environment getter
returns 'nothing'. This and the previous patch were tested in a-full,
and no errors occurred [1], which means the code paths that make
use of the function returning nothing are never actually executed
and can be cleaned up (in the following patch).
The rationale is that if environment getter cannot obtain the environment,
it should report that and not sweep the issue under the carpet;
it's up to the caller to handle that situation, or make pre-emptive
checks that avoid calling the environment getter when it is bound to fail.
[1] https://lists.openembedded.org/g/openembedded-core/message/223651
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
scripts/runqemu | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index c28980e6163..1e8406e1194 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1745,11 +1745,7 @@ to your build configuration.
cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target)
else:
cmd = 'bitbake -e %s %s' % (multiconfig, target)
- try:
- return subprocess.check_output(cmd, shell=True).decode('utf-8')
- except subprocess.CalledProcessError as err:
- logger.warning("Couldn't run '%s' to gather environment information, giving up with 'bitbake -e':\n%s" % (cmd, err.output.decode('utf-8')))
- return ''
+ return subprocess.check_output(cmd, shell=True).decode('utf-8')
def load_bitbake_env(self, mach=None, target=None):
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 3/3] scripts/runqemu: remove the code block that works around the missing bitbake environment
2025-10-07 12:46 [PATCH 1/3] scripts/runqemu: raise an error when bitbake was not found Alexander Kanavin
2025-10-07 12:46 ` [PATCH 2/3] runqemu: ensure that bitbake environment is either returned, or an exception is raised Alexander Kanavin
@ 2025-10-07 12:46 ` Alexander Kanavin
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Kanavin @ 2025-10-07 12:46 UTC (permalink / raw)
To: openembedded-core; +Cc: Alexander Kanavin
From: Alexander Kanavin <alex@linutronix.de>
As confirmed by the previous patch this code path is never taken
and can be removed.
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
scripts/runqemu | 34 ++++++----------------------------
1 file changed, 6 insertions(+), 28 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index 1e8406e1194..2be7a0f2869 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1007,34 +1007,12 @@ to your build configuration.
if not self.bitbake_e:
self.load_bitbake_env()
- if self.bitbake_e:
- native_vars = ['STAGING_DIR_NATIVE']
- for nv in native_vars:
- s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
- if s and s.group(1) != self.get(nv):
- logger.info('Overriding conf file setting of %s to %s from Bitbake environment' % (nv, s.group(1)))
- self.set(nv, s.group(1))
- else:
- # when we're invoked from a running bitbake instance we won't
- # be able to call `bitbake -e`, then try:
- # - get OE_TMPDIR from environment and guess paths based on it
- # - get OECORE_NATIVE_SYSROOT from environment (for sdk)
- tmpdir = self.get('OE_TMPDIR')
- oecore_native_sysroot = self.get('OECORE_NATIVE_SYSROOT')
- if tmpdir:
- logger.info('Setting STAGING_DIR_NATIVE and STAGING_BINDIR_NATIVE relative to OE_TMPDIR (%s)' % tmpdir)
- hostos, _, _, _, machine = os.uname()
- buildsys = '%s-%s' % (machine, hostos.lower())
- staging_dir_native = '%s/sysroots/%s' % (tmpdir, buildsys)
- self.set('STAGING_DIR_NATIVE', staging_dir_native)
- elif oecore_native_sysroot:
- logger.info('Setting STAGING_DIR_NATIVE to OECORE_NATIVE_SYSROOT (%s)' % oecore_native_sysroot)
- self.set('STAGING_DIR_NATIVE', oecore_native_sysroot)
- if self.get('STAGING_DIR_NATIVE'):
- # we have to assume that STAGING_BINDIR_NATIVE is at usr/bin
- staging_bindir_native = '%s/usr/bin' % self.get('STAGING_DIR_NATIVE')
- logger.info('Setting STAGING_BINDIR_NATIVE to %s' % staging_bindir_native)
- self.set('STAGING_BINDIR_NATIVE', '%s/usr/bin' % self.get('STAGING_DIR_NATIVE'))
+ native_vars = ['STAGING_DIR_NATIVE']
+ for nv in native_vars:
+ s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
+ if s and s.group(1) != self.get(nv):
+ logger.info('Overriding conf file setting of %s to %s from Bitbake environment' % (nv, s.group(1)))
+ self.set(nv, s.group(1))
def print_config(self):
logoutput = ['Continuing with the following parameters:']
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-07 12:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 12:46 [PATCH 1/3] scripts/runqemu: raise an error when bitbake was not found Alexander Kanavin
2025-10-07 12:46 ` [PATCH 2/3] runqemu: ensure that bitbake environment is either returned, or an exception is raised Alexander Kanavin
2025-10-07 12:46 ` [PATCH 3/3] scripts/runqemu: remove the code block that works around the missing bitbake environment Alexander Kanavin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox