summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hagelborn <tobias.hagelborn@axis.com>2017-06-20 09:42:43 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-28 20:55:08 +0100
commit73c590ea9ea85bcdbf0b8e6acbc6169dc5e1f749 (patch)
tree35af0465c9c57ad4f41a6a9e82836293f237543a
parent0e23081d701f57ad1f294b0e0e35c514415a339a (diff)
downloadpoky-73c590ea9ea85bcdbf0b8e6acbc6169dc5e1f749.tar.gz
staging.bbclass: Make use of oe.package.strip_execs
Make 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. (From OE-Core rev: fc4e6a30c51f8b15b667c21aaa6de9ba45217c1e) Signed-off-by: Tobias Hagelborn <tobiasha@axis.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/staging.bbclass108
1 files changed, 13 insertions, 95 deletions
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index 1bb22aaa46..fe8229499a 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -68,101 +68,19 @@ sysroot_stage_all() {
68} 68}
69 69
70python sysroot_strip () { 70python sysroot_strip () {
71 import stat, errno 71 inhibit_sysroot = d.getVar('INHIBIT_SYSROOT_STRIP', True)
72 72 if inhibit_sysroot and oe.types.boolean(inhibit_sysroot):
73 dvar = d.getVar('SYSROOT_DESTDIR') 73 return 0
74 pn = d.getVar('PN') 74
75 75 dstdir = d.getVar('SYSROOT_DESTDIR', True)
76 os.chdir(dvar) 76 pn = d.getVar('PN', True)
77 77 libdir = os.path.abspath(dstdir + os.sep + d.getVar("libdir", True))
78 # Return type (bits): 78 base_libdir = os.path.abspath(dstdir + os.sep + d.getVar("base_libdir", True))
79 # 0 - not elf 79 qa_already_stripped = 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn, True) or "").split()
80 # 1 - ELF 80 strip_cmd = d.getVar("STRIP", True)
81 # 2 - stripped 81
82 # 4 - executable 82 oe.package.strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir,
83 # 8 - shared library 83 qa_already_stripped=qa_already_stripped)
84 # 16 - kernel module
85 def isELF(path):
86 type = 0
87 ret, result = oe.utils.getstatusoutput("file \"%s\"" % path.replace("\"", "\\\""))
88
89 if ret:
90 bb.error("sysroot_strip: 'file %s' failed" % path)
91 return type
92
93 # Not stripped
94 if "ELF" in result:
95 type |= 1
96 if "not stripped" not in result:
97 type |= 2
98 if "executable" in result:
99 type |= 4
100 if "shared" in result:
101 type |= 8
102 return type
103
104
105 elffiles = {}
106 inodes = {}
107 libdir = os.path.abspath(dvar + os.sep + d.getVar("libdir"))
108 baselibdir = os.path.abspath(dvar + os.sep + d.getVar("base_libdir"))
109 if (d.getVar('INHIBIT_SYSROOT_STRIP') != '1'):
110 #
111 # First lets figure out all of the files we may have to process
112 #
113 for root, dirs, files in os.walk(dvar):
114 for f in files:
115 file = os.path.join(root, f)
116
117 try:
118 ltarget = oe.path.realpath(file, dvar, False)
119 s = os.lstat(ltarget)
120 except OSError as e:
121 (err, strerror) = e.args
122 if err != errno.ENOENT:
123 raise
124 # Skip broken symlinks
125 continue
126 if not s:
127 continue
128 # Check its an excutable
129 if (s[stat.ST_MODE] & stat.S_IXUSR) or (s[stat.ST_MODE] & stat.S_IXGRP) or (s[stat.ST_MODE] & stat.S_IXOTH) \
130 or ((file.startswith(libdir) or file.startswith(baselibdir)) and ".so" in f):
131 # If it's a symlink, and points to an ELF file, we capture the readlink target
132 if os.path.islink(file):
133 continue
134
135 # It's a file (or hardlink), not a link
136 # ...but is it ELF, and is it already stripped?
137 elf_file = isELF(file)
138 if elf_file & 1:
139 if elf_file & 2:
140 if 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn) or "").split():
141 bb.note("Skipping file %s from %s for already-stripped QA test" % (file[len(dvar):], pn))
142 else:
143 bb.warn("File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn))
144 continue
145
146 if s.st_ino in inodes:
147 os.unlink(file)
148 os.link(inodes[s.st_ino], file)
149 else:
150 inodes[s.st_ino] = file
151 # break hardlink
152 bb.utils.copyfile(file, file)
153 elffiles[file] = elf_file
154
155 #
156 # Now strip them (in parallel)
157 #
158 strip = d.getVar("STRIP")
159 sfiles = []
160 for file in elffiles:
161 elf_file = int(elffiles[file])
162 #bb.note("Strip %s" % file)
163 sfiles.append((file, elf_file, strip))
164
165 oe.utils.multiprocess_exec(sfiles, oe.package.runstrip)
166} 84}
167 85
168do_populate_sysroot[dirs] = "${SYSROOT_DESTDIR}" 86do_populate_sysroot[dirs] = "${SYSROOT_DESTDIR}"