From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mail.openembedded.org (Postfix) with ESMTP id 03348772B8 for ; Thu, 16 Feb 2017 16:42:11 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP; 16 Feb 2017 08:42:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,169,1484035200"; d="scan'208";a="934684906" Received: from alimonb-mobl1.zpn.intel.com ([10.219.128.120]) by orsmga003.jf.intel.com with ESMTP; 16 Feb 2017 08:42:11 -0800 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= To: openembedded-core@lists.openembedded.org Date: Thu, 16 Feb 2017 10:45:32 -0600 Message-Id: <1487263532-10730-2-git-send-email-anibal.limon@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1487263532-10730-1-git-send-email-anibal.limon@linux.intel.com> References: <1487263532-10730-1-git-send-email-anibal.limon@linux.intel.com> MIME-Version: 1.0 Subject: [[PATCHv2][Rebased] 2/2] classes/license.bbclass: Don't copy unneeded licenses by package X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Feb 2017 16:42:12 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usually a recipe only provides one package but when provides more than one package the LICENSE variable per package (i.e. linux-firmware) needs to take into account to avoid unnecesary copy of licenses into packages. The patch validates if LICENSE exists in package LICENSES in order to don't copy unneeded licenses. As result of this patch some packages will not contain licenses there are not into LICENSE variable. For example: acl contains GPLv2+ instead of GPLv2+ and LGPLv2.1+ libacl contains LGPLv2+ instead of GPLv2+ and LGPLv2.1+ This behaviour is declared on the acl recipe as: SUMMARY = "Utilities for managing POSIX Access Control Lists" HOMEPAGE = "http://savannah.nongnu.org/projects/acl/" SECTION = "libs" LICENSE = "LGPLv2.1+ & GPLv2+" LICENSE_${PN} = "GPLv2+" LICENSE_lib${BPN} = "LGPLv2.1+" [YOCTO #10325] Signed-off-by: Aníbal Limón --- meta/classes/license.bbclass | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 2b980c0..bbc578c 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass @@ -131,6 +131,10 @@ def write_license_files(d, license_manifest, pkg_dic): bb.utils.mkdirhier(pkg_rootfs_license_dir) pkg_license_dir = os.path.join(d.getVar('LICENSE_DIRECTORY'), pkg_dic[pkg]["PN"]) + + pkg_manifest_licenses = [canonical_license(d, lic) \ + for lic in pkg_dic[pkg]["LICENSES"]] + licenses = os.listdir(pkg_license_dir) for lic in licenses: rootfs_license = os.path.join(rootfs_license_dir, lic) @@ -138,9 +142,18 @@ def write_license_files(d, license_manifest, pkg_dic): 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 oe.license.license_ok(canonical_license(d, - generic_lic), bad_licenses) == False: + generic_lic = canonical_license(d, + re.search("^generic_(.*)$", lic).group(1)) + + # Do not copy generic license into package if isn't + # declared into LICENSES of the package. + if not re.sub('\+$', '', generic_lic) in \ + [re.sub('\+', '', lic) for lic in \ + pkg_manifest_licenses]: + continue + + if oe.license.license_ok(generic_lic, + bad_licenses) == False: continue if not os.path.exists(rootfs_license): @@ -499,7 +512,6 @@ def find_license_files(d): bb.fatal('%s: %s' % (d.getVar('PF'), exc)) except SyntaxError: bb.warn("%s: Failed to parse it's LICENSE field." % (d.getVar('PF'))) - # Add files from LIC_FILES_CHKSUM to list of license files lic_chksum_paths = defaultdict(OrderedDict) for path, data in lic_chksums.items(): -- 2.1.4