Message ID | 20250827064940.16074-1-r.gruenert@pironex.com |
---|---|
State | New |
Headers | show |
Series | [v4] scripts/runqemu: raise an error when bitbake was not found | expand |
Thanks, I think this is good now. Alex On Wed, 27 Aug 2025 at 08:50, Richard Grünert <r.gruenert@pironex.com> wrote: > > 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> > > Signed-off-by: Richard Grünert <r.gruenert@pironex.com> > --- > changes in v4: > Changed commit message and error message string according > to suggestions by Alexander Kanavin. > > changes in v3: > Messed up the CC tag :) > > changes in v2: > Changed the position according to suggestion by Alexander Kanavin. > I also changed the error to OEPathError as this seems to be made for > this exact situation. > --- > scripts/runqemu | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/scripts/runqemu b/scripts/runqemu > index c24528eac8..69872f6de8 100755 > --- a/scripts/runqemu > +++ b/scripts/runqemu > @@ -1713,9 +1713,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') > @@ -1732,6 +1729,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')
diff --git a/scripts/runqemu b/scripts/runqemu index c24528eac8..69872f6de8 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -1713,9 +1713,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') @@ -1732,6 +1729,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')
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> Signed-off-by: Richard Grünert <r.gruenert@pironex.com> --- changes in v4: Changed commit message and error message string according to suggestions by Alexander Kanavin. changes in v3: Messed up the CC tag :) changes in v2: Changed the position according to suggestion by Alexander Kanavin. I also changed the error to OEPathError as this seems to be made for this exact situation. --- scripts/runqemu | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)