diff options
author | John Bowler <jbowler@nslu2-linux.org> | 2006-01-31 17:36:37 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2006-01-31 17:36:37 +0000 |
commit | d4c62f2653b3c21c361dc3cf7ec748048e9cad16 (patch) | |
tree | ee724dac9af95a5181bff46deafaabe94ef5be0f /classes/package.bbclass | |
parent | 0181fca36610a03b991be5985aa53f794e9ce323 (diff) |
package.bbclass: implement a failsafe strip in classes
- package.bbclass now uses file-native and cross strip to reliably strip
unstripped executables and check the return code. For the moment a
failure here doesn't cause the build to fail but does output a failure
message direct to the controlling terminal (this is temporary). This
behaviour can be changed by forcing IGNORE_STRIP_ERRORS = ""
The change works by using a new runstrip shell function for every
potentially strippable file. Since this calls native 'file' there is
a dependency on all inheritors of package.bbclass for file-native and
since this would break native builds (because of the cycle in
file-native and it's own native depends) native.bbclass cancels this
dependency (system file should be fine for native packages and, anyway
native currently doesn't package.)
Diffstat (limited to 'classes/package.bbclass')
-rw-r--r-- | classes/package.bbclass | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/classes/package.bbclass b/classes/package.bbclass index 8375e61959..81ab094ef1 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -81,6 +81,53 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst bb.data.setVar('PACKAGES', ' '.join(packages), d) +# Function to strip a single file, called from RUNSTRIP below +# A working 'file' (one which works on the target architecture) +# is necessary for this stuff to work. +PACKAGE_DEPENDS ?= "file-native" +DEPENDS_prepend =+ "${PACKAGE_DEPENDS} " +#FIXME: this should be "" when any errors are gone! +IGNORE_STRIP_ERRORS ?= "1" + +runstrip() { + local ro st + st=0 + if { file "$1" || { + oewarn "file $1: failed (forced strip)" >&2 + echo 'not stripped' + } + } | grep -q 'not stripped' + then + oenote "${STRIP} $1" + ro= + test -w "$1" || { + ro=1 + chmod +w "$1" + } + '${STRIP}' "$1" + st=$? + test -n "$ro" && chmod -w "$1" + if test $st -ne 0 + then + oewarn "runstrip: ${STRIP} $1: strip failed" >&2 + if test -n '${IGNORE_STRIP_ERRORS}' + then + #FIXME: remove this, it's for error detection + if file "$1" 2>/dev/null >&2 + then + (oefatal "${STRIP} $1: command failed" >/dev/tty) + else + (oefatal "file $1: command failed" >/dev/tty) + fi + st=0 + fi + fi + else + oenote "runstrip: skip $1" + fi + return $st +} + python populate_packages () { import glob, stat, errno, re @@ -166,19 +213,14 @@ python populate_packages () { dpath = os.path.dirname(fpath) bb.mkdirhier(dpath) if (bb.data.getVar('INHIBIT_PACKAGE_STRIP', d, 1) != '1') and not os.path.islink(file) and isexec(file): - if bb.data.getVar('IGNORE_STRIP_ERRORS', d, 1) != '1': - # bail out on errors - stripfunc += "if (file %s | grep -q 'not stripped'); then echo 'Trying to strip: %s'; if ${STRIP} %s 2>&1 | grep strip; then return 1; fi; fi;\n" % (fpath, fpath, fpath) - else: - # old behaviour: ignore errors - stripfunc += "${STRIP} %s || : ;\n" % fpath + stripfunc += "\trunstrip %s || st=1\n" % fpath ret = bb.movefile(file,fpath) if ret is None or ret == 0: raise bb.build.FuncFailed("File population failed") if not stripfunc == "": from bb import build # strip - bb.data.setVar('RUNSTRIP', '%s\nreturn 0' % stripfunc, localdata) + bb.data.setVar('RUNSTRIP', '\tlocal st\n\tst=0\n%s\treturn $st' % stripfunc, localdata) bb.data.setVarFlag('RUNSTRIP', 'func', 1, localdata) bb.build.exec_func('RUNSTRIP', localdata) del localdata |