]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
devtool: un-/deploy-target: put deploylist into destdir
authorJohannes Schneider <johannes.schneider@leica-geosystems.com>
Fri, 17 Oct 2025 01:41:23 +0000 (01:41 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 27 Oct 2025 16:58:15 +0000 (16:58 +0000)
When deploying on devices with a RO root-filesystem, devtool would
fail on writing to the hard-coded "deploylist_path = '/.devtool'"

Since devtool already supports deploying to a different root-prefix
with: hostname[:destdir], we can make use of this guaranteed RW
location to place the deployment-list there.

Add the destdir parameter to the _prepare_remote_script function, to
construct the deploylist_path from it. For the 'undeploy' the same
host:destdir splitting logic is used as in 'deploy'.

Now it is possible to modify and build a recipe 'foo-bar' with
devtool, and have its ./image content deployed through:
$build> devtool deploy foo-bar target:/opt/development-overlay
Or removed again with:
$build> devtool undeploy foo-bar target:/opt/development-overlay

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
scripts/lib/devtool/deploy.py

index b5ca8f2c2f1c75eb3ca36d16cddac3eb177ad9be..a98b33c5718aa83120e57b93a89802c96558d5a3 100644 (file)
@@ -20,9 +20,9 @@ from devtool import exec_fakeroot_no_d, setup_tinfoil, check_workspace_recipe, D
 
 logger = logging.getLogger('devtool')
 
-deploylist_path = '/.devtool'
+deploylist_dirname = '.devtool'
 
-def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=False, nopreserve=False, nocheckspace=False):
+def _prepare_remote_script(deploy, destdir='/', verbose=False, dryrun=False, undeployall=False, nopreserve=False, nocheckspace=False):
     """
     Prepare a shell script for running on the target to
     deploy/undeploy files. We have to be careful what we put in this
@@ -31,6 +31,7 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals
     busybox rather than bash with coreutils).
     """
     lines = []
+    deploylist_path = os.path.join(destdir, deploylist_dirname)
     lines.append('#!/bin/sh')
     lines.append('set -e')
     if undeployall:
@@ -146,7 +147,7 @@ def deploy(args, config, basepath, workspace):
         except Exception as e:
             raise DevtoolError('Exception parsing recipe %s: %s' %
                             (args.recipename, e))
-        
+
         srcdir = rd.getVar('D')
         workdir = rd.getVar('WORKDIR')
         path = rd.getVar('PATH')
@@ -244,6 +245,7 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce
         tmpscript = '/tmp/devtool_deploy.sh'
         tmpfilelist = os.path.join(os.path.dirname(tmpscript), 'devtool_deploy.list')
         shellscript = _prepare_remote_script(deploy=True,
+                                            destdir=destdir,
                                             verbose=args.show_status,
                                             nopreserve=args.no_preserve,
                                             nocheckspace=args.no_check_space)
@@ -303,12 +305,19 @@ def undeploy(args, config, basepath, workspace):
         scp_port = "-P %s" % args.port
         ssh_port = "-p %s" % args.port
 
-    args.target = args.target.split(':')[0]
+    try:
+        host, destdir = args.target.split(':')
+    except ValueError:
+        destdir = '/'
+    else:
+        args.target = host
+    if not destdir.endswith('/'):
+        destdir += '/'
 
     tmpdir = tempfile.mkdtemp(prefix='devtool')
     try:
         tmpscript = '/tmp/devtool_undeploy.sh'
-        shellscript = _prepare_remote_script(deploy=False, dryrun=args.dry_run, undeployall=args.all)
+        shellscript = _prepare_remote_script(deploy=False, destdir=destdir, dryrun=args.dry_run, undeployall=args.all)
         # Write out the script to a file
         with open(os.path.join(tmpdir, os.path.basename(tmpscript)), 'w') as f:
             f.write(shellscript)