summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTobias Hagelborn <tobias.hagelborn@axis.com>2017-08-25 13:32:38 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-27 22:32:00 +0100
commitcd26fc143bbfd948795c2e65a577f89627a4f841 (patch)
treec1a77baaf501dd66befcbaf56e75a1a94bd2c043 /scripts
parent390dcbf2e14f212d81a8fe252cf3ae801b82ffa9 (diff)
downloadpoky-cd26fc143bbfd948795c2e65a577f89627a4f841.tar.gz
devtool: deploy-target: Support stripped libs and execs
New devtool deploy-target option --strip which enables deploying stripped binaries, saving some space on target. * Copies the files of ${D} into a new directory and strips them in place * Used oe.package.strip_execs for stripping directory * Added devtool.conf option "strip" for changing default behavior Config example: [Deploy] strip = true [YOCTO #11227] (From OE-Core rev: 7f10c5118793da6ded59ae6e60e796152dbd7ca3) Signed-off-by: Tobias Hagelborn <tobiasha@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/deploy.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
index 04c34cb016..7c571746c8 100644
--- a/scripts/lib/devtool/deploy.py
+++ b/scripts/lib/devtool/deploy.py
@@ -16,12 +16,16 @@
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17"""Devtool plugin containing the deploy subcommands""" 17"""Devtool plugin containing the deploy subcommands"""
18 18
19import logging
19import os 20import os
21import shutil
20import subprocess 22import subprocess
21import logging
22import tempfile 23import tempfile
23import shutil 24
25import bb.utils
24import argparse_oe 26import argparse_oe
27import oe.types
28
25from devtool import exec_fakeroot, setup_tinfoil, check_workspace_recipe, DevtoolError 29from devtool import exec_fakeroot, setup_tinfoil, check_workspace_recipe, DevtoolError
26 30
27logger = logging.getLogger('devtool') 31logger = logging.getLogger('devtool')
@@ -140,11 +144,12 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals
140 return '\n'.join(lines) 144 return '\n'.join(lines)
141 145
142 146
147
143def deploy(args, config, basepath, workspace): 148def deploy(args, config, basepath, workspace):
144 """Entry point for the devtool 'deploy' subcommand""" 149 """Entry point for the devtool 'deploy' subcommand"""
145 import re
146 import math 150 import math
147 import oe.recipeutils 151 import oe.recipeutils
152 import oe.package
148 153
149 check_workspace_recipe(workspace, args.recipename, checksrc=False) 154 check_workspace_recipe(workspace, args.recipename, checksrc=False)
150 155
@@ -170,6 +175,17 @@ def deploy(args, config, basepath, workspace):
170 'recipe? If so, the install step has not installed ' 175 'recipe? If so, the install step has not installed '
171 'any files.' % args.recipename) 176 'any files.' % args.recipename)
172 177
178 if args.strip and not args.dry_run:
179 # Fakeroot copy to new destination
180 srcdir = recipe_outdir
181 recipe_outdir = os.path.join(rd.getVar('WORKDIR', True), 'deploy-target-stripped')
182 if os.path.isdir(recipe_outdir):
183 bb.utils.remove(recipe_outdir, True)
184 exec_fakeroot(rd, "cp -af %s %s" % (os.path.join(srcdir, '.'), recipe_outdir), shell=True)
185 os.environ['PATH'] = ':'.join([os.environ['PATH'], rd.getVar('PATH', True) or ''])
186 oe.package.strip_execs(args.recipename, recipe_outdir, rd.getVar('STRIP', True), rd.getVar('libdir', True),
187 rd.getVar('base_libdir', True))
188
173 filelist = [] 189 filelist = []
174 ftotalsize = 0 190 ftotalsize = 0
175 for root, _, files in os.walk(recipe_outdir): 191 for root, _, files in os.walk(recipe_outdir):
@@ -189,7 +205,6 @@ def deploy(args, config, basepath, workspace):
189 print(' %s' % item) 205 print(' %s' % item)
190 return 0 206 return 0
191 207
192
193 extraoptions = '' 208 extraoptions = ''
194 if args.no_host_check: 209 if args.no_host_check:
195 extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 210 extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
@@ -301,6 +316,7 @@ def undeploy(args, config, basepath, workspace):
301 316
302def register_commands(subparsers, context): 317def register_commands(subparsers, context):
303 """Register devtool subcommands from the deploy plugin""" 318 """Register devtool subcommands from the deploy plugin"""
319
304 parser_deploy = subparsers.add_parser('deploy-target', 320 parser_deploy = subparsers.add_parser('deploy-target',
305 help='Deploy recipe output files to live target machine', 321 help='Deploy recipe output files to live target machine',
306 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.', 322 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.',
@@ -313,6 +329,15 @@ def register_commands(subparsers, context):
313 parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true') 329 parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true')
314 parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true') 330 parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true')
315 parser_deploy.add_argument('-P', '--port', default='22', help='Port to use for connection to the target') 331 parser_deploy.add_argument('-P', '--port', default='22', help='Port to use for connection to the target')
332
333 strip_opts = parser_deploy.add_mutually_exclusive_group(required=False)
334 strip_opts.add_argument('-S', '--strip',
335 help='Strip executables prior to deploying (default: %(default)s). '
336 'The default value of this option can be controlled by setting the strip option in the [Deploy] section to True or False.',
337 default=oe.types.boolean(context.config.get('Deploy', 'strip', default='0')),
338 action='store_true')
339 strip_opts.add_argument('--no-strip', help='Do not strip executables prior to deploy', dest='strip', action='store_false')
340
316 parser_deploy.set_defaults(func=deploy) 341 parser_deploy.set_defaults(func=deploy)
317 342
318 parser_undeploy = subparsers.add_parser('undeploy-target', 343 parser_undeploy = subparsers.add_parser('undeploy-target',