diff options
author | Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com> | 2024-08-12 14:28:29 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-08-23 09:51:36 +0100 |
commit | 0a0caacfa54dd086b87e31f5e806e5f21d5ffc3f (patch) | |
tree | 16808016f555c6bb2096240809bf481cea5cc458 /scripts/lib/recipetool/create.py | |
parent | 69bf37a3dd0470dc153bb7a21bd8f13a64bde2c3 (diff) | |
download | poky-0a0caacfa54dd086b87e31f5e806e5f21d5ffc3f.tar.gz |
recipetool: create_npm: reuse license utils
create_npm.py duplicated the logic for matching licenses from files and
also finding them. This patch refactors the code to reuse the license
utils. This will make the code more maintainable and also align both
behaviors. For instance, some licenses weren't matched properly because
the duplicate logic did not support the difference in format in the md5
tables for COMMON_LICENSE_DIR and licenses.csv.
This is also faster since the license files were being read twice.
The result is slightly more accurate since the utils have better
implementations, and I was able to reuse the logic for the root PN
package, as well as the base LICENSE variable.
I chose to extract generate_common_licenses_chksums into create.py
since it can be considered a general utility function to allow
other recipetool creators to refer to COMMON_LICENSE_DIR files.
I updated the wording in the code when appropriate.
v3:
- added commit
- this replaces the commit that added all the COMMON_LICENSE_DIR md5
to licenses.csv
(From OE-Core rev: 7bc18bed63b94689890bcde63402d7cc1cedffa9)
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-rw-r--r-- | scripts/lib/recipetool/create.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index c626844370..ea2ef5be63 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -1295,6 +1295,14 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=None, pn | |||
1295 | outlicenses[pkgname] = licenses | 1295 | outlicenses[pkgname] = licenses |
1296 | return outlicenses | 1296 | return outlicenses |
1297 | 1297 | ||
1298 | def generate_common_licenses_chksums(common_licenses, d): | ||
1299 | lic_files_chksums = [] | ||
1300 | for license in tidy_licenses(common_licenses): | ||
1301 | licfile = '${COMMON_LICENSE_DIR}/' + license | ||
1302 | md5value = bb.utils.md5_file(d.expand(licfile)) | ||
1303 | lic_files_chksums.append('file://%s;md5=%s' % (licfile, md5value)) | ||
1304 | return lic_files_chksums | ||
1305 | |||
1298 | def read_pkgconfig_provides(d): | 1306 | def read_pkgconfig_provides(d): |
1299 | pkgdatadir = d.getVar('PKGDATA_DIR') | 1307 | pkgdatadir = d.getVar('PKGDATA_DIR') |
1300 | pkgmap = {} | 1308 | pkgmap = {} |