summaryrefslogtreecommitdiffstats
path: root/meta/classes/uninative.bbclass
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-03-04 16:48:37 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-07 12:41:38 +0000
commit013dd24bce6c6f95167b275d3aee8e161d7e6718 (patch)
tree1d5ad3a0767c796cdb4b61a4c03d6f14f8543320 /meta/classes/uninative.bbclass
parent034618dbee7e6bc60a746f9d64188763faa31c37 (diff)
downloadpoky-013dd24bce6c6f95167b275d3aee8e161d7e6718.tar.gz
uninative: correctly enable uninative
The previous attempt at soft-failing when uninative was enabled didn't actually work, because the workers didn't evaluate the function that actually enabled uninative. In a BuildStarted handler we can check if we need to download or extract the uninative tarball. In a ConfigParsed handler on the workers we can check if the uninative loader is present, and if so enable it. (From OE-Core rev: 75fc9a8d408640d97481d310084b212a01dc5f8b) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/uninative.bbclass')
-rw-r--r--meta/classes/uninative.bbclass95
1 files changed, 55 insertions, 40 deletions
diff --git a/meta/classes/uninative.bbclass b/meta/classes/uninative.bbclass
index 9a5717020c..8902518a1d 100644
--- a/meta/classes/uninative.bbclass
+++ b/meta/classes/uninative.bbclass
@@ -7,19 +7,30 @@ UNINATIVE_TARBALL ?= "${BUILD_ARCH}-nativesdk-libc.tar.bz2"
7#UNINATIVE_CHECKSUM[x86_64] = "dead" 7#UNINATIVE_CHECKSUM[x86_64] = "dead"
8UNINATIVE_DLDIR ?= "${COREBASE}" 8UNINATIVE_DLDIR ?= "${COREBASE}"
9 9
10addhandler uninative_eventhandler 10addhandler uninative_event_fetchloader
11uninative_eventhandler[eventmask] = "bb.event.BuildStarted" 11uninative_event_fetchloader[eventmask] = "bb.event.BuildStarted"
12 12
13python uninative_eventhandler() { 13addhandler uninative_event_enable
14 enabled = True 14uninative_event_enable[eventmask] = "bb.event.ConfigParsed"
15
16python uninative_event_fetchloader() {
17 """
18 This event fires on the parent and will try to fetch the tarball if the
19 loader isn't already present.
20 """
15 21
16 loader = d.getVar("UNINATIVE_LOADER", True) 22 loader = d.getVar("UNINATIVE_LOADER", True)
17 tarball = d.getVar("UNINATIVE_TARBALL", True) 23 if os.path.exists(loader):
18 tarballdir = d.getVar("UNINATIVE_DLDIR", True) 24 return
19 tarballpath = os.path.join(tarballdir, tarball) 25
26 try:
27 # Save and restore cwd as Fetch.download() does a chdir()
28 olddir = os.getcwd()
29
30 tarball = d.getVar("UNINATIVE_TARBALL", True)
31 tarballdir = d.getVar("UNINATIVE_DLDIR", True)
32 tarballpath = os.path.join(tarballdir, tarball)
20 33
21 if not os.path.exists(loader):
22 # If the tarball doesn't exist, try to fetch it.
23 if not os.path.exists(tarballpath): 34 if not os.path.exists(tarballpath):
24 if d.getVar("UNINATIVE_URL", True) == "unset": 35 if d.getVar("UNINATIVE_URL", True) == "unset":
25 bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL") 36 bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL")
@@ -28,46 +39,50 @@ python uninative_eventhandler() {
28 if not chksum: 39 if not chksum:
29 bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True)) 40 bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True))
30 41
31 try:
32 # Save and restore cwd as Fetch.download() does a chdir()
33 olddir = os.getcwd()
34 42
35 localdata = bb.data.createCopy(d) 43 localdata = bb.data.createCopy(d)
36 localdata.setVar('FILESPATH', "") 44 localdata.setVar('FILESPATH', "")
37 localdata.setVar('DL_DIR', tarballdir) 45 localdata.setVar('DL_DIR', tarballdir)
38 46
39 srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum) 47 srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
40 bb.note("Fetching uninative binary shim from %s" % srcuri) 48 bb.note("Fetching uninative binary shim from %s" % srcuri)
41 49
42 fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False) 50 fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
43 fetcher.download() 51 fetcher.download()
44 localpath = fetcher.localpath(srcuri) 52 localpath = fetcher.localpath(srcuri)
45 if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath): 53 if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath):
46 os.symlink(localpath, tarballpath) 54 os.symlink(localpath, tarballpath)
47 except Exception as exc:
48 bb.warn("Unable to download uninative tarball: %s" % str(exc))
49 enabled = False
50 finally:
51 os.chdir(olddir)
52
53 # If we're still enabled then the fetch didn't fail, so unpack the tarball
54 if enabled:
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 55
63 if enabled: 56 import subprocess
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
60 d.setVar("NATIVELSBSTRING", "universal")
61 d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp")
62 d.prependVar("PATH", "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:")
63
64 except bb.fetch2.BBFetchException as exc:
65 bb.warn("Disabling uninative as unable to fetch uninative tarball: %s" % str(exc))
66 bb.warn("To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.")
67 except subprocess.CalledProcessError as exc:
68 bb.warn("Disabling uninative as unable to install uninative tarball: %s" % str(exc))
69 bb.warn("To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.")
70 finally:
71 os.chdir(olddir)
72}
73
74python uninative_event_enable() {
75 """
76 This event handler is called in the workers and is responsible for setting
77 up uninative if a loader is found.
78 """
79
80 loader = d.getVar("UNINATIVE_LOADER", True)
81 if os.path.exists(loader):
64 bb.debug(2, "Enabling uninative") 82 bb.debug(2, "Enabling uninative")
65 d.setVar("NATIVELSBSTRING", "universal") 83 d.setVar("NATIVELSBSTRING", "universal")
66 d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp") 84 d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp")
67 d.prependVar("PATH", "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:") 85 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.")
71} 86}
72 87
73python uninative_changeinterp () { 88python uninative_changeinterp () {