From: AdrianF <adrian.freihofer@siemens.com>
To: openembedded-core@lists.openembedded.org
Cc: Adrian Freihofer <adrian.freihofer@siemens.com>
Subject: [PATCH v2 18/25] devtool: deploy-target: allow deploying directly into a local rootfs
Date: Sun, 30 Aug 2026 23:48:40 +0200 [thread overview]
Message-ID: <20260830214912.1346063-19-adrian.freihofer@siemens.com> (raw)
In-Reply-To: <20260830214912.1346063-1-adrian.freihofer@siemens.com>
From: Adrian Freihofer <adrian.freihofer@siemens.com>
Accept an absolute path as the deploy-target "target" argument to copy
files directly into a local pseudo-managed rootfs directory (e.g. one
extracted by 'devtool ide-sdk --nfs' for NFS booting), instead of
always requiring an ssh connection.
Deploying over ssh to the target would also work for an NFS-mounted
rootfs, but that means dealing with the target's IP address and sshd
port, which is way more cumbersome than just passing a local path.
Copying the files in directly is also faster, since it avoids the
network/ssh round trip entirely.
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
scripts/lib/devtool/deploy.py | 119 ++++++++++++++++++++++++++++++----
1 file changed, 105 insertions(+), 14 deletions(-)
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
index d413fa7b91..4974a2fbae 100644
--- a/scripts/lib/devtool/deploy.py
+++ b/scripts/lib/devtool/deploy.py
@@ -20,6 +20,7 @@ import oe.types
import oe.package
from devtool import exec_fakeroot_no_d, setup_tinfoil, check_workspace_recipe, DevtoolError
+from runqemu_utils import native_environment, pseudo_state_dir
logger = logging.getLogger('devtool')
@@ -254,6 +255,85 @@ def deploy(args, config, basepath, workspace):
return deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_process, fakerootcmd, fakerootenv, args, file_globs=args.file_globs, packages_files=packages_files)
+def _deploy_local(args, target_dir, filelist, ftotalsize, tar_relpaths, allowed_files,
+ fakerootcmd, fakerootenv, path, recipe_outdir):
+ """Copy files directly into target_dir instead of over ssh/scp.
+
+ target_dir is expected to be a pseudo-managed rootfs previously extracted
+ on the host, e.g. by runqemu-extract-sdk or 'devtool ide-sdk --nfs' for a
+ target device or QEMU instance that NFS-mounts it.
+ """
+ if not os.path.isdir(target_dir):
+ raise DevtoolError('Target directory %s does not exist' % target_dir)
+ state_dir = pseudo_state_dir(target_dir)
+ if not os.path.isdir(state_dir):
+ raise DevtoolError(
+ '%s does not exist - %s does not look like a pseudo-managed rootfs '
+ '(e.g. one extracted by devtool ide-sdk --nfs).' % (state_dir, target_dir))
+
+ environment = native_environment()
+ pseudo = environment.get('PSEUDO')
+ native_sysroot = environment.get('OECORE_NATIVE_SYSROOT')
+ if not pseudo or not native_sysroot:
+ raise DevtoolError('qemu-helper-native did not provide pseudo')
+
+ if not args.no_check_space:
+ freespace = shutil.disk_usage(target_dir).free // 1024
+ if ftotalsize > freespace:
+ raise DevtoolError('Deploy failed - insufficient space on target '
+ '(available %d, needed %d)' % (freespace, ftotalsize))
+
+ # destdir is target_dir itself: the script writes directly into the
+ # local pseudo-managed rootfs directory, not into the real filesystem root.
+ destdir = target_dir
+ shellscript = _prepare_remote_script(deploy=True,
+ destdir=destdir,
+ verbose=args.show_status,
+ nopreserve=args.no_preserve,
+ nocheckspace=True)
+
+ tmpdir = tempfile.mkdtemp(prefix='devtool')
+ tar_filelist_path = None
+ try:
+ script_path = os.path.join(tmpdir, 'devtool_deploy.sh')
+ with open(script_path, 'w') as f:
+ f.write(shellscript)
+ filelist_path = os.path.join(tmpdir, 'devtool_deploy.list')
+ with open(filelist_path, 'w') as f:
+ f.write('%d\n' % ftotalsize)
+ for fpath, fsize in filelist:
+ f.write('%s %d\n' % (fpath, fsize))
+
+ if allowed_files is not None:
+ tar_fd, tar_filelist_path = tempfile.mkstemp(prefix='devtool-deploy-filelist-')
+ with os.fdopen(tar_fd, 'w') as f:
+ for relpath in tar_relpaths:
+ f.write('./' + relpath + '\n')
+ tar_cmd = 'tar cf - -T %s' % shlex.quote(tar_filelist_path)
+ else:
+ tar_cmd = 'tar cf - .'
+
+ # The extraction side needs its own pseudo session (with different database) than the recipe's own.
+ extract_cmd = 'PSEUDO_LOCALSTATEDIR=%s PSEUDO_INCLUDE_PATHS=%s %s -P %s sh %s %s %s %s' % (
+ shlex.quote(state_dir), shlex.quote(destdir), shlex.quote(pseudo),
+ shlex.quote(os.path.join(native_sysroot, 'usr')),
+ shlex.quote(script_path), shlex.quote(args.recipename),
+ shlex.quote(destdir), shlex.quote(filelist_path))
+ ret = exec_fakeroot_no_d(fakerootcmd, fakerootenv, path,
+ '%s | %s' % (tar_cmd, extract_cmd),
+ cwd=recipe_outdir, shell=True)
+ finally:
+ if tar_filelist_path:
+ os.remove(tar_filelist_path)
+ shutil.rmtree(tmpdir)
+
+ if ret != 0:
+ raise DevtoolError('Deploy failed - rerun with -s to get a complete '
+ 'error message')
+
+ logger.info('Successfully deployed %s to %s' % (recipe_outdir, target_dir))
+ return 0
+
def _deploy_ssh(args, destdir, filelist, ftotalsize, tar_relpaths, allowed_files,
fakerootcmd, fakerootenv, path, recipe_outdir):
"""Copy files to target_dir over ssh/scp (user@hostname[:destdir])."""
@@ -345,12 +425,16 @@ def _deploy_ssh(args, destdir, filelist, ftotalsize, tar_relpaths, allowed_files
def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_process, fakerootcmd, fakerootenv, args, file_globs=None, packages_files=None):
import math
- try:
- host, destdir = args.target.split(':')
- except ValueError:
- destdir = '/'
+ if os.path.isabs(args.target):
+ # A local pseudo-managed rootfs directory (e.g. NFS-exported)
+ destdir = os.path.realpath(args.target)
else:
- args.target = host
+ try:
+ host, destdir = args.target.split(':')
+ except ValueError:
+ destdir = '/'
+ else:
+ args.target = host
if not destdir.endswith('/'):
destdir += '/'
@@ -439,6 +523,12 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce
print(' %s' % item)
return 0
+ if os.path.isabs(args.target):
+ # A local directory (e.g. an NFS-exported rootfs) rather than a
+ # user@host ssh target: copy the files in directly, no network needed.
+ return _deploy_local(args, os.path.realpath(args.target), filelist, ftotalsize, tar_relpaths,
+ allowed_files, fakerootcmd, fakerootenv, path, recipe_outdir)
+
return _deploy_ssh(args, destdir, filelist, ftotalsize, tar_relpaths,
allowed_files, fakerootcmd, fakerootenv, path, recipe_outdir)
@@ -507,17 +597,18 @@ def register_commands(subparsers, context):
parser_deploy = subparsers.add_parser('deploy-target',
help='Deploy recipe output files to live target machine',
description='Deploys a recipe\'s build output (i.e. the output of '
- 'the do_install task) to a live target machine over ssh. '
- 'By default, any existing files will be preserved instead '
- 'of being overwritten and will be restored if you run '
- 'devtool undeploy-target. Note: this only deploys the '
- 'recipe itself and not any runtime dependencies, so it is '
- 'assumed that those have been installed on the target '
- 'beforehand. Use --package/--file-glob to deploy only a '
- 'subset of the recipe\'s installed files.',
+ 'the do_install task) to a live target machine over ssh, '
+ 'or directly into a local pseudo-managed rootfs directory '
+ '(e.g. one extracted for NFS booting). Existing files are '
+ 'preserved by default and restored by devtool '
+ 'undeploy-target. Only the recipe itself is deployed, not '
+ 'its runtime dependencies. Use --package/--file-glob to '
+ 'deploy only a subset of the recipe\'s installed files.',
group='testbuild')
parser_deploy.add_argument('recipename', help='Recipe to deploy')
- parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]')
+ parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]. '
+ 'Alternatively, an absolute path to a local pseudo-managed rootfs directory '
+ '(e.g. one extracted by devtool ide-sdk --nfs) to copy the files into directly, without ssh.')
parser_deploy.add_argument('-c', '--no-host-check', help='Disable ssh host key checking', action='store_true')
parser_deploy.add_argument('-s', '--show-status', help='Show progress/status output', action='store_true')
parser_deploy.add_argument('-n', '--dry-run', help='List files to be deployed only', action='store_true')
--
2.55.0
next prev parent reply other threads:[~2026-08-30 21:49 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 21:48 [PATCH v2 00/25] devtool: ide-sdk: NFS/slirp support, deploy filtering, and robustness fixes AdrianF
2026-08-30 21:48 ` [PATCH v2 01/25] runqemu-extract-sdk: set PSEUDO_INCLUDE_PATHS for the extraction AdrianF
2026-08-30 21:48 ` [PATCH v2 02/25] devtool: ide-sdk: dedupe solib_search_path entries AdrianF
2026-09-03 11:18 ` [OE-core] " Richard Purdie
2026-09-03 16:06 ` Freihofer, Adrian
2026-09-03 20:21 ` Richard Purdie
2026-08-30 21:48 ` [PATCH v2 03/25] devtool: ide-sdk: VSCode IntelliSense for rootfs-dbg sources AdrianF
2026-08-30 21:48 ` [PATCH v2 04/25] cpp-example: fix stuck breakpoints when attaching and daemonize properly AdrianF
2026-08-30 21:48 ` [PATCH v2 05/25] devtool: ide-sdk: auto-write image debug settings to bbappend AdrianF
2026-08-30 21:48 ` [PATCH v2 06/25] oe-selftest: devtool ide-sdk: adapt tests for auto-written image debug settings AdrianF
2026-08-30 21:48 ` [PATCH v2 07/25] oeqa: QemuTarget: set use_slirp when slirp is in runqemuparams AdrianF
2026-08-30 21:48 ` [PATCH v2 08/25] devtool: ide-sdk: support runqemu slirp AdrianF
2026-08-30 21:48 ` [PATCH v2 09/25] devtool: ide-sdk: auto-disable ssh host key checking for loopback targets AdrianF
2026-08-30 21:48 ` [PATCH v2 10/25] oe-selftest: devtool ide-sdk: add slirp networking test AdrianF
2026-08-30 21:48 ` [PATCH v2 11/25] devtool: deploy-target: add --package/--file-glob filters AdrianF
2026-08-30 22:11 ` Patchtest results for " patchtest
2026-08-30 21:48 ` [PATCH v2 12/25] oe-selftest: devtool deploy-target: test " AdrianF
2026-08-30 21:48 ` [PATCH v2 13/25] devtool: ide-sdk: forward --package/--file-glob deploy filters AdrianF
2026-08-30 21:48 ` [PATCH v2 14/25] oe-selftest: devtool ide-sdk: cover --package filters AdrianF
2026-08-30 21:48 ` [PATCH v2 15/25] runqemu-extract-sdk: refactor in Python AdrianF
2026-09-03 11:36 ` [OE-core] " Richard Purdie
2026-08-30 21:48 ` [PATCH v2 16/25] runqemu-export-rootfs: " AdrianF
2026-08-30 21:48 ` [PATCH v2 17/25] devtool: deploy: split ssh deployment into a separate function AdrianF
2026-08-30 21:48 ` AdrianF [this message]
2026-08-30 21:48 ` [PATCH v2 19/25] oe-selftest: devtool deploy-target: test deploying into a local rootfs path AdrianF
2026-08-30 21:48 ` [PATCH v2 20/25] oe-selftest: tinfoil: test prepared task runner AdrianF
2026-08-30 21:48 ` [PATCH v2 21/25] devtool: ide-sdk: run do_install through BitBake AdrianF
2026-08-30 21:48 ` [PATCH v2 22/25] oe-selftest: devtool ide-sdk: test install task AdrianF
2026-08-30 21:48 ` [PATCH v2 23/25] devtool: ide-sdk: support NFS rootfs AdrianF
2026-08-30 21:48 ` [PATCH v2 24/25] oe-selftest: devtool ide-sdk: test NFS debug rootfs AdrianF
2026-08-30 21:48 ` [PATCH v2 25/25] devtool: ide-sdk: fix GDB loading stale libs instead of recipe's own build AdrianF
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260830214912.1346063-19-adrian.freihofer@siemens.com \
--to=adrian.freihofer@siemens.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox