[OE-core] [PATCH] package.py: Add STRIP_OPTS variable

Changhee Han gyulkkajo at gmail.com
Fri Dec 8 04:54:00 UTC 2017


STRIP_OPTS variable is added to put extra options for strip command during
do_package. This helps to discard symbols or sections selectively.

For example, it can be used like below:

STRIP_OPTS_pn-somepackage = "--strip-debug --keep-file-symbols"

It preserves a symbol table on a binary. This is useful especialy for
an embedded system which has limited resources because a size of *-dbg
package is too huge to be installed to the target. Instead of it,
preserving the symbol table is lightweight and enough to track where a
problem comes from.

Signed-off-by: Changhee Han <gyulkkajo at gmail.com>
---
 meta/classes/package.bbclass | 6 ++++--
 meta/classes/staging.bbclass | 3 ++-
 meta/conf/documentation.conf | 1 +
 meta/lib/oe/package.py       | 8 +++++---
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 2053d46..1933e93 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1066,12 +1066,14 @@ python split_and_strip_files () {
     if (d.getVar('INHIBIT_PACKAGE_STRIP') != '1'):
         strip = d.getVar("STRIP")
         sfiles = []
+        opts = d.getVar("STRIP_OPTS") or ''
+
         for file in elffiles:
             elf_file = int(elffiles[file])
             #bb.note("Strip %s" % file)
-            sfiles.append((file, elf_file, strip))
+            sfiles.append((file, elf_file, strip, opts))
         for f in kernmods:
-            sfiles.append((f, 16, strip))
+            sfiles.append((f, 16, strip, opts))
 
         oe.utils.multiprocess_exec(sfiles, oe.package.runstrip)
 
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index c479bd9..51be462 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -78,8 +78,9 @@ python sysroot_strip () {
     base_libdir = os.path.abspath(dstdir + os.sep + d.getVar("base_libdir"))
     qa_already_stripped = 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn) or "").split()
     strip_cmd = d.getVar("STRIP")
+    strip_opts = d.getVar("STRIP_OPTS") or ''
 
-    oe.package.strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir,
+    oe.package.strip_execs(pn, dstdir, strip_cmd, strip_opts, libdir, base_libdir,
                            qa_already_stripped=qa_already_stripped)
 }
 
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index a55e283..802bad4 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -392,6 +392,7 @@ SSTATE_MIRRORS[doc] = "Configures the OpenEmbedded build system to search other
 STAGING_KERNEL_DIR[doc] = "The directory with kernel headers that are required to build out-of-tree modules."
 STAMP[doc] = "Specifies the base path used to create recipe stamp files. The path to an actual stamp file is constructed by evaluating this string and then appending additional information."
 STAMPS_DIR[doc] = "Specifies the base directory in which the OpenEmbedded build system places stamps."
+STRIP_OPTS[doc] = "Additional options to add strip command during do_package."
 SUMMARY[doc] = "The short (80 characters or less) summary of the binary package for packaging systems such as opkg, rpm or dpkg. By default, SUMMARY is used to define the DESCRIPTION variable if DESCRIPTION is not set in the recipe."
 SVNDIR[doc] = "The directory where Subversion checkouts will be stored."
 SYSLINUX_DEFAULT_CONSOLE[doc] = "Specifies the kernel boot default console."
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 1e5c3aa..84bd8ba 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -10,7 +10,7 @@ def runstrip(arg):
 
     import stat, subprocess
 
-    (file, elftype, strip) = arg
+    (file, elftype, strip, opts) = arg
 
     newmode = None
     if not os.access(file, os.W_OK) or os.access(file, os.R_OK):
@@ -31,6 +31,7 @@ def runstrip(arg):
     elif elftype & 8 or elftype & 4:
         stripcmd.extend(["--remove-section=.comment", "--remove-section=.note"])
 
+    stripcmd.extend(opts.split())
     stripcmd.append(file)
     bb.debug(1, "runstrip: %s" % stripcmd)
 
@@ -45,12 +46,13 @@ def runstrip(arg):
     return
 
 
-def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped=False):
+def strip_execs(pn, dstdir, strip_cmd, strip_opts, 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 strip_opts: Strip options
     :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}
@@ -148,7 +150,7 @@ def strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, qa_already_stripped=
     sfiles = []
     for file in elffiles:
         elf_file = int(elffiles[file])
-        sfiles.append((file, elf_file, strip_cmd))
+        sfiles.append((file, elf_file, strip_cmd, strip_opts))
 
     oe.utils.multiprocess_exec(sfiles, runstrip)
 
-- 
2.1.4




More information about the Openembedded-core mailing list