diff options
Diffstat (limited to 'meta-fsl-arm/classes/fsl-eula-unpack.bbclass')
| -rw-r--r-- | meta-fsl-arm/classes/fsl-eula-unpack.bbclass | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/meta-fsl-arm/classes/fsl-eula-unpack.bbclass b/meta-fsl-arm/classes/fsl-eula-unpack.bbclass new file mode 100644 index 000000000..7a6a55472 --- /dev/null +++ b/meta-fsl-arm/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 | |||
| 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 | # 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 | |||
| 41 | python 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 | } | ||
