Skip to contentSkip to conversation

license_class: Added support for LICENSE_PRIORITY in manifest creation

PATCH New Aníbal Limón 1 participant 9 messages Nov 4, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover license_class: Added support for LICENSE_PRIORITY in manifest creation

The major change is when you have OR'ed LICENSE only one is choose according LICENSE_PRIORITY preferences if LICENSE_PRIORITY isn't specified the left one is choosen.

Some minor changes was done in the core/packagegroups and glibc-locale recipes adding LIC_FILES_CHECKSUM to avoid warnings in manifest creation.

The test was done building qemux86/core-image-sato with and without these set of patches and then run diff recursive under common-licenses created directory.

You can find a tarball with common-license directories, resulted diff and local.conf at:

https://bugzilla.yoctoproject.org/attachment.cgi?id=2223

Aníbal Limón (8):
license_class: Reimplemented manifest creation in python
license_class: Added support for INCOMPATIBLE_LICENSE into
license_create_manifest
license_class: Added LICENSE_PRIORITY support
license_class: Fix remove + trim in license_create_manifest.
license_class: license_manifest_creation improvment copying licenses
to target
license_class: license_create_manifest improve package file read
packagegropups: Added LIC_FILES_CHKSUM with MIT license to avoid
warning when create license manifest.
glibc-locale: Added LIC_FILES_CHKSUM for avoid warnings in license
manifest creation.

 meta/classes/license.bbclass                       | 236 +++++++++++++--------
 meta/conf/documentation.conf                       |   1 +
 meta/recipes-core/glibc/glibc-collateral.inc       |   2 +
 .../nativesdk-packagegroup-sdk-host.bb             |   1 +
 .../packagegroups/packagegroup-base.bb             |   1 +
 .../packagegroups/packagegroup-core-boot.bb        |   1 +
 .../packagegroup-core-buildessential.bb            |   1 +
 .../packagegroup-core-eclipse-debug.bb             |   1 +
 .../packagegroups/packagegroup-core-nfs.bb         |   1 +
 .../packagegroups/packagegroup-core-sdk.bb         |   1 +
 .../packagegroup-core-ssh-dropbear.bb              |   1 +
 .../packagegroups/packagegroup-core-ssh-openssh.bb |   1 +
 .../packagegroup-core-standalone-sdk-target.bb     |   1 +
 .../packagegroups/packagegroup-core-tools-debug.bb |   1 +
 .../packagegroup-core-tools-profile.bb             |   1 +
 .../packagegroup-core-tools-testapps.bb            |   1 +
 .../packagegroups/packagegroup-cross-canadian.bb   |   1 +
 .../packagegroups/packagegroup-self-hosted.bb      |   1 +
 .../packagegroup-core-device-devel.bb              |   1 +
 .../packagegroup-core-full-cmdline.bb              |   1 +
 .../packagegroups/packagegroup-core-lsb.bb         |   1 +
 .../packagegroups/packagegroup-core-clutter.bb     |   1 +
 .../packagegroups/packagegroup-core-directfb.bb    |   1 +
 .../packagegroups/packagegroup-core-x11-base.bb    |   1 +
 .../packagegroups/packagegroup-core-x11-xserver.bb |   1 +
 .../packagegroups/packagegroup-core-x11.bb         |   1 +
 .../nativesdk-packagegroup-qt-toolchain-host.inc   |   1 +
 .../packagegroups/packagegroup-core-qt.bb          |   1 +
 .../packagegroups/packagegroup-core-qt4e.bb        |   1 +
 .../packagegroup-qt-toolchain-target.inc           |   1 +
 .../packagegroups/packagegroup-core-x11-sato.bb    |   1 +
 31 files changed, 180 insertions(+), 87 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/8 license_class: Reimplemented manifest creation in python

Reimplemented license_manifest_create from shell to python, in order to use oe.license module for handle INCOMPATIBLE_LICENSE and add License prorities into OR's evaluation.

---
 meta/classes/license.bbclass | 161 ++++++++++++++++++++++++-------------------
 1 file changed, 90 insertions(+), 71 deletions(-)
meta/classes/license.bbclass +90 -71
index a34ea39..c8a86ce 100644
@@ -25,78 +25,97 @@ python write_package_manifest() {
         'w+').write(image_list_installed_packages(d))
 }
 
