From 8989fcc89ba66a4270834736ef7a8c86368ba33c Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sat, 15 Sep 2012 13:21:47 -0300 Subject: 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 Acked-by: Daiane Angolini --- classes/fsl-eula-unpack.bbclass | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 classes/fsl-eula-unpack.bbclass (limited to 'classes/fsl-eula-unpack.bbclass') 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 @@ +# fsl-eula-unpack.bbclass provides the mechanism used for unpacking +# the .bin file downloaded by HTTP and handle the EULA acceptance. +# +# To use it, the 'fsl-eula' parameter needs to be added to the +# SRC_URI entry, e.g: +# +# SRC_URI = "${FSL_MIRROR}/firmware-imx-${PV};fsl-eula=true" + +python fsl_bin_do_unpack() { + src_uri = (d.getVar('SRC_URI', True) or "").split() + if len(src_uri) == 0: + return + + localdata = bb.data.createCopy(d) + bb.data.update_data(localdata) + + rootdir = localdata.getVar('WORKDIR', True) + fetcher = bb.fetch2.Fetch(src_uri, localdata) + + for url in fetcher.ud.values(): + # Check for supported fetchers + if url.type in ['http', 'https', 'ftp', 'file']: + if url.parm.get('fsl-eula', False): + # If download has failed, do nothing + if not os.path.exists(url.localpath): + bb.debug(1, "Exiting as '%s' cannot be found" % url.basename) + return + + # Change to the working directory + bb.note("Handling file '%s' as a Freescale's EULA binary." % url.basename) + save_cwd = os.getcwd() + os.chdir(rootdir) + + cmd = "sh %s --auto-accept --force" % (url.localpath) + bb.fetch2.runfetchcmd(cmd, d, quiet=True) + + # Return to the previous directory + os.chdir(save_cwd) +} + +python do_unpack() { + eula = d.getVar('ACCEPT_FSL_EULA', True) + eula_file = d.getVar('FSL_EULA_FILE', True) + pkg = d.getVar('PN', True) + if eula == None: + bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. " + "Please read it and in case you accept it, write: " + "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file)) + elif eula == '0': + bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg) + else: + bb.note("Freescale EULA has been accepted for '%s'" % pkg) + + try: + bb.build.exec_func('base_do_unpack', d) + except: + raise + + bb.build.exec_func('fsl_bin_do_unpack', d) +} -- cgit v1.2.3-54-g00ecf