1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
NATIVELSBSTRING = "universal"
UNINATIVE_LOADER ?= "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux/lib/${@bb.utils.contains('BUILD_ARCH', 'x86_64', 'ld-linux-x86-64.so.2', 'ld-linux.so.2', d)}"
UNINATIVE_URL ?= "unset"
UNINATIVE_TARBALL ?= "${BUILD_ARCH}-nativesdk-libc.tar.bz2"
# Example checksums
#UNINATIVE_CHECKSUM[i586] = "dead"
#UNINATIVE_CHECKSUM[x86_64] = "dead"
UNINATIVE_DLDIR ?= "${COREBASE}"
addhandler uninative_eventhandler
uninative_eventhandler[eventmask] = "bb.event.BuildStarted"
python uninative_eventhandler() {
loader = e.data.getVar("UNINATIVE_LOADER", True)
tarball = d.getVar("UNINATIVE_TARBALL", True)
tarballdir = d.getVar("UNINATIVE_DLDIR", True)
tarballpath = os.path.join(tarballdir, tarball)
if not os.path.exists(loader):
import subprocess
olddir = os.getcwd()
if not os.path.exists(tarballpath):
# Copy the data object and override DL_DIR and SRC_URI
localdata = bb.data.createCopy(d)
if d.getVar("UNINATIVE_URL", True) == "unset":
bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL")
chksum = d.getVarFlag("UNINATIVE_CHECKSUM", d.getVar("BUILD_ARCH", True), True)
if not chksum:
bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True))
srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
localdata.setVar('FILESPATH', tarballdir)
localdata.setVar('DL_DIR', tarballdir)
bb.note("Fetching uninative binary shim from %s" % srcuri)
fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
try:
fetcher.download()
localpath = fetcher.localpath(srcuri)
if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath):
os.symlink(localpath, tarballpath)
except Exception as exc:
bb.fatal("Unable to download uninative tarball: %s" % str(exc))
cmd = e.data.expand("mkdir -p ${STAGING_DIR}-uninative; cd ${STAGING_DIR}-uninative; tar -xjf ${UNINATIVE_DLDIR}/${UNINATIVE_TARBALL}; ${STAGING_DIR}-uninative/relocate_sdk.py ${STAGING_DIR}-uninative/${BUILD_ARCH}-linux ${UNINATIVE_LOADER} ${UNINATIVE_LOADER} ${STAGING_DIR}-uninative/${BUILD_ARCH}-linux/${bindir_native}/patchelf-uninative")
try:
subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError as exc:
bb.fatal("Unable to install uninative tarball: %s" % str(exc))
os.chdir(olddir)
}
SSTATEPOSTUNPACKFUNCS_append = " uninative_changeinterp"
PATH_prepend = "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:"
python uninative_changeinterp () {
import subprocess
import stat
import oe.qa
if not (bb.data.inherits_class('native', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('cross', d)):
return
sstateinst = d.getVar('SSTATE_INSTDIR', True)
for walkroot, dirs, files in os.walk(sstateinst):
for file in files:
f = os.path.join(walkroot, file)
if os.path.islink(f):
continue
s = os.stat(f)
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)):
continue
elf = oe.qa.ELFFile(f)
try:
elf.open()
except:
continue
#bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f))
subprocess.call("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f), shell=True)
}
|