diff options
author | Otavio Salvador <otavio@ossystems.com.br> | 2022-08-10 13:54:17 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-10 13:54:17 -0300 |
commit | cdc56a683fe009ea2889ea6354d3a44b562454d7 (patch) | |
tree | 8f2ab8d4ed80afa403ac69e494b38cfe5ab99555 /classes/fsl-eula-unpack.bbclass | |
parent | effeb16a8f18d8bec59b4c0ce5fb9ce3d2a92f5e (diff) | |
parent | 98275f8772806d6f67934b5dc0a1704eab2cebd0 (diff) | |
download | meta-freescale-cdc56a683fe009ea2889ea6354d3a44b562454d7.tar.gz |
Merge pull request #1169 from thochstein/fsl-eula-unpack
Rework fsl-eula-unpack.bbclass for reuse
Diffstat (limited to 'classes/fsl-eula-unpack.bbclass')
-rw-r--r-- | classes/fsl-eula-unpack.bbclass | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/classes/fsl-eula-unpack.bbclass b/classes/fsl-eula-unpack.bbclass index 5fd18c2f..d66acc5a 100644 --- a/classes/fsl-eula-unpack.bbclass +++ b/classes/fsl-eula-unpack.bbclass | |||
@@ -104,6 +104,28 @@ do_fetch:prepend() { | |||
104 | bb.fatal("The recipe LICENSE should include Proprietary but is " + d.getVar("LICENSE") + ".") | 104 | bb.fatal("The recipe LICENSE should include Proprietary but is " + d.getVar("LICENSE") + ".") |
105 | } | 105 | } |
106 | 106 | ||
107 | do_unpack[vardepsexclude] += "FSL_EULA_FILE" | ||
108 | python do_unpack() { | ||
109 | eula = d.getVar('ACCEPT_FSL_EULA') | ||
110 | eula_file = d.getVar('FSL_EULA_FILE') | ||
111 | pkg = d.getVar('PN') | ||
112 | if eula == None: | ||
113 | bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. " | ||
114 | "Please read it and in case you accept it, write: " | ||
115 | "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file)) | ||
116 | elif eula == '0': | ||
117 | bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg) | ||
118 | else: | ||
119 | bb.note("Freescale EULA has been accepted for '%s'" % pkg) | ||
120 | |||
121 | try: | ||
122 | bb.build.exec_func('base_do_unpack', d) | ||
123 | except: | ||
124 | raise | ||
125 | |||
126 | bb.build.exec_func('fsl_bin_do_unpack', d) | ||
127 | } | ||
128 | |||
107 | python fsl_bin_do_unpack() { | 129 | python fsl_bin_do_unpack() { |
108 | src_uri = (d.getVar('SRC_URI') or "").split() | 130 | src_uri = (d.getVar('SRC_URI') or "").split() |
109 | if len(src_uri) == 0: | 131 | if len(src_uri) == 0: |
@@ -128,16 +150,28 @@ python fsl_bin_do_unpack() { | |||
128 | bb.note("Handling file '%s' as a Freescale EULA-licensed archive." % url.basename) | 150 | bb.note("Handling file '%s' as a Freescale EULA-licensed archive." % url.basename) |
129 | cmd = "sh %s --auto-accept --force" % (url.localpath) | 151 | cmd = "sh %s --auto-accept --force" % (url.localpath) |
130 | bb.fetch2.runfetchcmd(cmd, d, quiet=True, workdir=rootdir) | 152 | bb.fetch2.runfetchcmd(cmd, d, quiet=True, workdir=rootdir) |
153 | if not found: | ||
154 | bb.fatal("The recipe inherits 'fsl-eula-unpack.bbclass' but does not mark any URL in SRC_URI with the option 'fsl-eula=true'") | ||
131 | 155 | ||
132 | # Check for two EULAs, one from the layer and one from the package | 156 | # Check for two EULAs, one from the layer and one from the package |
133 | bb.note("Checking LIC_FILES_CHKSUM for Freescale EULA consistency...") | 157 | bb.note("Checking LIC_FILES_CHKSUM for Freescale EULA consistency...") |
134 | if found > 1: | 158 | if found > 1: |
135 | bb.warn("The package contains multiple Freescale EULA-licensed archives. The consistency logic may not be able to detect a EULA problem.") | 159 | bb.warn("The package contains multiple Freescale EULA-licensed archives. The consistency logic may not be able to detect a EULA problem.") |
160 | (layer_license, licenses, md5sums, found_layer_licenses, found_package_licenses) = find_nxp_eula_licenses(d) | ||
161 | if not found_layer_licenses: | ||
162 | bb.fatal("The Freescale layer EULA '%s' is not listed in LIC_FILES_CHKSUM '%s'." | ||
163 | % (layer_license, licenses)) | ||
164 | if not found_package_licenses: | ||
165 | bb.fatal("A valid package EULA with md5sum in %s was not found in LIC_FILES_CHKSUM '%s'." | ||
166 | % (md5sums.split(), licenses)) | ||
167 | } | ||
168 | |||
169 | def find_nxp_eula_licenses(d): | ||
136 | layer_license = d.getVar('LIC_FILES_CHKSUM_LAYER') | 170 | layer_license = d.getVar('LIC_FILES_CHKSUM_LAYER') |
137 | licenses = d.getVar('LIC_FILES_CHKSUM') or "" | 171 | licenses = d.getVar('LIC_FILES_CHKSUM') or "" |
138 | md5sums = d.getVar('FSL_EULA_FILE_MD5SUMS') or "" | 172 | md5sums = d.getVar('FSL_EULA_FILE_MD5SUMS') or "" |
139 | found_layer_license = False | 173 | found_layer_licenses = "" |
140 | found_package_license = False | 174 | found_package_licenses = "" |
141 | for license in licenses.split(): | 175 | for license in licenses.split(): |
142 | try: | 176 | try: |
143 | (method, host, path, user, pswd, parm) = bb.fetch.decodeurl(license) | 177 | (method, host, path, user, pswd, parm) = bb.fetch.decodeurl(license) |
@@ -147,37 +181,8 @@ python fsl_bin_do_unpack() { | |||
147 | bb.fatal("%s: LIC_FILES_CHKSUM contains an invalid URL: %s" % (d.getVar('PF'), license)) | 181 | bb.fatal("%s: LIC_FILES_CHKSUM contains an invalid URL: %s" % (d.getVar('PF'), license)) |
148 | if license == layer_license: | 182 | if license == layer_license: |
149 | bb.note("Found Freescale EULA for the layer %s." % license) | 183 | bb.note("Found Freescale EULA for the layer %s." % license) |
150 | found_layer_license = True | 184 | found_layer_licenses += license |
151 | elif parm.get('md5') in md5sums: | 185 | elif parm.get('md5') in md5sums: |
152 | bb.note("Found Freescale EULA for the package %s." % license) | 186 | bb.note("Found Freescale EULA for the package %s." % license) |
153 | found_package_license = True | 187 | found_package_licenses += license |
154 | if not found_layer_license: | 188 | return (layer_license, licenses, md5sums, found_layer_licenses, found_package_licenses) |
155 | bb.fatal("The Freescale layer EULA '%s' is not listed in LIC_FILES_CHKSUM '%s'." | ||
156 | % (layer_license, licenses)) | ||
157 | if not found_package_license: | ||
158 | bb.fatal("A valid package EULA with md5sum in %s was not found in LIC_FILES_CHKSUM '%s'." | ||
159 | % (md5sums.split(), licenses)) | ||
160 | } | ||
161 | |||
162 | python do_unpack() { | ||
163 | eula = d.getVar('ACCEPT_FSL_EULA') | ||
164 | eula_file = d.getVar('FSL_EULA_FILE') | ||
165 | pkg = d.getVar('PN') | ||
166 | if eula == None: | ||
167 | bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. " | ||
168 | "Please read it and in case you accept it, write: " | ||
169 | "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file)) | ||
170 | elif eula == '0': | ||
171 | bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg) | ||
172 | else: | ||
173 | bb.note("Freescale EULA has been accepted for '%s'" % pkg) | ||
174 | |||
175 | try: | ||
176 | bb.build.exec_func('base_do_unpack', d) | ||
177 | except: | ||
178 | raise | ||
179 | |||
180 | bb.build.exec_func('fsl_bin_do_unpack', d) | ||
181 | } | ||
182 | |||
183 | do_unpack[vardepsexclude] += "FSL_EULA_FILE" | ||