diff options
Diffstat (limited to 'classes/fsl-eula-unpack.bbclass')
-rw-r--r-- | classes/fsl-eula-unpack.bbclass | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/classes/fsl-eula-unpack.bbclass b/classes/fsl-eula-unpack.bbclass new file mode 100644 index 0000000..0da17c3 --- /dev/null +++ b/classes/fsl-eula-unpack.bbclass | |||
@@ -0,0 +1,63 @@ | |||
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 | |||
9 | python 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 | save_cwd = os.getcwd() | ||
22 | # Check for supported fetchers | ||
23 | if url.type in ['http', 'https', 'ftp', 'file']: | ||
24 | if url.parm.get('fsl-eula', False): | ||
25 | # If download has failed, do nothing | ||
26 | if not os.path.exists(url.localpath): | ||
27 | bb.debug(1, "Exiting as '%s' cannot be found" % url.basename) | ||
28 | return | ||
29 | |||
30 | # Change to the working directory | ||
31 | bb.note("Handling file '%s' as a Freescale's EULA binary." % url.basename) | ||
32 | save_cwd = os.getcwd() | ||
33 | os.chdir(rootdir) | ||
34 | |||
35 | cmd = "sh %s --auto-accept --force" % (url.localpath) | ||
36 | bb.fetch2.runfetchcmd(cmd, d, quiet=True) | ||
37 | |||
38 | # Return to the previous directory | ||
39 | os.chdir(save_cwd) | ||
40 | } | ||
41 | |||
42 | python do_unpack() { | ||
43 | eula = d.getVar('ACCEPT_FSL_EULA', True) | ||
44 | eula_file = d.getVar('FSL_EULA_FILE', True) | ||
45 | pkg = d.getVar('PN', True) | ||
46 | if eula == None: | ||
47 | bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. " | ||
48 | "Please read it and in case you accept it, write: " | ||
49 | "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file)) | ||
50 | elif eula == '0': | ||
51 | bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg) | ||
52 | else: | ||
53 | bb.note("Freescale EULA has been accepted for '%s'" % pkg) | ||
54 | |||
55 | try: | ||
56 | bb.build.exec_func('base_do_unpack', d) | ||
57 | except: | ||
58 | raise | ||
59 | |||
60 | bb.build.exec_func('fsl_bin_do_unpack', d) | ||
61 | } | ||
62 | |||
63 | do_unpack[vardepsexclude] += "FSL_EULA_FILE" | ||