Skip to contentSkip to conversation

License tracking

PATCH New Beth Flanagan 1 participant 2 messages Jan 27, 2011

lore
Share & tools
lore
#0 lore raw

cover License tracking

From: Beth Flanagan <[email protected]>

Re-pull request for license tracking with Josh's requested fixes.

Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: eflanagan/license
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=eflanagan/license

Thanks,
Beth Flanagan <[email protected]>
---

Beth Flanagan (1):
Initial commit of license reporting:

 meta/classes/license.bbclass          |  101 +++++
 meta/conf/distro/poky.conf            |    4 +-
 meta/files/common-licenses/Apache-2.0 |  202 ++++++++++
 meta/files/common-licenses/Artistic   |  131 +++++++
 meta/files/common-licenses/BSD        |   26 ++
 meta/files/common-licenses/GFDL       |  451 ++++++++++++++++++++++
 meta/files/common-licenses/GFDL-1.2   |  397 +++++++++++++++++++
 meta/files/common-licenses/GFDL-1.3   |  451 ++++++++++++++++++++++
 meta/files/common-licenses/GPL        |  676 +++++++++++++++++++++++++++++++++
 meta/files/common-licenses/GPLv2      |  339 +++++++++++++++++
 meta/files/common-licenses/GPLv3      |  676 +++++++++++++++++++++++++++++++++
 meta/files/common-licenses/LGPL       |  165 ++++++++
 meta/files/common-licenses/LGPLv2     |  481 +++++++++++++++++++++++
 meta/files/common-licenses/LGPLv2.1   |  510 +++++++++++++++++++++++++
 meta/files/common-licenses/LGPLv3     |  165 ++++++++
 15 files changed, 4774 insertions(+), 1 deletions(-)
 create mode 100644 meta/classes/license.bbclass
 create mode 100644 meta/files/common-licenses/Apache-2.0
 create mode 100644 meta/files/common-licenses/Artistic
 create mode 100644 meta/files/common-licenses/BSD
 create mode 100644 meta/files/common-licenses/GFDL
 create mode 100644 meta/files/common-licenses/GFDL-1.2
 create mode 100644 meta/files/common-licenses/GFDL-1.3
 create mode 100644 meta/files/common-licenses/GPL
 create mode 100644 meta/files/common-licenses/GPLv2
 create mode 100644 meta/files/common-licenses/GPLv3
 create mode 100644 meta/files/common-licenses/LGPL
 create mode 100644 meta/files/common-licenses/LGPLv2
 create mode 100644 meta/files/common-licenses/LGPLv2.1
 create mode 100644 meta/files/common-licenses/LGPLv3
#1 lore raw

PATCH 1/1 Initial commit of license reporting:

From: Beth Flanagan <[email protected]>

This is an intial commit for the license reporting system. A few notes:
The LICENSE fields needs to be standardized throughout poky. As it stands, we throw a warning if the license file is not found (either because it does not exist or because LICENSE_FILE_CHKSUM is munged) in the generic license directory. This should eventually become an error.

I've seen a few places where Apache-v2.0 is written differently and I'm sure this will throw the above warning. This does not put the license data on the rootfs. Also, I provide both the actual license text and a link to the best guess of the generic_license. That guessing is not very robust and I'm loath to get into a bunch of pattern matching rather than standardize LICENSE.

This adds one new param to poky.conf and one new to license.bbclass:

LICENSE_DIR: the base directory we copy all the license results to (set in license.bbclass)
COMMON_LICENSE_DIR: this is the directory that holds all the common generic license files. currently meta/files/common-licenses (set in poky.conf)

TODO:
- We should verify the common-licenses. I stripped these from my Ubuntu 10.10 system.
- We should allow the capability of licenses on the rootfs, although the resulting image created would be a lot larger.
- More common-licenses. I don't include bzip, zlib, ICS.... I should, but that means tracking down a lot of licenses.
- General cleanup of licensing and standardization of names. We should standardize on a naming convention. What's in licenses.conf should match up with what is in the recipes which should match with what is in common-licenses. Outside the scope of this though. See:
http://bugzilla.pokylinux.org/show_bug.cgi?id=650

