summaryrefslogtreecommitdiff
path: root/meta/classes
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:09 +0000
commit75fc9a8d408640d97481d310084b212a01dc5f8b (patch)
tree25b8c9cbe92e6812e1f3969308c6da5ae0847dee /meta/classes
parentd40cb4a359dbc5d762fabd996c29e468f5398dd9 (diff)
downloadopenembedded-core-75fc9a8d408640d97481d310084b212a01dc5f8b.tar.gz
openembedded-core-75fc9a8d408640d97481d310084b212a01dc5f8b.tar.bz2
openembedded-core-75fc9a8d408640d97481d310084b212a01dc5f8b.zip
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. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-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"
#UNINATIVE_CHECKSUM[x86_64] = "dead"
UNINATIVE_DLDIR ?= "${COREBASE}"
-addhandler uninative_eventhandler
-uninative_eventhandler[eventmask] = "bb.event.BuildStarted"
+addhandler uninative_event_fetchloader
+uninative_event_fetchloader[eventmask] = "bb.event.BuildStarted"
-python uninative_eventhandler() {
- enabled = True
+addhandler uninative_event_enable
+uninative_event_enable[eventmask] = "bb.event.ConfigParsed"
+
+python uninative_event_fetchloader() {
+ """
+ This event fires on the parent and will try to fetch the tarball if the
+ loader isn't already present.
+ """
loader = d.getVar("UNINATIVE_LOADER", True)
- tarball = d.getVar("UNINATIVE_TARBALL", True)
- tarballdir = d.getVar("UNINATIVE_DLDIR", True)
- tarballpath = os.path.join(tarballdir, tarball)
+ if os.path.exists(loader):
+ return
+
+ try:
+ # Save and restore cwd as Fetch.download() does a chdir()
+ olddir = os.getcwd()
+
+ tarball = d.getVar("UNINATIVE_TARBALL", True)
+ tarballdir = d.getVar("UNINATIVE_DLDIR", True)
+ tarballpath = os.path.join(tarballdir, tarball)
- if not os.path.exists(loader):
- # If the tarball doesn't exist, try to fetch it.
if not os.path.exists(tarballpath):
if d.getVar("UNINATIVE_URL", True) == "unset":
bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL")
@@ -28,46 +39,50 @@ python uninative_eventhandler() {
if not chksum:
bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True))
- try:
- # Save and restore cwd as Fetch.download() does a chdir()
- olddir = os.getcwd()
- localdata = bb.data.createCopy(d)
- localdata.setVar('FILESPATH', "")
- localdata.setVar('DL_DIR', tarballdir)
+ localdata = bb.data.createCopy(d)
+ localdata.setVar('FILESPATH', "")
+ localdata.setVar('DL_DIR', tarballdir)
- srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
- bb.note("Fetching uninative binary shim from %s" % srcuri)
+ srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
+ bb.note("Fetching uninative binary shim from %s" % srcuri)
- fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
- fetcher.download()
- localpath = fetcher.localpath(srcuri)
- if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath):
+ fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
+ 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.warn("Unable to download uninative tarball: %s" % str(exc))
- enabled = False
- finally:
- os.chdir(olddir)
-
- # If we're still enabled then the fetch didn't fail, so unpack the tarball
- if enabled:
- import subprocess
- try:
- 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")
- subprocess.check_call(cmd, shell=True)
- except subprocess.CalledProcessError as exc:
- bb.warn("Unable to install uninative tarball: %s" % str(exc))
- enabled = False
- if enabled:
+ import subprocess
+ 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")
+ subprocess.check_call(cmd, shell=True)
+
+ d.setVar("NATIVELSBSTRING", "universal")
+ d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp")
+ d.prependVar("PATH", "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:")
+
+ except bb.fetch2.BBFetchException as exc:
+ bb.warn("Disabling uninative as unable to fetch uninative tarball: %s" % str(exc))
+ bb.warn("To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.")
+ except subprocess.CalledProcessError as exc:
+ bb.warn("Disabling uninative as unable to install uninative tarball: %s" % str(exc))
+ bb.warn("To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.")
+ finally:
+ os.chdir(olddir)
+}
+
+python uninative_event_enable() {
+ """
+ This event handler is called in the workers and is responsible for setting
+ up uninative if a loader is found.
+ """
+
+ loader = d.getVar("UNINATIVE_LOADER", True)
+ if os.path.exists(loader):
bb.debug(2, "Enabling uninative")
d.setVar("NATIVELSBSTRING", "universal")
d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp")
d.prependVar("PATH", "${STAGING_DIR}-uninative/${BUILD_ARCH}-linux${bindir_native}:")
- else:
- bb.warn("Uninative selected but the loader isn't present and can't be downloaded. Disabling uninative.\n"
- "To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.")
}
python uninative_changeinterp () {