diff options
author | Nitin A Kamble <nitin.a.kamble@intel.com> | 2010-05-11 16:25:39 -0700 |
---|---|---|
committer | Nitin A Kamble <nitin.a.kamble@intel.com> | 2010-05-11 16:25:39 -0700 |
commit | 2ca1f78a9578d9c2095be548aeda523b61ee840c (patch) | |
tree | cbf1dc64c07aff1347260fee4cfdca3d9fffeb98 | |
parent | c89362c767ba3255358f5bf5630bdef8cb3d107d (diff) | |
download | openembedded-core-2ca1f78a9578d9c2095be548aeda523b61ee840c.tar.gz openembedded-core-2ca1f78a9578d9c2095be548aeda523b61ee840c.tar.bz2 openembedded-core-2ca1f78a9578d9c2095be548aeda523b61ee840c.zip |
License Change checking:
Added a new variable in recipe : LIC_FILES_CHKSUM
It is a required field for every recipe.
It describes license text location in the source files. And also stores
md5sum of that license text. Any change in this license text triggers build
error. Which enables developer to review any changes in the license and
update the license fields in the recipe accordingly.
For Example: contents of zlib_1.2.3.bb
LICENSE = "zlib"
LIC_FILES_CHKSUM = "file://README;md5=ae764cfda68da96df20af9fbf9fe49bd \
file://zlib.h;beginline=1;endline=30;md5=6ab03f03a5ee92d06b809797d4d5586d "
Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
-rw-r--r-- | meta/classes/insane.bbclass | 63 | ||||
-rw-r--r-- | meta/packages/zlib/zlib_1.2.3.bb | 2 |
2 files changed, 64 insertions, 1 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 6d82e4df88..88e77a75ee 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass @@ -266,6 +266,66 @@ def package_qa_check_buildpaths(path, name, d): sane = package_qa_handle_error(9, error_msg, name, path, d) return sane +def package_qa_check_license(workdir, d): + """ + Check for changes in the license files + """ + import tempfile + sane = True + + lic_files = bb.data.getVar('LIC_FILES_CHKSUM', d, True) + + if not lic_files: + bb.error(" Recipe (.bb) file does not have license file information (LIC_FILES_CHKSUM)") + return False + + srcdir = bb.data.getVar('S', d, True) + + for url in lic_files.split(): + (type, host, path, user, pswd, parm) = bb.decodeurl(url) + srclicfile = os.path.join(srcdir, path) + + if 'md5' not in parm: + bb.error("md5 checksum is not specified for ", url) + return False + beginline, endline = 0, 0 + if 'beginline' in parm: + beginline = int(parm['beginline']) + if 'endline' in parm: + endline = int(parm['endline']) + + if (not beginline) and (not endline): + md5chksum = bb.utils.md5_file(srclicfile) + else: + fi = open(srclicfile, 'r') + fo = tempfile.NamedTemporaryFile(mode='wb', prefix='poky.', suffix='.tmp', delete=False) + tmplicfile = fo.name; + lineno = 0 + linesout = 0 + for line in fi: + lineno += 1 + if (lineno >= beginline): + if ((lineno <= endline) or not endline): + fo.write(line) + linesout += 1 + else: + break + fo.flush() + fo.close() + fi.close() + md5chksum = bb.utils.md5_file(tmplicfile) + os.unlink(tmplicfile) + + if parm['md5'] == md5chksum: + bb.note ("md5 checksum matched for ", url) + else: + bb.error ("md5 data is not matching for ", url) + bb.note ("The new md5 checksum is ", md5chksum) + bb.note ("Check if the license information has changed, and if it has update the .bb file with correct license") + return False + + return sane + def package_qa_check_staged(path,d): """ Check staged la and pc files for sanity @@ -385,7 +445,8 @@ python do_package_qa () { if not package_qa_check_rdepends(package, workdir, d): rdepends_sane = False - if not walk_sane or not rdepends_sane: + + if not walk_sane or not rdepends_sane or not package_qa_check_license(workdir, d): bb.fatal("QA run found fatal errors. Please consider fixing them.") bb.note("DONE with PACKAGE QA") } diff --git a/meta/packages/zlib/zlib_1.2.3.bb b/meta/packages/zlib/zlib_1.2.3.bb index 97d0be5d5e..c58d5f2d25 100644 --- a/meta/packages/zlib/zlib_1.2.3.bb +++ b/meta/packages/zlib/zlib_1.2.3.bb @@ -3,6 +3,8 @@ SECTION = "libs" PRIORITY = "required" HOMEPAGE = "http://www.gzip.org/zlib/" LICENSE = "zlib" +LIC_FILES_CHKSUM = "file://README;md5=ae764cfda68da96df20af9fbf9fe49bd \ + file://zlib.h;beginline=1;endline=30;md5=6ab03f03a5ee92d06b809797d4d5586d " PR = "r7" SRC_URI = "http://www.zlib.net/zlib-1.2.3.tar.bz2 \ |