Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | NATIVELSBSTRING = "universal" |
| 2 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame^] | 3 | UNINATIVE_LOADER ?= "${@bb.utils.contains('BUILD_ARCH', 'x86_64', '${STAGING_DIR_NATIVE}/lib/ld-linux-x86-64.so.2', '${STAGING_DIR_NATIVE}/lib/ld-linux.so.2', d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | |
| 5 | addhandler uninative_eventhandler |
| 6 | uninative_eventhandler[eventmask] = "bb.event.BuildStarted" |
| 7 | |
| 8 | python uninative_eventhandler() { |
| 9 | loader = e.data.getVar("UNINATIVE_LOADER", True) |
| 10 | if not os.path.exists(loader): |
| 11 | import subprocess |
| 12 | cmd = e.data.expand("mkdir -p ${STAGING_DIR}; cd ${STAGING_DIR}; tar -xjf ${COREBASE}/${BUILD_ARCH}-nativesdk-libc.tar.bz2; ${STAGING_DIR}/relocate_sdk.py ${STAGING_DIR_NATIVE} ${UNINATIVE_LOADER} ${UNINATIVE_LOADER} ${STAGING_BINDIR_NATIVE}/patchelf-uninative") |
| 13 | #bb.warn("nativesdk lib extraction: " + cmd) |
| 14 | subprocess.check_call(cmd, shell=True) |
| 15 | } |
| 16 | |
| 17 | SSTATEPOSTUNPACKFUNCS_append = " uninative_changeinterp" |
| 18 | |
| 19 | python uninative_changeinterp () { |
| 20 | import subprocess |
| 21 | import stat |
| 22 | import oe.qa |
| 23 | |
| 24 | if not (bb.data.inherits_class('native', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('cross', d)): |
| 25 | return |
| 26 | |
| 27 | sstateinst = d.getVar('SSTATE_INSTDIR', True) |
| 28 | for walkroot, dirs, files in os.walk(sstateinst): |
| 29 | for file in files: |
| 30 | f = os.path.join(walkroot, file) |
| 31 | if os.path.islink(f): |
| 32 | continue |
| 33 | s = os.stat(f) |
| 34 | if not ((s[stat.ST_MODE] & stat.S_IXUSR) or (s[stat.ST_MODE] & stat.S_IXGRP) or (s[stat.ST_MODE] & stat.S_IXOTH)): |
| 35 | continue |
| 36 | elf = oe.qa.ELFFile(f) |
| 37 | try: |
| 38 | elf.open() |
| 39 | except: |
| 40 | continue |
| 41 | |
| 42 | #bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f)) |
| 43 | subprocess.call("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f), shell=True) |
| 44 | } |