---
 meta/classes/license.bbclass          |  101 +++++
 meta/conf/distro/poky.conf            |    4 +-
 meta/files/common-licenses/Apache-2.0 |  202 ++++++++++
 meta/files/common-licenses/Artistic   |  131 +++++++
 meta/files/common-licenses/BSD        |   26 ++
 meta/files/common-licenses/GFDL       |  451 ++++++++++++++++++++++
 meta/files/common-licenses/GFDL-1.2   |  397 +++++++++++++++++++
 meta/files/common-licenses/GFDL-1.3   |  451 ++++++++++++++++++++++
 meta/files/common-licenses/GPL        |  676 +++++++++++++++++++++++++++++++++
 meta/files/common-licenses/GPLv2      |  339 +++++++++++++++++
 meta/files/common-licenses/GPLv3      |  676 +++++++++++++++++++++++++++++++++
 meta/files/common-licenses/LGPL       |  165 ++++++++
 meta/files/common-licenses/LGPLv2     |  481 +++++++++++++++++++++++
 meta/files/common-licenses/LGPLv2.1   |  510 +++++++++++++++++++++++++
 meta/files/common-licenses/LGPLv3     |  165 ++++++++
 15 files changed, 4774 insertions(+), 1 deletions(-)
 create mode 100644 meta/classes/license.bbclass
 create mode 100644 meta/files/common-licenses/Apache-2.0
 create mode 100644 meta/files/common-licenses/Artistic
 create mode 100644 meta/files/common-licenses/BSD
 create mode 100644 meta/files/common-licenses/GFDL
 create mode 100644 meta/files/common-licenses/GFDL-1.2
 create mode 100644 meta/files/common-licenses/GFDL-1.3
 create mode 100644 meta/files/common-licenses/GPL
 create mode 100644 meta/files/common-licenses/GPLv2
 create mode 100644 meta/files/common-licenses/GPLv3
 create mode 100644 meta/files/common-licenses/LGPL
 create mode 100644 meta/files/common-licenses/LGPLv2
 create mode 100644 meta/files/common-licenses/LGPLv2.1
 create mode 100644 meta/files/common-licenses/LGPLv3
meta/classes/license.bbclass new file +101 -0
new file mode 100644
index 0000000..ddedd57
@@ -0,0 +1,101 @@
+# Populates LICENSE_DIRECTORY as set in poky.conf with the license files as set by
+# LIC_FILES_CHKSUM. 
+# TODO:
+# - We should also enable the ability to put the generated license directory onto the
+#  rootfs
+# - Gather up more generic licenses
+# - There is a real issue revolving around license naming standards. See license names 
+#  licenses.conf and compare them to the license names in the recipes. You'll see some
+#  differences and that should be corrected.
+
+LICENSE_DIRECTORY ??= "${DEPLOY_DIR_IMAGE}/licenses"
+
+addtask populate_lic after do_patch before do_package 
+do_populate_lic[nostamp] = "1"
+python do_populate_lic() {
+    """
+    Populate LICENSE_DIRECTORY with licenses.
+    """
+    import os
+    import bb
+    import shutil
+
+    # All the license types for the package
+    license_types = bb.data.getVar('LICENSE', d, True)
+    # All the license files for the package
+    lic_files = bb.data.getVar('LIC_FILES_CHKSUM', d, True)
+    pn = bb.data.getVar('PN', d, True)
+    # The base directory we wrangle licenses to
+    destdir = os.path.join(bb.data.getVar('LICENSE_DIRECTORY', d, True), pn)
+    # The license files are located in S/LIC_FILE_CHECKSUM.
+    srcdir = bb.data.getVar('S', d, True)
+    # Directory we store the generic licenses as set in poky.conf
+    generic_directory = bb.data.getVar('COMMON_LICENSE_DIR', d, True)
+    if not generic_directory:
+        raise bb.build.FuncFailed("COMMON_LICENSE_DIR is unset. Please set this in your distro config")
+
+    try:
+        # Let's try to clean up the packages license directory
+        shutil.rmtree(destdir)
+    except:
+        pass 
+
+    try:
+        # Create the package license directory structure.
+        bb.mkdirhier(destdir)
+    except:
+        pass
+
+    if not lic_files:
+        # No recipe should have an invalid license file. This is checked else
+        # where, but let's be pedantic
+        bb.note(pn + ": Recipe file does not have license file information.")
+        return True
+
+    for url in lic_files.split():
+        (type, host, path, user, pswd, parm) = bb.decodeurl(url)
+        # We want the license file to be copied into the destination
+        srclicfile = os.path.join(srcdir, path)
+        ret = bb.copyfile(srclicfile, os.path.join(destdir, os.path.basename(path)))
+        # If the copy didn't occur, something horrible went wrong and we fail out
+        if ret is False or ret == 0:
+            bb.warn("%s could not be copied for some reason. It may not exist. WARN for now." % srclicfile)
+ 
+    # This takes some explaining.... we now are going to go an try to symlink 
+    # to a generic file. But, with the way LICENSE works, a package can have multiple
+    # licenses. Some of them are, for example, GPLv2+, which means it can use that version
+    # of GPLv2 specified in it's license, or a later version of GPLv2. For the purposes of
+    # what we're doing here, we really don't track license revisions (although we may want to)
+    # So, we strip out the + and link to a generic GPLv2
+    #
+    # That said, there are some entries into LICENSE that either have no generic (bzip, zlib, ICS)
+    # or the LICENSE is messy (Apache 2.0 .... when they mean Apache-2.0). This should be corrected
+    # but it's outside of scope for this.
+    #
+    # Also, you get some clever license fields with logic in the field. 
+    # I'm sure someone has written a logic parser for these fields, but if so, I don't know where it is. 
+    # So what I do is just link to every license mentioned in the license field.
+    
+    for license_type in license_types.replace('&', '').replace('+', '').replace('&', '').replace('(', '').replace(')', '').split():
+        if os.path.isfile(os.path.join(generic_directory, license_type)):
+            gen_lic_dest = os.path.join(bb.data.getVar('LICENSE_DIRECTORY', d, True), "common-licenses")
+            try:
+                bb.mkdirhier(gen_lic_dest)
+            except:
+                pass
+            
+            try:
+                bb.copyfile(os.path.join(generic_directory, license_type), os.path.join(gen_lic_dest, license_type))
+            except:
+                bb.warn("%s: No generic license file exists for: %s at %s" % (pn, license_type, generic_directory))
+                pass 
+            try:
+                os.symlink(os.path.join(gen_lic_dest, license_type), os.path.join(destdir, "generic_" + license_type))
+            except:
+                bb.warn("%s: No generic license file exists for: %s at %s" % (pn, license_type, generic_directory))
+                pass
+        else:
+            bb.warn("%s: Something went wrong with copying: %s to %s" % (pn, license_type, generic_directory))
+            bb.warn("This could be either because we do not have a generic for this license or the LICENSE field is incorrect")
+            pass
+}
meta/conf/distro/poky.conf +3 -1
index 82a5e02..6326eea 100644
@@ -12,7 +12,7 @@ USER_CLASSES ?= ""
 
 PACKAGE_CLASSES ?= "package_ipk"
 INHERIT_INSANE ?= "insane"
