summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-20 08:45:28 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-24 11:52:07 +0100
commit7ad0c0d6ab12bebeac097fc0f5210c876dcfe9be (patch)
treee3f6cbdc2308f9c8a29b268d195e06ba4545cea1 /meta/classes/package.bbclass
parentb5788fb1f795f2f35d1788d8311e12984ffb2122 (diff)
downloadopenembedded-core-contrib-7ad0c0d6ab12bebeac097fc0f5210c876dcfe9be.tar.gz
package: Refactor to remove isElf/is_elf function duplication
There are probably further cleanups needed here but this at least removes the major code duplication between these two similar funcitons, keeping the kernel module ".ko" extension check for efficiency to avoid opening and reading file contents in the general case. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass40
1 files changed, 4 insertions, 36 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 94e4639a11..f121acccab 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -936,38 +936,6 @@ python split_and_strip_files () {
sourcefile = d.expand("${WORKDIR}/debugsources.list")
bb.utils.remove(sourcefile)
- # Return type (bits):
- # 0 - not elf
- # 1 - ELF
- # 2 - stripped
- # 4 - executable
- # 8 - shared library
- # 16 - kernel module
- def isELF(path):
- type = 0
- result = subprocess.check_output(["file", "-b", path], stderr=subprocess.STDOUT).decode("utf-8")
-
- # 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
-
- def isStaticLib(path):
- if path.endswith('.a') and not os.path.islink(path):
- with open(path, 'rb') as fh:
- # The magic must include the first slash to avoid
- # matching golang static libraries
- magic = b'!<arch>\x0a/'
- start = fh.read(len(magic))
- return start == magic
- return False
-
#
# First lets figure out all of the files we may have to process ... do this only once!
#
@@ -987,7 +955,7 @@ python split_and_strip_files () {
if file.endswith(".ko") and file.find("/lib/modules/") != -1:
kernmods.append(file)
continue
- if isStaticLib(file):
+ if oe.package.is_static_lib(file):
staticlibs.append(file)
continue
@@ -1017,14 +985,14 @@ python split_and_strip_files () {
# If it's a symlink, and points to an ELF file, we capture the readlink target
if cpath.islink(file):
target = os.readlink(file)
- if isELF(ltarget):
- #bb.note("Sym: %s (%d)" % (ltarget, isELF(ltarget)))
+ if oe.package.is_elf(ltarget):
+ #bb.note("Sym: %s (%d)" % (ltarget, oe.package.is_elf(ltarget)))
symlinks[file] = target
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 = oe.package.is_elf(file)
if elf_file & 1:
if elf_file & 2:
if 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn) or "").split():