<div dir="ltr"><br><br>On 20 June 2017 at 10:42, Tobias Hagelborn &lt;<a href="mailto:tobias.hagelborn@axis.com">tobias.hagelborn@axis.com</a>&gt; wrote:<br>&gt;<br>&gt; New devtool deploy-target option --strip which enables deploying<br>&gt; stripped binaries, saving some space on target.<br>&gt;<br>&gt; * Copies the files of ${D} into a new directory and strips them in place<br>&gt; * Used oe.package.strip_execs for stripping directory<br>&gt; * Added devtool.conf option &quot;strip&quot; for changing default behavior<br>&gt;<br>&gt; Config example:<br>&gt; [Deploy]<br>&gt; strip = true<br>&gt;<br>&gt; [YOCTO #11227]<br>&gt;<br>&gt; Signed-off-by: Tobias Hagelborn &lt;<a href="mailto:tobiasha@axis.com">tobiasha@axis.com</a>&gt;<br>&gt; ---<br>&gt;  scripts/lib/devtool/deploy.py | 32 ++++++++++++++++++++++++++++----<br>&gt;  1 file changed, 28 insertions(+), 4 deletions(-)<br>&gt;<br>&gt; diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py<br>&gt; index 04c34cb..96b877e 100644<br>&gt; --- a/scripts/lib/devtool/deploy.py<br>&gt; +++ b/scripts/lib/devtool/deploy.py<br>&gt; @@ -16,12 +16,16 @@<br>&gt;  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>&gt;  &quot;&quot;&quot;Devtool plugin containing the deploy subcommands&quot;&quot;&quot;<br>&gt;<br>&gt; +import logging<br>&gt;  import os<br>&gt; +import shutil<br>&gt;  import subprocess<br>&gt; -import logging<br>&gt;  import tempfile<br>&gt; -import shutil<br>&gt; +<br>&gt; +import bb.utils<br>&gt;  import argparse_oe<br>&gt; +import oe<br>&gt; +<br>&gt;  from devtool import exec_fakeroot, setup_tinfoil, check_workspace_recipe, DevtoolError<br>&gt;<br>&gt;  logger = logging.getLogger(&#39;devtool&#39;)<br>&gt; @@ -140,9 +144,9 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals<br>&gt;      return &#39;\n&#39;.join(lines)<br>&gt;<br>&gt;<br>&gt; +<br>&gt;  def deploy(args, config, basepath, workspace):<br>&gt;      &quot;&quot;&quot;Entry point for the devtool &#39;deploy&#39; subcommand&quot;&quot;&quot;<br>&gt; -    import re<br>&gt;      import math<br>&gt;      import oe.recipeutils<br>&gt;<br>&gt; @@ -170,6 +174,17 @@ def deploy(args, config, basepath, workspace):<br>&gt;                              &#39;recipe? If so, the install step has not installed &#39;<br>&gt;                              &#39;any files.&#39; % args.recipename)<br>&gt;<br>&gt; +        if args.strip and not args.dry_run:<br>&gt; +            # Fakeroot copy to new destination<br>&gt; +            srcdir = recipe_outdir<br>&gt; +            recipe_outdir = os.path.join(rd.getVar(&#39;WORKDIR&#39;, True), &#39;deploy-target-stripped&#39;)<br>&gt; +            if os.path.isdir(recipe_outdir):<br>&gt; +                bb.utils.remove(recipe_outdir, True)<br>&gt; +            exec_fakeroot(rd, &quot;cp -af %s %s&quot; % (os.path.join(srcdir, &#39;.&#39;), recipe_outdir), shell=True)<br>&gt; +            os.environ[&#39;PATH&#39;] = &#39;:&#39;.join([os.environ[&#39;PATH&#39;], rd.getVar(&#39;PATH&#39;, True) or &#39;&#39;])<br>&gt; +            oe.package.strip_execs(args.recipename, recipe_outdir, rd.getVar(&#39;STRIP&#39;, True), rd.getVar(&#39;libdir&#39;, True),<br>&gt; +                        rd.getVar(&#39;base_libdir&#39;, True))<br>&gt; +<br>&gt;          filelist = []<br>&gt;          ftotalsize = 0<br>&gt;          for root, _, files in os.walk(recipe_outdir):<br>&gt; @@ -189,7 +204,6 @@ def deploy(args, config, basepath, workspace):<br>&gt;                  print(&#39;  %s&#39; % item)<br>&gt;              return 0<br>&gt;<br>&gt; -<br>&gt;          extraoptions = &#39;&#39;<br>&gt;          if args.no_host_check:<br>&gt;              extraoptions += &#39;-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no&#39;<br>&gt; @@ -301,6 +315,7 @@ def undeploy(args, config, basepath, workspace):<br>&gt;<br>&gt;  def register_commands(subparsers, context):<br>&gt;      &quot;&quot;&quot;Register devtool subcommands from the deploy plugin&quot;&quot;&quot;<br>&gt; +<br>&gt;      parser_deploy = subparsers.add_parser(&#39;deploy-target&#39;,<br>&gt;                                            help=&#39;Deploy recipe output files to live target machine&#39;,<br>&gt;                                            description=&#39;Deploys a recipe\&#39;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.&#39;,<br>&gt; @@ -313,6 +328,15 @@ def register_commands(subparsers, context):<br>&gt;      parser_deploy.add_argument(&#39;-p&#39;, &#39;--no-preserve&#39;, help=&#39;Do not preserve existing files&#39;, action=&#39;store_true&#39;)<br>&gt;      parser_deploy.add_argument(&#39;--no-check-space&#39;, help=&#39;Do not check for available space before deploying&#39;, action=&#39;store_true&#39;)<br>&gt;      parser_deploy.add_argument(&#39;-P&#39;, &#39;--port&#39;, default=&#39;22&#39;, help=&#39;Port to use for connection to the target&#39;)<br>&gt; +<br>&gt; +    strip_opts = parser_deploy.add_mutually_exclusive_group(required=False)<br>&gt; +    strip_opts.add_argument(&#39;-S&#39;, &#39;--strip&#39;,<br>&gt; +                               help=&#39;Strip executables prior to deploying (default: %(default)s). &#39;<br>&gt; +                                    &#39;The default value of this option can be controlled by setting the strip option in the [Deploy] section to True or False.&#39;,<br>&gt; +                               default=oe.types.boolean(context.config.get(&#39;Deploy&#39;, &#39;strip&#39;, default=&#39;0&#39;)),<br>&gt; +                               action=&#39;store_true&#39;)<br><br>Autobuilder is complaining about this:<br><br>Exception: bb.process.ExecutionError: Execution of &#39;devtool --bbpath /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/meta-poky:/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/build:/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/meta:/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/meta-yocto-bsp --basepath /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/sdk-ext/image//opt/poky/2.3 create-workspace --create-only /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/sdk-ext/image//opt/poky/2.3/workspace&#39; failed with exit code 1:<br>Traceback (most recent call last):<br>  File &quot;/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/devtool&quot;, line 351, in &lt;module&gt;<br>    ret = main()<br>  File &quot;/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/devtool&quot;, line 329, in main<br>    plugin.register_commands(subparsers, context)<br>  File &quot;/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/lib/devtool/deploy.py&quot;, line 336, in register_commands<br>    default=oe.types.boolean(context.config.get(&#39;Deploy&#39;, &#39;strip&#39;, default=&#39;0&#39;)),<br>AttributeError: module &#39;oe&#39; has no attribute &#39;types&#39;<br><br>See <a href="https://autobuilder.yocto.io/builders/nightly-x86-64/builds/333/steps/BuildImages_2/logs/stdio">https://autobuilder.yocto.io/builders/nightly-x86-64/builds/333/steps/BuildImages_2/logs/stdio</a> for context.<br><br><br>&gt; +    strip_opts.add_argument(&#39;--no-strip&#39;, help=&#39;Do not strip executables prior to deploy&#39;, dest=&#39;strip&#39;, action=&#39;store_false&#39;)<br>&gt; +<br>&gt;      parser_deploy.set_defaults(func=deploy)<br>&gt;<br>&gt;      parser_undeploy = subparsers.add_parser(&#39;undeploy-target&#39;,<br>&gt; --<br>&gt; 2.1.4<br>&gt;<br>&gt; --<br>&gt; _______________________________________________<br>&gt; Openembedded-core mailing list<br>&gt; <a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.openembedded.org</a><br>&gt; <a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br></div>