-INHERIT += "${PACKAGE_CLASSES} ${USER_CLASSES} debian devshell ${INHERIT_INSANE} sstate"
+INHERIT += "${PACKAGE_CLASSES} ${USER_CLASSES} debian devshell ${INHERIT_INSANE} sstate license"
 # For some reason, this doesn't work
 # TARGET_OS ?= "linux"
 # TARGET_VENDOR ?= "-poky"
@@ -143,6 +143,8 @@ COMMERCIAL_VIDEO_PLUGINS ?= ""
 # COMMERCIAL_VIDEO_PLUGINS ?= "gst-plugins-ugly-mpeg2dec gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse"
 COMMERCIAL_QT ?= ""
 # COMMERCIAL_QT ?= "qmmp"
+# Set of common licenses used for license.bbclass
+COMMON_LICENSE_DIR ??= "${POKYBASE}/meta/files/common-licenses"
 
 
 require conf/distro/include/world-broken.inc
meta/files/common-licenses/Apache-2.0 new file +202 -0

202 lines not on this page · raw message

meta/files/common-licenses/Artistic new file +131 -0

131 lines not on this page · raw message

meta/files/common-licenses/BSD new file +26 -0
new file mode 100644
index 0000000..c7a0aa4
@@ -0,0 +1,26 @@
+Copyright (c) The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
meta/files/common-licenses/GFDL new file +451 -0

451 lines not on this page · raw message

meta/files/common-licenses/GFDL-1.2 new file +397 -0

397 lines not on this page · raw message

meta/files/common-licenses/GFDL-1.3 new file +451 -0

451 lines not on this page · raw message

meta/files/common-licenses/GPL new file +676 -0

676 lines not on this page · raw message

meta/files/common-licenses/GPLv2 new file +339 -0

339 lines not on this page · raw message

meta/files/common-licenses/GPLv3 new file +676 -0

210 lines not on this page · raw message

meta/files/common-licenses/LGPL new file +165 -0

165 lines not on this page · raw message

meta/files/common-licenses/LGPLv2 new file +481 -0

481 lines not on this page · raw message

meta/files/common-licenses/LGPLv2.1 new file +510 -0

510 lines not on this page · raw message

meta/files/common-licenses/LGPLv3 new file +165 -0

165 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.1

Part of the diff is not shown here. View the raw message.