summaryrefslogtreecommitdiffstats
path: root/meta/classes/uninative.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-22 13:05:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-24 09:40:34 +0000
commit29c5edaf46e807d44aab32adc3c1cb1410c87993 (patch)
tree2022dd63e87baff0423f15cf2b49075e4ee70a10 /meta/classes/uninative.bbclass
parentb54fa253104c6fec402f8b678337293589cc0545 (diff)
downloadpoky-29c5edaf46e807d44aab32adc3c1cb1410c87993.tar.gz
uninative: Add fetch capability
Originally, the idea was that the init environment would handle fetching or providing the binary shim that uninative needs. This turns out to be ugly, especially when you consider proxy environments and so on getting involved. Instead, lets therefore support our fetcher which already handles all this. The distro is expected to setup configuration like: UNINATIVE_URL ?= "http://mydomain/mypath/" UNINATIVE_CHECKSUM[i586] = "md5sum1" UNINATIVE_CHECKSUM[x86_64] = "md5sum2" and then it should all work if the user inherits the uninative class. This patch also improves the error handling in the class to give more user readable error messages. If the shim binary is already provided, the system will just use that and ignore the url information. (From OE-Core rev: 89097d2d7bf058136b01ec982b9453b49052b1d8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/uninative.bbclass')
-rw-r--r--meta/classes/uninative.bbclass41
1 files changed, 38 insertions, 3 deletions
diff --git a/meta/classes/uninative.bbclass b/meta/classes/uninative.bbclass
index 0cd27db853..fe1e89b29c 100644
--- a/meta/classes/uninative.bbclass
+++ b/meta/classes/uninative.bbclass
@@ -2,16 +2,51 @@ NATIVELSBSTRING = "universal"
2 2
3UNINATIVE_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)}" 3UNINATIVE_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)}"
4 4
5UNINATIVE_URL ?= "unset"
6UNINATIVE_TARBALL ?= "${BUILD_ARCH}-nativesdk-libc.tar.bz2"
7# Example checksums
8#UNINATIVE_CHECKSUM[i586] = "dead"
9#UNINATIVE_CHECKSUM[x86_64] = "dead"
10UNINATIVE_DLDIR ?= "${COREBASE}"
11
5addhandler uninative_eventhandler 12addhandler uninative_eventhandler
6uninative_eventhandler[eventmask] = "bb.event.BuildStarted" 13uninative_eventhandler[eventmask] = "bb.event.BuildStarted"
7 14
8python uninative_eventhandler() { 15python uninative_eventhandler() {
9 loader = e.data.getVar("UNINATIVE_LOADER", True) 16 loader = e.data.getVar("UNINATIVE_LOADER", True)
17 tarball = d.getVar("UNINATIVE_TARBALL", True)
18 tarballdir = d.getVar("UNINATIVE_DLDIR", True)
10 if not os.path.exists(loader): 19 if not os.path.exists(loader):
11 import subprocess 20 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") 21
13 #bb.warn("nativesdk lib extraction: " + cmd) 22 olddir = os.getcwd()
14 subprocess.check_call(cmd, shell=True) 23 if not os.path.exists(os.path.join(tarballdir, tarball)):
24 # Copy the data object and override DL_DIR and SRC_URI
25 localdata = bb.data.createCopy(d)
26
27 if d.getVar("UNINATIVE_URL", True) == "unset":
28 bb.fatal("Uninative selected but not configured, please set UNINATIVE_URL")
29
30 chksum = d.getVarFlag("UNINATIVE_CHECKSUM", d.getVar("BUILD_ARCH", True), True)
31 if not chksum:
32 bb.fatal("Uninative selected but not configured correctly, please set UNINATIVE_CHECKSUM[%s]" % d.getVar("BUILD_ARCH", True))
33
34 srcuri = d.expand("${UNINATIVE_URL}${UNINATIVE_TARBALL};md5sum=%s" % chksum)
35 dldir = localdata.expand(tarballdir)
36 localdata.setVar('FILESPATH', dldir)
37 localdata.setVar('DL_DIR', dldir)
38 bb.note("Fetching uninative binary shim from %s" % srcuri)
39 fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
40 try:
41 fetcher.download()
42 except Exception as exc:
43 bb.fatal("Unable to download uninative tarball: %s" % str(exc))
44 cmd = e.data.expand("mkdir -p ${STAGING_DIR}; cd ${STAGING_DIR}; tar -xjf ${UNINATIVE_DLDIR}/${UNINATIVE_TARBALL}; ${STAGING_DIR}/relocate_sdk.py ${STAGING_DIR_NATIVE} ${UNINATIVE_LOADER} ${UNINATIVE_LOADER} ${STAGING_BINDIR_NATIVE}/patchelf-uninative")
45 try:
46 subprocess.check_call(cmd, shell=True)
47 except subprocess.CalledProcessError as exc:
48 bb.fatal("Unable to install uninative tarball: %s" % str(exc))
49 os.chdir(olddir)
15} 50}
16 51
17SSTATEPOSTUNPACKFUNCS_append = " uninative_changeinterp" 52SSTATEPOSTUNPACKFUNCS_append = " uninative_changeinterp"