package.py: Add function strip_execs
PATCH v3 2/4 staging.bbclass: Make use of oe.package.strip_execs
In reply to Tobias HagelbornMake use of the library function oe.package.strip_execs for stripping sysroot executables. oe.packge.strip_execs is based on code previously residing in sysroot_strip.
--- meta/classes/staging.bbclass | 108 ++++++------------------------------------- 1 file changed, 13 insertions(+), 95 deletions(-)
meta/classes/staging.bbclass +13 -95
@@ -68,101 +68,19 @@ sysroot_stage_all() { } python sysroot_strip () { - import stat, errno - - dvar = d.getVar('SYSROOT_DESTDIR') - pn = d.getVar('PN') - - os.chdir(dvar) - - # Return type (bits): - # 0 - not elf - # 1 - ELF - # 2 - stripped - # 4 - executable - # 8 - shared library - # 16 - kernel module - def isELF(path): - type = 0 - ret, result = oe.utils.getstatusoutput("file \"%s\"" % path.replace("\"", "\\\"")) - - if ret: - bb.error("sysroot_strip: 'file %s' failed" % path) - return type - - # Not stripped - if "ELF" in result: - type |= 1 - if "not stripped" not in result: - type |= 2 - if "executable" in result: - type |= 4 - if "shared" in result: - type |= 8 - return type - - - elffiles = {} - inodes = {} - libdir = os.path.abspath(dvar + os.sep + d.getVar("libdir")) - baselibdir = os.path.abspath(dvar + os.sep + d.getVar("base_libdir")) - if (d.getVar('INHIBIT_SYSROOT_STRIP') != '1'): - # - # First lets figure out all of the files we may have to process - # - for root, dirs, files in os.walk(dvar): - for f in files: - file = os.path.join(root, f) - - try: - ltarget = oe.path.realpath(file, dvar, False) - s = os.lstat(ltarget) - except OSError as e: - (err, strerror) = e.args - if err != errno.ENOENT: - raise - # Skip broken symlinks - continue - if not s: - continue - # Check its an excutable - if (s[stat.ST_MODE] & stat.S_IXUSR) or (s[stat.ST_MODE] & stat.S_IXGRP) or (s[stat.ST_MODE] & stat.S_IXOTH) \ - or ((file.startswith(libdir) or file.startswith(baselibdir)) and ".so" in f): - # If it's a symlink, and points to an ELF file, we capture the readlink target - if os.path.islink(file): - continue - - # It's a file (or hardlink), not a link - # ...but is it ELF, and is it already stripped? - elf_file = isELF(file) - if elf_file & 1: - if elf_file & 2: - if 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn) or "").split(): - bb.note("Skipping file %s from %s for already-stripped QA test" % (file[len(dvar):], pn)) - else: - bb.warn("File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn)) - continue - - if s.st_ino in inodes: - os.unlink(file) - os.link(inodes[s.st_ino], file) - else: - inodes[s.st_ino] = file - # break hardlink - bb.utils.copyfile(file, file) - elffiles[file] = elf_file - - # - # Now strip them (in parallel) - # - strip = d.getVar("STRIP") - sfiles = [] - for file in elffiles: - elf_file = int(elffiles[file]) - #bb.note("Strip %s" % file) - sfiles.append((file, elf_file, strip)) - - oe.utils.multiprocess_exec(sfiles, oe.package.runstrip) + inhibit_sysroot = d.getVar('INHIBIT_SYSROOT_STRIP', True) + if inhibit_sysroot and oe.types.boolean(inhibit_sysroot): + return 0 + + dstdir = d.getVar('SYSROOT_DESTDIR', True) + pn = d.getVar('PN', True) + libdir = os.path.abspath(dstdir + os.sep + d.getVar("libdir", True)) + base_libdir = os.path.abspath(dstdir + os.sep + d.getVar("base_libdir", True)) + qa_already_stripped = 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn, True) or "").split() + strip_cmd = d.getVar("STRIP", True) + + oe.package.strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, + qa_already_stripped=qa_already_stripped) } do_populate_sysroot[dirs] = "${SYSROOT_DESTDIR}"
Signature · 1 line
2.1.4
PATCH v3 1/4 package.py: Add function strip_execs
Strip all executables in a directory.
Utility function placed in oe-package together with run_strip. strip_execs is based on strip_sysroot from staging.bbclass Moving out datastore references in favor of function parameters.
--- meta/lib/oe/package.py | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
meta/lib/oe/package.py +105 -0
@@ -45,6 +45,111 @@ def runstrip(arg): return +def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped=False): + """ + Strip executable code (like executables, shared libraries) _in_place_ + - Based on sysroot_strip in staging.bbclass + :param dstdir: directory in which to strip files + :param strip_cmd: Strip command (usually ${STRIP}) + :param libdir: ${libdir} - strip .so files in this directory + :param base_libdir: ${base_libdir} - strip .so files in this directory + :param qa_already_stripped: Set to True if already-stripped' in ${INSANE_SKIP} + This is for proper logging and messages only. + """ + import stat, errno, oe.path, oe.utils + + os.chdir(dstdir) + + # Return type (bits): + # 0 - not elf + # 1 - ELF + # 2 - stripped + # 4 - executable + # 8 - shared library + # 16 - kernel module + def isELF(path): + type = 0 + ret, result = oe.utils.getstatusoutput("file \"%s\"" % path.replace("\"", "\\\"")) + + if ret: + bb.error("split_and_strip_files: 'file %s' failed" % path) + return type + + # Not stripped + if "ELF" in result: + type |= 1 + if "not stripped" not in result: + type |= 2 + if "executable" in result: + type |= 4 + if "shared" in result: + type |= 8 + return type + + + elffiles = {} + inodes = {} + libdir = os.path.abspath(dstdir + os.sep + libdir) + base_libdir = os.path.abspath(dstdir + os.sep + base_libdir) + + # + # First lets figure out all of the files we may have to process + # + for root, dirs, files in os.walk(dstdir): + for f in files: + file = os.path.join(root, f) + + try: + ltarget = oe.path.realpath(file, dstdir, False) + s = os.lstat(ltarget) + except OSError as e: + (err, strerror) = e.args + if err != errno.ENOENT: + raise + # Skip broken symlinks + continue + if not s: + continue + # Check its an excutable + if (s[stat.ST_MODE] & stat.S_IXUSR) or (s[stat.ST_MODE] & stat.S_IXGRP) or (s[stat.ST_MODE] & stat.S_IXOTH) \ + or ((file.startswith(libdir) or file.startswith(base_libdir)) and ".so" in f): + # If it's a symlink, and points to an ELF file, we capture the readlink target + if os.path.islink(file): + continue + + # It's a file (or hardlink), not a link + # ...but is it ELF, and is it already stripped? + elf_file = isELF(file) + if elf_file & 1: + if elf_file & 2: + if qa_already_stripped: + bb.note("Skipping file %s from %s for already-stripped QA test" % (file[len(dstdir):], pn)) + else: + bb.warn("File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dstdir):], pn)) + continue + + if s.st_ino in inodes: + os.unlink(file) + os.link(inodes[s.st_ino], file) + else: + inodes[s.st_ino] = file + # break hardlink + bb.utils.copyfile(file, file) + elffiles[file] = elf_file + + # + # Now strip them (in parallel) + # + sfiles = [] + for file in elffiles: + elf_file = int(elffiles[file]) + #bb.note("Strip %s" % file) + sfiles.append((file, elf_file, strip_cmd)) + + oe.utils.multiprocess_exec(sfiles, runstrip) + + + def file_translate(file): ft = file.replace("@", "@at@") ft = ft.replace(" ", "@space@")
Signature · 1 line
2.1.4
PATCH v3 4/4 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]
--- scripts/lib/devtool/deploy.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
scripts/lib/devtool/deploy.py +28 -4
@@ -16,12 +16,16 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """Devtool plugin containing the deploy subcommands""" +import logging import os +import shutil import subprocess -import logging import tempfile -import shutil + +import bb.utils import argparse_oe +import oe + from devtool import exec_fakeroot, setup_tinfoil, check_workspace_recipe, DevtoolError logger = logging.getLogger('devtool')
@@ -140,9 +144,9 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals return '\n'.join(lines) + def deploy(args, config, basepath, workspace): """Entry point for the devtool 'deploy' subcommand""" - import re import math import oe.recipeutils
@@ -170,6 +174,17 @@ def deploy(args, config, basepath, workspace): 'recipe? If so, the install step has not installed ' 'any files.' % args.recipename) + if args.strip and not args.dry_run: + # Fakeroot copy to new destination + srcdir = recipe_outdir + recipe_outdir = os.path.join(rd.getVar('WORKDIR', True), 'deploy-target-stripped') + if os.path.isdir(recipe_outdir): + bb.utils.remove(recipe_outdir, True) + exec_fakeroot(rd, "cp -af %s %s" % (os.path.join(srcdir, '.'), recipe_outdir), shell=True) + os.environ['PATH'] = ':'.join([os.environ['PATH'], rd.getVar('PATH', True) or '']) + oe.package.strip_execs(args.recipename, recipe_outdir, rd.getVar('STRIP', True), rd.getVar('libdir', True), + rd.getVar('base_libdir', True)) + filelist = [] ftotalsize = 0 for root, _, files in os.walk(recipe_outdir):
@@ -189,7 +204,6 @@ def deploy(args, config, basepath, workspace): print(' %s' % item) return 0 - extraoptions = '' if args.no_host_check: extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
@@ -301,6 +315,7 @@ def undeploy(args, config, basepath, workspace): def register_commands(subparsers, context): """Register devtool subcommands from the deploy plugin""" + 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.',
@@ -313,6 +328,15 @@ def register_commands(subparsers, context): parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true') parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true') parser_deploy.add_argument('-P', '--port', default='22', help='Port to use for connection to the target') + + strip_opts = parser_deploy.add_mutually_exclusive_group(required=False) + strip_opts.add_argument('-S', '--strip', + help='Strip executables prior to deploying (default: %(default)s). ' + 'The default value of this option can be controlled by setting the strip option in the [Deploy] section to True or False.', + default=oe.types.boolean(context.config.get('Deploy', 'strip', default='0')), + action='store_true') + strip_opts.add_argument('--no-strip', help='Do not strip executables prior to deploy', dest='strip', action='store_false') + parser_deploy.set_defaults(func=deploy) parser_undeploy = subparsers.add_parser('undeploy-target',
Signature · 1 line
2.1.4
PATCH v3 3/4 package.py: strip_execs: Support for .ko modules
In reply to Tobias Hagelborn* Support stripping of .ko modules verifying file extension and check of content "vermagic="
* Minor refactoring (removing lint errors)
--- meta/lib/oe/package.py | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-)
meta/lib/oe/package.py +25 -19
@@ -56,9 +56,12 @@ def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped= :param qa_already_stripped: Set to True if already-stripped' in ${INSANE_SKIP} This is for proper logging and messages only. """ - import stat, errno, oe.path, oe.utils + import stat, errno, oe.path, oe.utils, mmap - os.chdir(dstdir) + # Detect .ko module by searching for "vermagic=" string + def is_kernel_module(path): + with open(path) as f: + return mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ).find(b"vermagic=") >= 0 # Return type (bits): # 0 - not elf
@@ -67,31 +70,33 @@ def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped= # 4 - executable # 8 - shared library # 16 - kernel module - def isELF(path): - type = 0 - ret, result = oe.utils.getstatusoutput("file \"%s\"" % path.replace("\"", "\\\"")) + def is_elf(path): + exec_type = 0 + ret, result = oe.utils.getstatusoutput( + "file \"%s\"" % path.replace("\"", "\\\"")) if ret: bb.error("split_and_strip_files: 'file %s' failed" % path) - return type + return exec_type # Not stripped if "ELF" in result: - type |= 1 + exec_type |= 1 if "not stripped" not in result: - type |= 2 + exec_type |= 2 if "executable" in result: - type |= 4 + exec_type |= 4 if "shared" in result: - type |= 8 - return type - + exec_type |= 8 + if "relocatable" in result and is_kernel_module(path): + exec_type |= 16 + return exec_type elffiles = {} inodes = {} - libdir = os.path.abspath(dstdir + os.sep + libdir) - base_libdir = os.path.abspath(dstdir + os.sep + base_libdir) - + libdir = os.path.abspath(os.path.join(dstdir, libdir.lstrip(os.sep))) + base_libdir = os.path.abspath(os.path.join(dstdir, base_libdir.lstrip(os.sep))) + exec_mask = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH # # First lets figure out all of the files we may have to process #
@@ -111,15 +116,16 @@ def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped= if not s: continue # Check its an excutable - if (s[stat.ST_MODE] & stat.S_IXUSR) or (s[stat.ST_MODE] & stat.S_IXGRP) or (s[stat.ST_MODE] & stat.S_IXOTH) \ - or ((file.startswith(libdir) or file.startswith(base_libdir)) and ".so" in f): + if s[stat.ST_MODE] & exec_mask \ + or ((file.startswith(libdir) or file.startswith(base_libdir)) and ".so" in f) \ + or file.endswith('.ko'): # If it's a symlink, and points to an ELF file, we capture the readlink target if os.path.islink(file): continue # It's a file (or hardlink), not a link # ...but is it ELF, and is it already stripped? - elf_file = isELF(file) + elf_file = is_elf(file) if elf_file & 1: if elf_file & 2: if qa_already_stripped:
@@ -132,6 +138,7 @@ def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped= os.unlink(file) os.link(inodes[s.st_ino], file) else: + # break hardlinks so that we do not strip the original. inodes[s.st_ino] = file # break hardlink bb.utils.copyfile(file, file)
@@ -143,7 +150,6 @@ def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped= sfiles = [] for file in elffiles: elf_file = int(elffiles[file]) - #bb.note("Strip %s" % file) sfiles.append((file, elf_file, strip_cmd)) oe.utils.multiprocess_exec(sfiles, runstrip)
Signature · 1 line
2.1.4
Re: [PATCH v3 4/4] devtool: deploy-target: Support stripped libs and execs
In reply to Tobias HagelbornQuoted 30 lines · Tobias Hagelborn
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 behaviorConfig example:
[Deploy]
strip = true[YOCTO #11227]
Signed-off-by Tobias Hagelborn <[email protected]>--- scripts/lib/devtool/deploy.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)scripts/lib/devtool/deploy.py +2
-0@@ -16,12 +16,16 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """Devtool plugin containing the deploy subcommands""" +import logging import os +import shutil
scripts/lib/devtool/deploy.py line 29
Quoted 10 lines
scripts/lib/devtool/deploy.py +4
-2import subprocess -import logging import tempfile -import shutil + +import bb.utils import argparse_oe +import oe + from devtool import exec_fakeroot, setup_tinfoil,
check_workspace_recipe, DevtoolError
scripts/lib/devtool/deploy.py def _prepare_remote_script(deploy, verbose=False,
Quoted 3 lines
scripts/lib/devtool/deploy.py +0
-0logger = logging.getLogger('devtool')@@ -140,9 +144,9 @@ def _prepare_remote_script(deploy, verbose=False,
dryrun=False, undeployall=Fals
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 174
Quoted 12 lines
scripts/lib/devtool/deploy.py +1
-1return '\n'.join(lines) + def deploy(args, config, basepath, workspace): """Entry point for the devtool 'deploy' subcommand""" - import re import math import oe.recipeutils@@ -170,6 +174,17 @@ def deploy(args, config, basepath, workspace): 'recipe? If so, the install step has not
installed '
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace):
Quoted 6 lines
scripts/lib/devtool/deploy.py +4
-0'any files.' % args.recipename) + if args.strip and not args.dry_run: + # Fakeroot copy to new destination + srcdir = recipe_outdir + recipe_outdir = os.path.join(rd.getVar('WORKDIR', True),
'deploy-target-stripped')
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace):
Quoted 3 lines
scripts/lib/devtool/deploy.py +3
-0+ if os.path.isdir(recipe_outdir): + bb.utils.remove(recipe_outdir, True) + exec_fakeroot(rd, "cp -af %s %s" % (os.path.join(srcdir,
'.'), recipe_outdir), shell=True)
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 184
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ os.environ['PATH'] = ':'.join([os.environ['PATH'],
rd.getVar('PATH', True) or ''])
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 185
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ oe.package.strip_execs(args.recipename, recipe_outdir,
rd.getVar('STRIP', True), rd.getVar('libdir', True),
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 209
Quoted 13 lines
scripts/lib/devtool/deploy.py +2
-1+ rd.getVar('base_libdir', True)) + filelist = [] ftotalsize = 0 for root, _, files in os.walk(recipe_outdir):@@ -189,7 +204,6 @@ def deploy(args, config, basepath, workspace): print(' %s' % item) return 0 - extraoptions = '' if args.no_host_check: extraoptions += '-o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no'
scripts/lib/devtool/deploy.py def undeploy(args, config, basepath, workspace): · line 320
Quoted 7 lines
scripts/lib/devtool/deploy.py +1
-0@@ -301,6 +315,7 @@ def undeploy(args, config, basepath, workspace): def register_commands(subparsers, context): """Register devtool subcommands from the deploy plugin""" + parser_deploy = subparsers.add_parser('deploy-target', help='Deploy recipe output
files to live target machine',
scripts/lib/devtool/deploy.py def undeploy(args, config, basepath, workspace): · line 321
Quoted 1 line
scripts/lib/devtool/deploy.py +0
-0description='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.',
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 328
Quoted 2 lines
scripts/lib/devtool/deploy.py +0
-0@@ -313,6 +328,15 @@ def register_commands(subparsers, context): parser_deploy.add_argument('-p', '--no-preserve', help='Do not
preserve existing files', action='store_true')
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 329
Quoted 1 line
scripts/lib/devtool/deploy.py +0
-0parser_deploy.add_argument('--no-check-space', help='Do not check
for available space before deploying', action='store_true')
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 330
Quoted 1 line
scripts/lib/devtool/deploy.py +0
-0parser_deploy.add_argument('-P', '--port', default='22', help='Port
to use for connection to the target')
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 332
Quoted 2 lines
scripts/lib/devtool/deploy.py +2
-0+ + strip_opts =
parser_deploy.add_mutually_exclusive_group(required=False)
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 334
Quoted 2 lines
scripts/lib/devtool/deploy.py +2
-0+ strip_opts.add_argument('-S', '--strip', + help='Strip executables prior to
deploying (default: %(default)s). '
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 335
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ 'The default value of this option
can be controlled by setting the strip option in the [Deploy] section to True or False.',
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 336
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+
default=oe.types.boolean(context.config.get('Deploy', 'strip', default='0')),
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 337
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ action='store_true')
Autobuilder is complaining about this:
Exception: bb.process.ExecutionError: Execution of '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'
failed with exit code 1:
Traceback (most recent call last):
File
"/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/devtool",
line 351, in <module>
ret = main()
File
"/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/devtool",
line 329, in main
plugin.register_commands(subparsers, context)
File
"/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/lib/devtool/deploy.py",
line 336, in register_commands
default=oe.types.boolean(context.config.get('Deploy', 'strip',
default='0')),
AttributeError: module 'oe' has no attribute 'types'
See
https://autobuilder.yocto.io/builders/nightly-x86-64/builds/333/steps/BuildImages_2/logs/stdio
for context.
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 338
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ strip_opts.add_argument('--no-strip', help='Do not strip executables
prior to deploy', dest='strip', action='store_false')
Quoted 12 lines
scripts/lib/devtool/deploy.py +1
-1+ parser_deploy.set_defaults(func=deploy) parser_undeploy = subparsers.add_parser('undeploy-target', --2.1.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH v3 4/4] devtool: deploy-target: Support stripped libs and execs
Quoted 151 lines · Jussi Kukkonen
Quoted 8 lines · On 20 June 2017 at 10:42, Tobias Hagelborn <[email protected]…
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 behaviorQuoted 7 lines
Config example:
[Deploy]
strip = true[YOCTO #11227]
Signed-off-by Tobias Hagelborn <[email protected]<mailto:[email protected]>>
Review
Quoted 5 lines
--- scripts/lib/devtool/deploy.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/scripts/lib/devtool/deploy.pyQuoted 10 lines
index 04c34cb..96b877e 100644
scripts/lib/devtool/deploy.py +2
-0@@ -16,12 +16,16 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """Devtool plugin containing the deploy subcommands""" +import logging import os +import shutilscripts/lib/devtool/deploy.py line 29
Quoted 10 lines
scripts/lib/devtool/deploy.py +4
-2import subprocess -import logging import tempfile -import shutil + +import bb.utils import argparse_oe +import oe + from devtool import exec_fakeroot, setup_tinfoil,
check_workspace_recipe, DevtoolErrorscripts/lib/devtool/deploy.py def _prepare_remote_script(deploy, verbose=False,
Quoted 3 lines
scripts/lib/devtool/deploy.py +0
-0logger = logging.getLogger('devtool')@@ -140,9 +144,9 @@ def _prepare_remote_script(deploy, verbose=False,dryrun=False, undeployall=Fals
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 174
Quoted 12 lines
scripts/lib/devtool/deploy.py +1
-1return '\n'.join(lines) + def deploy(args, config, basepath, workspace): """Entry point for the devtool 'deploy' subcommand""" - import re import math import oe.recipeutils@@ -170,6 +174,17 @@ def deploy(args, config, basepath, workspace): 'recipe? If so, the install step has notinstalled '
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace):
Quoted 6 lines
scripts/lib/devtool/deploy.py +4
-0'any files.' % args.recipename) + if args.strip and not args.dry_run: + # Fakeroot copy to new destination + srcdir = recipe_outdir + recipe_outdir = os.path.join(rd.getVar('WORKDIR', True),'deploy-target-stripped')
scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace):
Quoted 3 lines
scripts/lib/devtool/deploy.py +3
-0+ if os.path.isdir(recipe_outdir): + bb.utils.remove(recipe_outdir, True) + exec_fakeroot(rd, "cp -af %s %s" % (os.path.join(srcdir,'.'),
recipe_outdir), shell=True)scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 184
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ os.environ['PATH'] = ':'.join([os.environ['PATH'],
rd.getVar('PATH', True)or ''])scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 185
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ oe.package.strip_execs(args.recipename, recipe_outdir,
rd.getVar('STRIP', True),rd.getVar('libdir', True),scripts/lib/devtool/deploy.py def deploy(args, config, basepath, workspace): · line 209
Quoted 13 lines
scripts/lib/devtool/deploy.py +2
-1+ rd.getVar('base_libdir', True)) + filelist = [] ftotalsize = 0 for root, _, files in os.walk(recipe_outdir):@@ -189,7 +204,6 @@ def deploy(args, config, basepath, workspace): print(' %s' % item) return 0 - extraoptions = '' if args.no_host_check: extraoptions += '-o UserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no'
scripts/lib/devtool/deploy.py def undeploy(args, config, basepath, workspace): · line 320
Quoted 7 lines
scripts/lib/devtool/deploy.py +1
-0@@ -301,6 +315,7 @@ def undeploy(args, config, basepath, workspace): def register_commands(subparsers, context): """Register devtool subcommands from the deploy plugin""" + parser_deploy = subparsers.add_parser('deploy-target', help='Deploy recipe outputfiles to live target machine',
scripts/lib/devtool/deploy.py def undeploy(args, config, basepath, workspace): · line 321
Quoted 1 line
scripts/lib/devtool/deploy.py +0
-0description='Deploys arecipe\'s build output (i.e. the output of the
do_installtask) 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.',scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 328
Quoted 2 lines
scripts/lib/devtool/deploy.py +0
-0@@ -313,6 +328,15 @@ def register_commands(subparsers, context): parser_deploy.add_argument('-p', '--no-preserve', help='Do notpreserve existing files', action='store_true')
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 329
Quoted 1 line
scripts/lib/devtool/deploy.py +0
-0parser_deploy.add_argument('--no-check-space', help='Do notcheck for available space before deploying', action='store_true')
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 330
Quoted 1 line
scripts/lib/devtool/deploy.py +0
-0parser_deploy.add_argument('-P', '--port', default='22',help='Port to use for connection to the target')
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 332
Quoted 2 lines
scripts/lib/devtool/deploy.py +2
-0+ + strip_opts =
parser_deploy.add_mutually_exclusive_group(required=False)scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 334
Quoted 2 lines
scripts/lib/devtool/deploy.py +2
-0+ strip_opts.add_argument('-S', '--strip', + help='Strip executables prior todeploying (default: %(default)s). '
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 335
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ 'The default value of thisoption can be controlled by setting the strip option in the [Deploy] section to True or False.',
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 336
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+default=oe.types.boolean(context.config.get('Deploy', 'strip', default='0')),
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 337
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ action='store_true')Autobuilder is complaining about this:
Exception: bb.process.ExecutionError: Execution of '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.3create-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' failed with exit code 1:
Traceback (most recent call last):
File
"/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/devtool", line 351, in <module>
ret =main()
File
"/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/devtool", line 329, in main
plugin.register_commands(subparsers, context)
File
"/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/scripts/lib/devtool/deploy.py", line 336, inregister_commands
default=oe.types.boolean(context.config.get('Deploy', 'strip',
default='0')),
AttributeError: module 'oe' has no attribute 'types'See https://autobuilder.yocto.io/builders/nightly-x86-64/builds/333/steps/BuildImages_2/logs/stdio for context.
scripts/lib/devtool/deploy.py def register_commands(subparsers, context): · line 338
Quoted 1 line
scripts/lib/devtool/deploy.py +1
-0+ strip_opts.add_argument('--no-strip', help='Do not stripexecutables prior to deploy', dest='strip', action='store_false')
Quoted 7 lines
scripts/lib/devtool/deploy.py +1
-1+ parser_deploy.set_defaults(func=deploy) parser_undeploy = subparsers.add_parser('undeploy-target', --2.1.4
Quoted 6 lines
Quoted 4 lines
--
_______________________________________________
Openembedded-core mailing list
[email protected]<mailto:[email protected]>
Thanks for pointing this out Jussi,
I will send an updated version.
Cheers
Tobias