summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2012-09-15 13:21:47 -0300
committerOtavio Salvador <otavio@ossystems.com.br>2012-10-02 09:41:16 -0300
commit8989fcc89ba66a4270834736ef7a8c86368ba33c (patch)
treed201c72985e3c3de153a5e937765ce5ee8bceb4e /classes
parentcb376b652d98fd58f4959192cb5642da01e77bab (diff)
downloadmeta-fsl-arm-8989fcc89ba66a4270834736ef7a8c86368ba33c.tar.gz
fsl-eula-unpack.bbclass: Support Freescale EULA binaries unpack
This class provides the mechanism used for unpacking the .bin file downloaded by HTTP and handle the EULA acceptance. Change-Id: I88857c7dac94568c5bced4e712744087638de68a Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Acked-by: Daiane Angolini <daiane.angolini@freescale.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/fsl-eula-unpack.bbclass60
1 files changed, 60 insertions, 0 deletions
diff --git a/classes/fsl-eula-unpack.bbclass b/classes/fsl-eula-unpack.bbclass
new file mode 100644
index 0000000..7a6a554
--- /dev/null
+++ b/classes/fsl-eula-unpack.bbclass
@@ -0,0 +1,60 @@
1# fsl-eula-unpack.bbclass provides the mechanism used for unpacking
2# the .bin file downloaded by HTTP and handle the EULA acceptance.
3#
4# To use it, the 'fsl-eula' parameter needs to be added to the
5# SRC_URI entry, e.g:
6#
7# SRC_URI = "${FSL_MIRROR}/firmware-imx-${PV};fsl-eula=true"
8
9python fsl_bin_do_unpack() {
10 src_uri = (d.getVar('SRC_URI', True) or "").split()
11 if len(src_uri) == 0:
12 return
13
14 localdata = bb.data.createCopy(d)
15 bb.data.update_data(localdata)
16
17 rootdir = localdata.getVar('WORKDIR', True)
18 fetcher = bb.fetch2.Fetch(src_uri, localdata)
19
20 for url in fetcher.ud.values():
21 # Check for supported fetchers
22 if url.type in ['http', 'https', 'ftp', 'file']:
23 if url.parm.get('fsl-eula', False):
24 # If download has failed, do nothing
25 if not os.path.exists(url.localpath):
26 bb.debug(1, "Exiting as '%s' cannot be found" % url.basename)
27 return
28
29 # Change to the working directory
30 bb.note("Handling file '%s' as a Freescale's EULA binary." % url.basename)
31 save_cwd = os.getcwd()
32 os.chdir(rootdir)
33
34 cmd = "sh %s --auto-accept --force" % (url.localpath)
35 bb.fetch2.runfetchcmd(cmd, d, quiet=True)
36
37 # Return to the previous directory
38 os.chdir(save_cwd)
39}
40
41python do_unpack() {
42 eula = d.getVar('ACCEPT_FSL_EULA', True)
43 eula_file = d.getVar('FSL_EULA_FILE', True)
44 pkg = d.getVar('PN', True)
45 if eula == None:
46 bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. "
47 "Please read it and in case you accept it, write: "
48 "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file))
49 elif eula == '0':
50 bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg)
51 else:
52 bb.note("Freescale EULA has been accepted for '%s'" % pkg)
53
54 try:
55 bb.build.exec_func('base_do_unpack', d)
56 except:
57 raise
58
59 bb.build.exec_func('fsl_bin_do_unpack', d)
60}