-license_create_manifest() {
-        # Test if BUILD_IMAGES_FROM_FEEDS is defined in env
-        if [ -n "${BUILD_IMAGES_FROM_FEEDS}" ]; then
-          exit 0
-        fi
-
-	INSTALLED_PKGS=`cat ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest`
-	LICENSE_MANIFEST="${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest"
-	# remove existing license.manifest file
-	if [ -f ${LICENSE_MANIFEST} ]; then
-		rm ${LICENSE_MANIFEST}
-	fi
-	touch ${LICENSE_MANIFEST}
-	for pkg in ${INSTALLED_PKGS}; do
-		filename=`ls ${PKGDATA_DIR}/runtime-reverse/${pkg}| head -1`
-		pkged_pn="$(sed -n 's/^PN: //p' ${filename})"
-
-		# check to see if the package name exists in the manifest. if so, bail.
-		if grep -q "^PACKAGE NAME: ${pkg}" ${LICENSE_MANIFEST}; then
-			continue
-		fi
-
-		pkged_pv="$(sed -n 's/^PV: //p' ${filename})"
-		pkged_name="$(basename $(readlink ${filename}))"
-		pkged_lic="$(sed -n "/^LICENSE_${pkged_name}: /{ s/^LICENSE_${pkged_name}: //; s/[|&()*]/ /g; s/  */ /g; p }" ${filename})"
-		if [ -z ${pkged_lic} ]; then
-			# fallback checking value of LICENSE
-			pkged_lic="$(sed -n "/^LICENSE: /{ s/^LICENSE: //; s/[|&()*]/ /g; s/  */ /g; p }" ${filename})"
-		fi
-
-		echo "PACKAGE NAME:" ${pkg} >> ${LICENSE_MANIFEST}
-		echo "PACKAGE VERSION:" ${pkged_pv} >> ${LICENSE_MANIFEST}
-		echo "RECIPE NAME:" ${pkged_pn} >> ${LICENSE_MANIFEST}
-		printf "LICENSE:" >> ${LICENSE_MANIFEST}
-		for lic in ${pkged_lic}; do
-			# to reference a license file trim trailing + symbol
-			if ! [ -e "${LICENSE_DIRECTORY}/${pkged_pn}/generic_${lic%+}" ]; then
-				bbwarn "The license listed ${lic} was not in the licenses collected for ${pkged_pn}"
-			fi
-                        printf " ${lic}" >> ${LICENSE_MANIFEST}
-		done
-		printf "\n\n" >> ${LICENSE_MANIFEST}
-	done
-
-	# Two options here:
-	# - Just copy the manifest
-	# - Copy the manifest and the license directories
-	# With both options set we see a .5 M increase in core-image-minimal
-	if [ "${COPY_LIC_MANIFEST}" = "1" ]; then
-		mkdir -p ${IMAGE_ROOTFS}/usr/share/common-licenses/
-		cp ${LICENSE_MANIFEST} ${IMAGE_ROOTFS}/usr/share/common-licenses/license.manifest
-		if [ "${COPY_LIC_DIRS}" = "1" ]; then
-			for pkg in ${INSTALLED_PKGS}; do
-				mkdir -p ${IMAGE_ROOTFS}/usr/share/common-licenses/${pkg}
-				pkged_pn="$(oe-pkgdata-util lookup-recipe ${PKGDATA_DIR} ${pkg})"
-				for lic in `ls ${LICENSE_DIRECTORY}/${pkged_pn}`; do
-					# Really don't need to copy the generics as they're 
-					# represented in the manifest and in the actual pkg licenses
-					# Doing so would make your image quite a bit larger
-					if [ "${lic#generic_}" = "${lic}" ]; then
-						cp ${LICENSE_DIRECTORY}/${pkged_pn}/${lic} ${IMAGE_ROOTFS}/usr/share/common-licenses/${pkg}/${lic}
-					else
-						if [ ! -f ${IMAGE_ROOTFS}/usr/share/common-licenses/${lic} ]; then
-							cp ${LICENSE_DIRECTORY}/${pkged_pn}/${lic} ${IMAGE_ROOTFS}/usr/share/common-licenses/
-						fi
-						ln -sf ../${lic} ${IMAGE_ROOTFS}/usr/share/common-licenses/${pkg}/${lic}
-					fi
-				done
-			done
-		fi
-	fi
+python license_create_manifest() {
+    import shutil
+    import re
 
+    build_images_from_feeds = d.getVar('BUILD_IMAGES_FROM_FEEDS', True)
+    if build_images_from_feeds == "1":
+        return 0
+
+    pkg_dic = {}
+    package_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
+                        d.getVar('IMAGE_NAME', True), 'package.manifest')
+    with open(package_manifest, "r") as package_file:
+        pkg_list = package_file.read().split()
+        for pkg in pkg_list:
+            pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True),
+                                    'runtime-reverse', pkg)
+            with open(pkg_info, "r") as pkg_info_file:
+                pkg_dic[pkg] = {}
+
+                pkg_lic_name = os.path.basename(os.readlink(pkg_info))
+
+                for line in pkg_info_file.read().split("\n"):
+                    if re.match("^PN: .*$", line):
+                        pkg_dic[pkg]["PN"] = re.search("PN: (.*)$", line).group(1)
+
+                    if re.match("^PV: .*$", line):
+                        pkg_dic[pkg]["PV"] = re.search("PV: (.*)$", line).group(1)
+
+                    if re.match("^LICENSE_%s: (.*)$" % re.escape(pkg_lic_name)
+                                , line):
+                        pkg_dic[pkg]["LICENSE"] = re.search("^LICENSE_%s: (.*)$"
+                                    % pkg_lic_name, line).group(1)
+                    elif re.match("^LICENSE: (.*)$", line):
+                        pkg_dic[pkg]["LICENSE"] = re.search("^LICENSE: (.*)$",
+                                    line).group(1)
+
+    license_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
+                        d.getVar('IMAGE_NAME', True), 'license.manifest')
+    with open(license_manifest, "w") as license_file:
+        for pkg in sorted(pkg_dic):
+            license_file.write("PACKAGE NAME: %s\n" % pkg)
+            license_file.write("PACKAGE VERSION: %s\n" % pkg_dic[pkg]["PV"])
+            license_file.write("RECIPE NAME: %s\n" % pkg_dic[pkg]["PN"])
+            license_file.write("LICENSE:")
+
+            licenses = re.sub('[|&()*]', '', pkg_dic[pkg]["LICENSE"])
+            licenses = re.sub('  *', ' ', licenses)
+            for lic in licenses.split():
+                lic = re.sub('\+', '', lic)
+                lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
+                                        pkg_dic[pkg]["PN"], "generic_%s" % lic)
+                if not os.path.exists(lic_file):
+                   bb.warn("The license listed %s was not in the "\ 
+                            "licenses collected for recipe %s" 
+                            % (lic, pkg_dic[pkg]["PN"]))
+                license_file.write(" %s" % lic)
+            license_file.write("\n\n")
+
+    # Two options here:
+    # - Just copy the manifest
+    # - Copy the manifest and the license directories
+    # With both options set we see a .5 M increase in core-image-minimal
+    copy_lic_manifest = d.getVar('COPY_LIC_MANIFEST', True)
+    copy_lic_dirs = d.getVar('COPY_LIC_DIRS', True)
+    if copy_lic_manifest == "1":
+        rootfs_license_dir = os.path.join(d.getVar('IMAGE_ROOTFS', 'True'), 
+                                'usr', 'share', 'common-licenses')
+        os.makedirs(rootfs_license_dir)
+        rootfs_license_manifest = os.path.join(rootfs_license_dir,
+                                                'license.manifest')
+        shutil.copyfile(license_manifest, rootfs_license_manifest)
+
+        if copy_lic_dirs == "1":
+            for pkg in sorted(pkg_dic):
+                pkg_rootfs_license_dir = os.path.join(rootfs_license_dir, pkg)
+                os.makedirs(pkg_rootfs_license_dir)
+                pkg_license_dir = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
+                                            pkg_dic[pkg]["PN"]) 
+                licenses = os.listdir(pkg_license_dir)
+                for lic in licenses:
+                    rootfs_license = os.path.join(rootfs_license_dir, lic)
+                    pkg_license = os.path.join(pkg_license_dir, lic)
+                    pkg_rootfs_license = os.path.join(pkg_rootfs_license_dir, lic)
+
+                    if re.match("^generic_.*$", lic):
+                        if not os.path.exists(pkg_rootfs_license):
+                            shutil.copyfile(pkg_license, rootfs_license)
+
+                        os.symlink(os.path.join('..', lic), pkg_rootfs_license)
+                    else:
+                        shutil.copyfile(pkg_license, pkg_rootfs_license)
 }
 
 python do_populate_lic() {
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/8 license_class: Added support for INCOMPATIBLE_LICENSE into license_create_manifest

In reply to Aníbal Limón

Now license_create_manifest handle INCOMPATIBLE_LICENSE to avoid put them into license.manifest and copy them into target image.

Generalized license_ok(license) to license_ok(bad_licenses, license) to avoid duplicate code.

[YOCTO #6765]

---
 meta/classes/license.bbclass | 60 ++++++++++++++++++++++++++++++--------------
 1 file changed, 41 insertions(+), 19 deletions(-)
meta/classes/license.bbclass +41 -19
index c8a86ce..c11ef1c 100644
@@ -28,6 +28,15 @@ python write_package_manifest() {
 python license_create_manifest() {
     import shutil
     import re
+    import oe.license
+
+    bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
+    bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
+
+    # Handles an "or" or two license sets provided by
+    # flattened_licenses(), pick one that works if possible.
+    def choose_lic_set(a, b):
+        return a if all(license_ok(bad_licenses, lic) for lic in a) else b
 
     build_images_from_feeds = d.getVar('BUILD_IMAGES_FROM_FEEDS', True)
     if build_images_from_feeds == "1":
@@ -70,9 +79,13 @@ python license_create_manifest() {
             license_file.write("RECIPE NAME: %s\n" % pkg_dic[pkg]["PN"])
             license_file.write("LICENSE:")
 
-            licenses = re.sub('[|&()*]', '', pkg_dic[pkg]["LICENSE"])
-            licenses = re.sub('  *', ' ', licenses)
-            for lic in licenses.split():
+            try:
+                licenses = oe.license.flattened_licenses(pkg_dic[pkg]["LICENSE"]
+                            , choose_lic_set)
+            except oe.license.LicenseError as exc:
+                bb.fatal('%s: %s' % (d.getVar('P', True), exc))
+
+            for lic in licenses:
                 lic = re.sub('\+', '', lic)
                 lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
                                         pkg_dic[pkg]["PN"], "generic_%s" % lic)
@@ -110,11 +123,18 @@ python license_create_manifest() {
                     pkg_rootfs_license = os.path.join(pkg_rootfs_license_dir, lic)
 
                     if re.match("^generic_.*$", lic):
+                        generic_lic = re.search("^generic_(.*)$", lic).group(1)
+                        if not license_ok(bad_licenses, generic_lic):
+                            continue
+
                         if not os.path.exists(pkg_rootfs_license):
                             shutil.copyfile(pkg_license, rootfs_license)
 
                         os.symlink(os.path.join('..', lic), pkg_rootfs_license)
                     else:
+                        if not license_ok(bad_licenses, lic):
+                            continue
+
                         shutil.copyfile(pkg_license, pkg_rootfs_license)
 }
 
@@ -297,6 +317,21 @@ def canonical_license(d, license):
     """
     return d.getVarFlag('SPDXLICENSEMAP', license, True) or license
 
+def license_ok(dont_want_licenses, license):
+    import re
+    from fnmatch import fnmatchcase as fnmatch
+    for dwl in dont_want_licenses:
+        # If you want to exclude license named generically 'X', we
+        # surely want to exclude 'X+' as well.  In consequence, we
+        # will exclude a trailing '+' character from LICENSE in
+        # case INCOMPATIBLE_LICENSE is not a 'X+' license.
+        lic = license
+        if not re.search('\+$', dwl):
+            lic = re.sub('\+', '', license)
+        if fnmatch(lic, dwl):
+            return False
+    return True
+
 def incompatible_license(d, dont_want_licenses, package=None):
     """
     This function checks if a recipe has only incompatible licenses. It also
@@ -305,34 +340,21 @@ def incompatible_license(d, dont_want_licenses, package=None):
     """
     import re
     import oe.license
-    from fnmatch import fnmatchcase as fnmatch
     license = d.getVar("LICENSE_%s" % package, True) if package else None
     if not license:
         license = d.getVar('LICENSE', True)
 
-    def license_ok(license):
-        for dwl in dont_want_licenses:
-            # If you want to exclude license named generically 'X', we
-            # surely want to exclude 'X+' as well.  In consequence, we
-            # will exclude a trailing '+' character from LICENSE in
-            # case INCOMPATIBLE_LICENSE is not a 'X+' license.
-            lic = license
-            if not re.search('\+$', dwl):
-                lic = re.sub('\+', '', license)
-            if fnmatch(lic, dwl):
-                return False
-        return True
-
     # Handles an "or" or two license sets provided by
     # flattened_licenses(), pick one that works if possible.
     def choose_lic_set(a, b):
-        return a if all(license_ok(lic) for lic in a) else b
+        return a if all(license_ok(dont_want_licenses, lic) for lic in a) else b
 
     try:
         licenses = oe.license.flattened_licenses(license, choose_lic_set)
     except oe.license.LicenseError as exc:
         bb.fatal('%s: %s' % (d.getVar('P', True), exc))
-    return any(not license_ok(canonical_license(d, l)) for l in licenses)
+    return any(not license_ok(dont_want_licenses,canonical_license(d, l))
+                for l in licenses)
 
 def check_license_flags(d):
     """
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/8 license_class: Added LICENSE_PRIORITY support

In reply to Aníbal Limón

Now you can specify LICENSE_PRIORITY for license manifest creation.

This means that if you have LICENSE expression with OR's only one license is selected based on LICENSE_PRIORITY and INCOMPATIBLE_LICENSE.

[YOCTO #6757]

---
 meta/classes/license.bbclass | 47 ++++++++++++++++++++++++++++++++++++++------
 meta/conf/documentation.conf |  1 +
 2 files changed, 42 insertions(+), 6 deletions(-)
meta/classes/license.bbclass +41 -6
index c11ef1c..a055660 100644
@@ -33,10 +33,45 @@ python license_create_manifest() {
     bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
     bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
 
+    priority_licenses = (d.getVar("LICENSE_PRIORITY", True) or "").split()
+    priority_licenses = map(lambda l: canonical_license(d, l), priority_licenses)
+    priority_licenses.reverse()
+
+    # Get license priority based on index,
+    # INCOMPATIBLE_LICENSE entries have negative weight.
+    # Licenses not listed have a weight of 0.
+    # LICENSE_PRIORITY entries have a positive weight.
+    def get_license_priority(license):
+        # If you want to exclude license named generically 'X', we
+        # surely want to exclude 'X+' as well.  In consequence, we
+        # will exclude a trailing '+' character from LICENSE in
+        # case INCOMPATIBLE_LICENSE is not a 'X+' license.
+        for bl in bad_licenses:
+            lic = license
+            if not re.search('\+$', bl):
+                lic = re.sub('\+', '', license)
+
+            if lic == bl:
+                return -1 * (bad_licenses.index(lic) + 1)
+
+        if license in priority_licenses:
+            return priority_licenses.index(license) + 1
+        else:
+            return 0
+
     # Handles an "or" or two license sets provided by
-    # flattened_licenses(), pick one that works if possible.
-    def choose_lic_set(a, b):
-        return a if all(license_ok(bad_licenses, lic) for lic in a) else b
+    # flattened_licenses(), pick one that works based on
+    # LICENSE_PRIORITY and INCOMPATIBLE_LICENSE.
+    def choose_lic_set(alpha, beta):
+        alpha_canonical = [canonical_license(d, l) for l in alpha]
+        beta_canonical = [canonical_license(d, l) for l in beta]
+        alpha_weight = sum(get_license_priority(a) for a in alpha_canonical)
+        beta_weight = sum(get_license_priority(b) for b in beta_canonical)
+
+        if alpha_weight >= beta_weight:
+            return alpha
+        else:
+            return beta
 
     build_images_from_feeds = d.getVar('BUILD_IMAGES_FROM_FEEDS', True)
     if build_images_from_feeds == "1":
@@ -80,12 +115,12 @@ python license_create_manifest() {
             license_file.write("LICENSE:")
 
             try:
-                licenses = oe.license.flattened_licenses(pkg_dic[pkg]["LICENSE"]
-                            , choose_lic_set)
+                pkg_dic[pkg]["FLATTENED_LICENSE"] = oe.license.flattened_licenses(
+                            pkg_dic[pkg]["LICENSE"], choose_lic_set)
             except oe.license.LicenseError as exc:
                 bb.fatal('%s: %s' % (d.getVar('P', True), exc))
 
-            for lic in licenses:
+            for lic in pkg_dic[pkg]["FLATTENED_LICENSE"]:
                 lic = re.sub('\+', '', lic)
                 lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
                                         pkg_dic[pkg]["PN"], "generic_%s" % lic)
meta/conf/documentation.conf +1 -0
index 66ec093..d2b3057 100644
@@ -220,6 +220,7 @@ IMAGE_ROOTFS_SIZE[doc] = "Defines the size in Kbytes for the generated image."
 IMAGE_TYPES[doc] = "Specifies the complete list of supported image types by default."
 INC_PR[doc] = "Helps define the recipe revision for recipes that share a common include file."
 INCOMPATIBLE_LICENSE[doc] = "Specifies a space-separated list of license names (as they would appear in LICENSE) that should be excluded from the build."
+LICENSE_PRIORITY[doc] = "Space separated list of licenses in priority order, highest to lowest."
 INHIBIT_DEFAULT_DEPS[doc] = "Prevents the default dependencies, namely the C compiler and standard C library (libc), from being added to DEPENDS."
 INHIBIT_PACKAGE_STRIP[doc] = "If set to "1", causes the build to not strip binaries in resulting packages."
 INHERIT[doc] = "Causes the named class to be inherited at this point during parsing. The variable is only valid in configuration files."
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 4/8 license_class: Fix remove + trim in license_create_manifest.

In reply to Aníbal Limón
---
 meta/classes/license.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/license.bbclass +2 -2
index a055660..74de364 100644
@@ -121,9 +121,9 @@ python license_create_manifest() {
                 bb.fatal('%s: %s' % (d.getVar('P', True), exc))
 
             for lic in pkg_dic[pkg]["FLATTENED_LICENSE"]:
-                lic = re.sub('\+', '', lic)
                 lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
-                                        pkg_dic[pkg]["PN"], "generic_%s" % lic)
+                                        pkg_dic[pkg]["PN"], "generic_%s" %
+                                        re.sub('\+', '', lic))
                 if not os.path.exists(lic_file):
                    bb.warn("The license listed %s was not in the "\ 
                             "licenses collected for recipe %s" 
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 5/8 license_class: license_manifest_creation improvment copying licenses to target

In reply to Aníbal Limón

Do a hardlink for license.manifest and licenses instead of copy this helps in reduce disk usage when rootfs is built.

---
 meta/classes/license.bbclass | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
meta/classes/license.bbclass +4 -5
index 74de364..f2dd0eb 100644
@@ -26,7 +26,6 @@ python write_package_manifest() {
 }
 
 python license_create_manifest() {
-    import shutil
     import re
     import oe.license
 
@@ -143,7 +142,7 @@ python license_create_manifest() {
         os.makedirs(rootfs_license_dir)
         rootfs_license_manifest = os.path.join(rootfs_license_dir,
                                                 'license.manifest')
-        shutil.copyfile(license_manifest, rootfs_license_manifest)
+        os.link(license_manifest, rootfs_license_manifest)
 
         if copy_lic_dirs == "1":
             for pkg in sorted(pkg_dic):
@@ -162,15 +161,15 @@ python license_create_manifest() {
                         if not license_ok(bad_licenses, generic_lic):
                             continue
 
-                        if not os.path.exists(pkg_rootfs_license):
-                            shutil.copyfile(pkg_license, rootfs_license)
+                        if not os.path.exists(rootfs_license):
+                            os.link(pkg_license, rootfs_license)
 
                         os.symlink(os.path.join('..', lic), pkg_rootfs_license)
                     else:
                         if not license_ok(bad_licenses, lic):
                             continue
 
-                        shutil.copyfile(pkg_license, pkg_rootfs_license)
+                        os.link(pkg_license, pkg_rootfs_license)
 }
 
 python do_populate_lic() {
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 6/8 license_class: license_create_manifest improve package file read

In reply to Aníbal Limón

Improved package file read using oe.packagedata.read_pkgdatafile instead of doing itself.

---
 meta/classes/license.bbclass | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
meta/classes/license.bbclass +5 -18
index f2dd0eb..d462b0a 100644
@@ -28,6 +28,7 @@ python write_package_manifest() {
 python license_create_manifest() {
     import re
     import oe.license
+    import oe.packagedata
 
     bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
     bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
@@ -84,25 +85,11 @@ python license_create_manifest() {
         for pkg in pkg_list:
             pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True),
                                     'runtime-reverse', pkg)
-            with open(pkg_info, "r") as pkg_info_file:
-                pkg_dic[pkg] = {}
+            pkg_lic_name = "LICENSE_" + os.path.basename(os.readlink(pkg_info))
 
-                pkg_lic_name = os.path.basename(os.readlink(pkg_info))
-
-                for line in pkg_info_file.read().split("\n"):
-                    if re.match("^PN: .*$", line):
-                        pkg_dic[pkg]["PN"] = re.search("PN: (.*)$", line).group(1)
-
-                    if re.match("^PV: .*$", line):
-                        pkg_dic[pkg]["PV"] = re.search("PV: (.*)$", line).group(1)
-
-                    if re.match("^LICENSE_%s: (.*)$" % re.escape(pkg_lic_name)
-                                , line):
-                        pkg_dic[pkg]["LICENSE"] = re.search("^LICENSE_%s: (.*)$"
-                                    % pkg_lic_name, line).group(1)
-                    elif re.match("^LICENSE: (.*)$", line):
-                        pkg_dic[pkg]["LICENSE"] = re.search("^LICENSE: (.*)$",
-                                    line).group(1)
+            pkg_dic[pkg] = oe.packagedata.read_pkgdatafile(pkg_info)
+            if not "LICENSE" in pkg_dic[pkg].keys():
+               pkg_dic[pkg]["LICENSE"] = pkg_dic[pkg][pkg_lic_name]
 
     license_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
                         d.getVar('IMAGE_NAME', True), 'license.manifest')
Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 7/8 packagegropups: Added LIC_FILES_CHKSUM with MIT license to avoid warning when create license manifest.

In reply to Aníbal Limón
---
 meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb       | 1 +
 meta/recipes-core/packagegroups/packagegroup-base.bb                     | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-boot.bb                | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-buildessential.bb      | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-eclipse-debug.bb       | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-nfs.bb                 | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-sdk.bb                 | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-ssh-dropbear.bb        | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-ssh-openssh.bb         | 1 +
 .../packagegroups/packagegroup-core-standalone-sdk-target.bb             | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-tools-debug.bb         | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-tools-profile.bb       | 1 +
 meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb      | 1 +
 meta/recipes-core/packagegroups/packagegroup-cross-canadian.bb           | 1 +
 meta/recipes-core/packagegroups/packagegroup-self-hosted.bb              | 1 +
 meta/recipes-devtools/packagegroups/packagegroup-core-device-devel.bb    | 1 +
 meta/recipes-extended/packagegroups/packagegroup-core-full-cmdline.bb    | 1 +
 meta/recipes-extended/packagegroups/packagegroup-core-lsb.bb             | 1 +
 meta/recipes-graphics/packagegroups/packagegroup-core-clutter.bb         | 1 +
 meta/recipes-graphics/packagegroups/packagegroup-core-directfb.bb        | 1 +
 meta/recipes-graphics/packagegroups/packagegroup-core-x11-base.bb        | 1 +
 meta/recipes-graphics/packagegroups/packagegroup-core-x11-xserver.bb     | 1 +
 meta/recipes-graphics/packagegroups/packagegroup-core-x11.bb             | 1 +
 .../packagegroups/nativesdk-packagegroup-qt-toolchain-host.inc           | 1 +
 meta/recipes-qt/packagegroups/packagegroup-core-qt.bb                    | 1 +
 meta/recipes-qt/packagegroups/packagegroup-core-qt4e.bb                  | 1 +
 meta/recipes-qt/packagegroups/packagegroup-qt-toolchain-target.inc       | 1 +
 meta/recipes-sato/packagegroups/packagegroup-core-x11-sato.bb            | 1 +
 28 files changed, 28 insertions(+)
meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb +1 -0
index 0c6a530..4e7153d 100644
@@ -5,6 +5,7 @@
 SUMMARY = "Host packages for the standalone SDK or external toolchain"
 PR = "r12"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup nativesdk
 
meta/recipes-core/packagegroups/packagegroup-base.bb +1 -0
index f4b2cd5..455d1b7 100644
@@ -1,5 +1,6 @@
 SUMMARY = "Merge machine and distro options to create a basic machine task/package"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r83"
 
 #
meta/recipes-core/packagegroups/packagegroup-core-boot.bb +1 -0
index 09f5373..8ce4b53 100644
@@ -5,6 +5,7 @@
 SUMMARY = "Minimal boot requirements"
 DESCRIPTION = "The minimal set of packages required to boot the system"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r17"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
meta/recipes-core/packagegroups/packagegroup-core-buildessential.bb +1 -0
index 74ed247..e97522c 100644
@@ -5,6 +5,7 @@
 
 SUMMARY = "Essential build dependencies"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-core/packagegroups/packagegroup-core-eclipse-debug.bb +1 -0
index e7b013d..e67c131 100644
@@ -1,5 +1,6 @@
 SUMMARY = "Remote debugging tools for Eclipse integration"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-core/packagegroups/packagegroup-core-nfs.bb +1 -0
index 247a30e..1d3fb96 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "NFS package groups"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r2"
 
 inherit packagegroup
meta/recipes-core/packagegroups/packagegroup-core-sdk.bb +1 -0
index a544bbd..a674a31 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Software development tools"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r9"
 
 inherit packagegroup
meta/recipes-core/packagegroups/packagegroup-core-ssh-dropbear.bb +1 -0
index e99946f..8b82f80 100644
@@ -1,5 +1,6 @@
 SUMMARY = "Dropbear SSH client/server"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r1"
 
 inherit packagegroup
meta/recipes-core/packagegroups/packagegroup-core-ssh-openssh.bb +1 -0
index 32d20e6..0dba895 100644
@@ -1,5 +1,6 @@
 SUMMARY = "OpenSSH SSH client/server"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r1"
 
 inherit packagegroup
meta/recipes-core/packagegroups/packagegroup-core-standalone-sdk-target.bb +1 -0
index 154a55c..c84f4f4 100644
@@ -1,6 +1,7 @@
 SUMMARY = "Target packages for the standalone SDK"
 PR = "r8"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-core/packagegroups/packagegroup-core-tools-debug.bb +1 -0
index 82347b9..f2783cf 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Debugging tools"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-core/packagegroups/packagegroup-core-tools-profile.bb +1 -0
index 41d2548..155acf7 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Profiling tools"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 PR = "r3"
 
meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb +1 -0
index 33a3eee..2c7254c 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Testing tools/applications"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 PR = "r2"
 
meta/recipes-core/packagegroups/packagegroup-cross-canadian.bb +1 -0
index e3b1c18..c4b474e 100644
@@ -1,6 +1,7 @@
 SUMMARY = "Host SDK package for cross canadian toolchain"
 PN = "packagegroup-cross-canadian-${MACHINE}"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 # Save TRANSLATED_TARGET_ARCH before allarch tramples it
 TRANSLATED_TARGET_ARCH = "${@d.getVar('TUNE_ARCH', True).replace('_', '-')}"
meta/recipes-core/packagegroups/packagegroup-self-hosted.bb +1 -0
index 65aca7f..1fd9a17 100644
@@ -6,6 +6,7 @@ SUMMARY = "Self-hosting"
 DESCRIPTION = "Packages required to run the build system"
 PR = "r13"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-devtools/packagegroups/packagegroup-core-device-devel.bb +1 -0
index e831860..c570be4 100644
@@ -1,5 +1,6 @@
 SUMMARY = "Provides a small set of tools for development on the device"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 PR = "r1"
 
meta/recipes-extended/packagegroups/packagegroup-core-full-cmdline.bb +1 -0
index ad3f240..2f4e2a9 100644
@@ -6,6 +6,7 @@ SUMMARY = "Standard full-featured Linux system"
 DESCRIPTION = "Package group bringing in packages needed for a more traditional full-featured Linux system"
 PR = "r6"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-extended/packagegroups/packagegroup-core-lsb.bb +1 -0
index dd96fbe..d9572cd 100644
@@ -6,6 +6,7 @@ SUMMARY = "Linux Standard Base (LSB)"
 DESCRIPTION = "Packages required to satisfy the Linux Standard Base (LSB) specification"
 PR = "r10"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 inherit packagegroup
 
meta/recipes-graphics/packagegroups/packagegroup-core-clutter.bb +1 -0
index 7540821..b44447a 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Clutter package groups"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 PR = "r6"
 
meta/recipes-graphics/packagegroups/packagegroup-core-directfb.bb +1 -0
index 53dc0ae..b2a5946 100644
@@ -1,5 +1,6 @@
 SUMMARY = "DirectFB without X11"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
meta/recipes-graphics/packagegroups/packagegroup-core-x11-base.bb +1 -0
index 2eff371..ddee3d9 100644
@@ -1,6 +1,7 @@
 SUMMARY = "Basic X11 session"
 DESCRIPTION = "Packages required to set up a basic working X11 session"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r1"
 
 inherit packagegroup
meta/recipes-graphics/packagegroups/packagegroup-core-x11-xserver.bb +1 -0
index 2d68e97..21aee34 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "X11 display server"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r40"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
meta/recipes-graphics/packagegroups/packagegroup-core-x11.bb +1 -0
index fde5144..0200c5e 100644
@@ -3,6 +3,7 @@
 #
 
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r40"
 
 inherit packagegroup
meta/recipes-qt/packagegroups/nativesdk-packagegroup-qt-toolchain-host.inc +1 -0
index a3c275f..787a98d 100644
@@ -2,5 +2,6 @@ require recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb
 
 DESCRIPTION = "Host packages for Qt Embedded SDK"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 RDEPENDS_${PN} += "nativesdk-qt4-tools"
meta/recipes-qt/packagegroups/packagegroup-core-qt.bb +1 -0
index d28e032..b1b4e7e 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Qt package groups"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r4"
 
 # Qt4 could NOT be built on MIPS64 with 64 bits userspace
meta/recipes-qt/packagegroups/packagegroup-core-qt4e.bb +1 -0
index d7a457c..e6cd9ed 100644
@@ -1,6 +1,7 @@
 SUMMARY = "Qt for Embedded Linux (Qt without X11)"
 PR = "r2"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 # Qt4 could NOT be built on MIPS64 with 64 bits userspace
 COMPATIBLE_HOST_mips64 = "mips64.*-linux-gnun32"
meta/recipes-qt/packagegroups/packagegroup-qt-toolchain-target.inc +1 -0
index fc1ccba..ee0c4b6 100644
@@ -1,4 +1,5 @@
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 # Qt4 could NOT be built on MIPS64 with 64 bits userspace
 COMPATIBLE_HOST_mips64 = "mips64.*-linux-gnun32"
meta/recipes-sato/packagegroups/packagegroup-core-x11-sato.bb +1 -0
index bc3e0fd..da8d5e0 100644
@@ -4,6 +4,7 @@
 
 SUMMARY = "Sato desktop"
 LICENSE = "MIT"
+LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r33"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 8/8 glibc-locale: Added LIC_FILES_CHKSUM for avoid warnings in license manifest creation.

In reply to Aníbal Limón
---
 meta/recipes-core/glibc/glibc-collateral.inc | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-core/glibc/glibc-collateral.inc +2 -0
index 85e06da..e9e411d 100644
@@ -1,5 +1,7 @@
 INHIBIT_DEFAULT_DEPS = "1"
 LICENSE = "GPLv2 & LGPLv2.1"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \
+                    file://${COMMON_LICENSE_DIR}/LGPL-2.1;md5=1a6d268fd218675ffea8be556788b780"
 HOMEPAGE = "http://www.gnu.org/software/libc/index.html"
 
 do_fetch[noexec] = "1"
Signature · 1 line
1.9.1