summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-02-22 21:06:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-28 11:32:59 +0000
commit55ae56687a39287328ee8b8bd5496f164f617c6b (patch)
tree189a00c183ba7d7737ce35b8ebb340e19290f806
parent50b8740fba8dba11e9f5256c08ebdb869cd57911 (diff)
downloadpoky-55ae56687a39287328ee8b8bd5496f164f617c6b.tar.gz
uninative.bbclass: if the loader can't be found disable instead of failing
(From OE-Core rev: 99ae0859ba5fa83c9cfd75a814f8281624e8987e) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/uninative.bbclass64
1 files changed, 38 insertions, 26 deletions
diff --git a/meta/classes/uninative.bbclass b/meta/classes/uninative.bbclass
index 270c1b0be4..9a5717020c 100644
--- a/meta/classes/uninative.bbclass
+++ b/meta/classes/uninative.bbclass
@@ -1,5 +1,3 @@
1NATIVELSBSTRING = "universal"
2
3UNINATIVE_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)}" 1UNINATIVE_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)}"
4 2
5UNINATIVE_URL ?= "unset" 3UNINATIVE_URL ?= "unset"
@@ -13,19 +11,16 @@ addhandler uninative_eventhandler
13uninative_eventhandler[eventmask] = "bb.event.BuildStarted" 11uninative_eventhandler[eventmask] = "bb.event.BuildStarted"
14 12
15python uninative_eventhandler() { 13python uninative_eventhandler() {
16 loader = e.data.getVar("UNINATIVE_LOADER", True) 14 enabled = True
15
16 loader = d.getVar("UNINATIVE_LOADER", True)
17 tarball = d.getVar("UNINATIVE_TARBALL", True) 17 tarball = d.getVar("UNINATIVE_TARBALL", True)
18 tarballdir = d.getVar("UNINATIVE_DLDIR", True) 18 tarballdir = d.getVar("UNINATIVE_DLDIR", True)
19 tarballpath = os.path.join(tarballdir, tarball) 19 tarballpath = os.path.join(tarballdir, tarball)
20 20
21 if not os.path.exists(loader): 21 if not os.path.exists(loader):
22 import subprocess 22 # If the tarball doesn't exist, try to fetch it.
23
24 olddir = os.getcwd()
25 if not os.path.exists(tarballpath): 23 if not os.path.exists(tarballpath):
26 # Copy the data object and override DL_DIR and SRC_URI
27 localdata = bb.data.createCopy(d)
28
29 if d.getVar("UNINATIVE_URL", True) == "unset": 24 if d.getVar("UNINATIVE_URL", True) == "unset":
30 bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL") 25 bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL")
31 26
@@ -33,31 +28,48 @@ python uninative_eventhandler() {
33 if not chksum: 28 if not chksum:
34 bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True)) 29 bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True))
35 30
36 srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
37 localdata.setVar('FILESPATH', tarballdir)
38 localdata.setVar('DL_DIR', tarballdir)
39 bb.note("Fetching uninative binary shim from %s" % srcuri)
40 fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
41 try: 31 try:
32 # Save and restore cwd as Fetch.download() does a chdir()
33 olddir = os.getcwd()
34
35 localdata = bb.data.createCopy(d)
36 localdata.setVar('FILESPATH', "")
37 localdata.setVar('DL_DIR', tarballdir)
38
39 srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
40 bb.note("Fetching uninative binary shim from %s" % srcuri)
41
42 fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
42 fetcher.download() 43 fetcher.download()
43 localpath = fetcher.localpath(srcuri) 44 localpath = fetcher.localpath(srcuri)
44 if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath): 45 if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath):
45 os.symlink(localpath, tarballpath) 46 os.symlink(localpath, tarballpath)
46 except Exception as exc: 47 except Exception as exc:
47 bb.fatal("Unable to download uninative tarball: %s" % str(exc)) 48 bb.warn("Unable to download uninative tarball: %s" % str(exc))
48 49 enabled = False
49 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") 50 finally:
50 try: 51 os.chdir(olddir)
51 subprocess.check_call(cmd, shell=True) 52
52 except subprocess.CalledProcessError as exc: 53 # If we're still enabled then the fetch didn't fail, so unpack the tarball
53 bb.fatal("Unable to install uninative tarball: %s" % str(exc)) 54 if enabled:
54 os.chdir(olddir) 55 import subprocess
56 try:
57 cmd = d.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")
58 subprocess.check_call(cmd, shell=True)
59 except subprocess.CalledProcessError as exc:
60 bb.warn("Unable to install uninative tarball: %s" % str(exc))
61 enabled = False
62
63 if enabled:
64 bb.debug(2, "Enabling uninative")
65 d.setVar("NATIVELSBSTRING", "universal")
66 d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp")
67 d.prependVar("PATH", "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:")
68 else:
69 bb.warn("Uninative selected but the loader isn't present and can't be downloaded. Disabling uninative.\n"
70 "To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.")
55} 71}
56 72
57SSTATEPOSTUNPACKFUNCS_append = " uninative_changeinterp"
58
59PATH_prepend = "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:"
60
61python uninative_changeinterp () { 73python uninative_changeinterp () {
62 import subprocess 74 import subprocess
63 import stat 75 import stat