diff mbox series

[21/24] devtool: ide-sdk: run do_install through BitBake

Message ID 20260830142922.17241-22-adrian.freihofer@siemens.com
State New
Headers show
Series devtool: ide-sdk: NFS/slirp support, deploy filtering, and robustness fixes | expand

Commit Message

AdrianF Aug. 30, 2026, 2:28 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

Generate a Python install-task runner for the IDE SDK environment. It
prepares Tinfoil normally, then invokes run_prepared_task() to rerun
do_install through BitBake's worker path before deploying the result.

The IDE owns configure, compile, and unit-test steps in the modified source
tree. At deployment time, resolving task dependencies could rerun those
steps, discard the IDE's build results, and add unnecessary delay. The
prepared-task runner therefore executes only do_install after BitBake has
prepared its prerequisites.

This supports shell and Python task bodies and lets BitBake establish the
fakeroot environment when the task requires pseudo.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 scripts/lib/devtool/ide_sdk.py | 42 +++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index ac4930af50..ee3c50460a 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -1400,26 +1400,32 @@  class RecipeModified:
                           self.fakerootcmd, self.fakerootenv))
         return self.write_script(cmd_lines, 'deploy_target')
 
+    def gen_install_task_script(self):
+        """Generate a script which runs do_install through BitBake."""
+        cmd_lines = ['#!%s' % sys.executable]
+        if self.cmd_compile:
+            cmd_lines += ['import subprocess',
+                          'subprocess.run(%s, cwd=%r, shell=True, check=True)' %
+                          (repr(self.cmd_compile), self.real_srctree)]
+        cmd_lines += ['import os',
+                      'import sys',
+                      'sys.path.insert(0, %r)' % os.path.realpath(
+                          os.path.join(self.bitbakepath, '..', 'lib')),
+                      'import bb.tinfoil',
+                      'os.chdir(%r)' % self.topdir,
+                      'tinfoil = bb.tinfoil.Tinfoil()',
+                      'try:',
+                      '    tinfoil.prepare(config_only=False, quiet=2)',
+                      '    tinfoil.run_prepared_task(%r, "do_install")' % self.pn,
+                      'finally:',
+                      '    tinfoil.shutdown()']
+        return self.write_script(cmd_lines, 'bb_run_do_install')
+
     def gen_install_deploy_script(self, args):
         """Generate a script which does install and deploy"""
-        cmd_lines = ['#!/bin/sh']
-
-        # Save the original command-line args before 'set' overwrites $@
-        cmd_lines.append('_args="$@"')
-        # . oe-init-build-env $BUILDDIR $BITBAKEDIR
-        # Using 'set' to pass the build directory to oe-init-build-env in sh syntax
-        cmd_lines.append('cd "%s" || { echo "cd %s failed"; exit 1; }' % (
-            self.oe_init_dir, self.oe_init_dir))
-        cmd_lines.append('set %s %s' % (self.topdir, self.bitbakepath.rstrip('/bin')))
-        cmd_lines.append('. "%s" || { echo ". %s %s failed"; exit 1; }' % (
-            self.oe_init_build_env, self.oe_init_build_env, self.topdir))
-
-        # bitbake -c install
-        cmd_lines.append(
-            'bitbake %s -c install --force || { echo "bitbake %s -c install --force failed"; exit 1; }' % (self.bpn, self.bpn))
-
-        # Self contained devtool deploy-target - use saved args, not $@ (overwritten by 'set')
-        cmd_lines.append(self.gen_deploy_target_script(args) + ' $_args')
+        cmd_lines = ['#!/bin/sh -e']
+        cmd_lines.append(self.gen_install_task_script())
+        cmd_lines.append(self.gen_deploy_target_script(args) + ' "$@"')
 
         return self.write_script(cmd_lines, 'install_and_deploy')