diff options
Diffstat (limited to 'classes/fsl-eula-unpack.bbclass')
| -rw-r--r-- | classes/fsl-eula-unpack.bbclass | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/classes/fsl-eula-unpack.bbclass b/classes/fsl-eula-unpack.bbclass new file mode 100644 index 000000000..a9f16ef0f --- /dev/null +++ b/classes/fsl-eula-unpack.bbclass | |||
| @@ -0,0 +1,67 @@ | |||
| 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 | LIC_FILES_CHKSUM_append = " file://${FSL_EULA_FILE};md5=acdb807ac7275fe32f9f64992e111241" | ||
| 10 | LIC_FILES_CHKSUM[vardepsexclude] += "FSL_EULA_FILE" | ||
| 11 | |||
| 12 | python fsl_bin_do_unpack() { | ||
| 13 | src_uri = (d.getVar('SRC_URI', True) or "").split() | ||
| 14 | if len(src_uri) == 0: | ||
| 15 | return | ||
| 16 | |||
| 17 | localdata = bb.data.createCopy(d) | ||
| 18 | bb.data.update_data(localdata) | ||
| 19 | |||
| 20 | rootdir = localdata.getVar('WORKDIR', True) | ||
| 21 | fetcher = bb.fetch2.Fetch(src_uri, localdata) | ||
| 22 | |||
| 23 | for url in fetcher.ud.values(): | ||
| 24 | save_cwd = os.getcwd() | ||
| 25 | # Check for supported fetchers | ||
| 26 | if url.type in ['http', 'https', 'ftp', 'file']: | ||
| 27 | if url.parm.get('fsl-eula', False): | ||
| 28 | # If download has failed, do nothing | ||
| 29 | if not os.path.exists(url.localpath): | ||
| 30 | bb.debug(1, "Exiting as '%s' cannot be found" % url.basename) | ||
| 31 | return | ||
| 32 | |||
| 33 | # Change to the working directory | ||
| 34 | bb.note("Handling file '%s' as a Freescale's EULA binary." % url.basename) | ||
| 35 | save_cwd = os.getcwd() | ||
| 36 | os.chdir(rootdir) | ||
| 37 | |||
| 38 | cmd = "sh %s --auto-accept --force" % (url.localpath) | ||
| 39 | bb.fetch2.runfetchcmd(cmd, d, quiet=True) | ||
| 40 | |||
| 41 | # Return to the previous directory | ||
| 42 | os.chdir(save_cwd) | ||
| 43 | } | ||
| 44 | |||
| 45 | python do_unpack() { | ||
| 46 | eula = d.getVar('ACCEPT_FSL_EULA', True) | ||
| 47 | eula_file = d.getVar('FSL_EULA_FILE', True) | ||
| 48 | pkg = d.getVar('PN', True) | ||
| 49 | if eula == None: | ||
| 50 | bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. " | ||
| 51 | "Please read it and in case you accept it, write: " | ||
| 52 | "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file)) | ||
| 53 | elif eula == '0': | ||
| 54 | bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg) | ||
| 55 | else: | ||
| 56 | bb.note("Freescale EULA has been accepted for '%s'" % pkg) | ||
| 57 | |||
| 58 | # The binary unpack needs to be done first so 'S' is valid | ||
| 59 | bb.build.exec_func('fsl_bin_do_unpack', d) | ||
| 60 | |||
| 61 | try: | ||
| 62 | bb.build.exec_func('base_do_unpack', d) | ||
| 63 | except: | ||
| 64 | raise | ||
| 65 | } | ||
| 66 | |||
| 67 | do_unpack[vardepsexclude] += "FSL_EULA_FILE" | ||
