All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [CONSOLIDATED PULL 17/20] archiver.bbclass: Add the function of filtering packages
Date: Wed, 27 Jun 2012 08:43:22 -0700	[thread overview]
Message-ID: <df58d93d9ab6eaecd26ba0b84eea747ab0d71700.1340811559.git.sgw@linux.intel.com> (raw)
In-Reply-To: <cover.1340811559.git.sgw@linux.intel.com>
In-Reply-To: <cover.1340811559.git.sgw@linux.intel.com>

From: Xiaofeng Yan <xiaofeng.yan@windriver.com>

This function can miss packages whose license is in
"COPYLEFT_LICENSE_EXCLUDE" and tarball packages with license in
"COPYLEFT_LICENSE_INCLUDE".

[YOCTO #2473]

Signed-off-by: Xiaofeng Yan <xiaofeng.yan@windriver.com>
---
 meta/classes/archiver.bbclass |   71 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 70 insertions(+), 1 deletions(-)

diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index 083bb1d..2b5404f 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -10,6 +10,68 @@ SOURCE_ARCHIVE_LOG_WITH_SCRIPTS ?= '${@d.getVarFlag('ARCHIVER_MODE', 'log_type')
                                     if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'logs_with_scripts'}'
 SOURCE_ARCHIVE_PACKAGE_TYPE ?= '${@d.getVarFlag('ARCHIVER_MODE','type') \
                                  if d.getVarFlag('ARCHIVER_MODE', 'log_type')!= 'none' else 'tar'}'
+FILTER ?= '${@d.getVarFlag('ARCHIVER_MODE','filter') \
+           if d.getVarFlag('ARCHIVER_MODE', 'filter')!= 'none' else 'no'}'
+
+
+COPYLEFT_LICENSE_INCLUDE ?= 'GPL* LGPL*'
+COPYLEFT_LICENSE_INCLUDE[type] = 'list'
+COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which include licenses'
+
+COPYLEFT_LICENSE_EXCLUDE ?= 'CLOSED Proprietary'
+COPYLEFT_LICENSE_EXCLUDE[type] = 'list'
+COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which exclude licenses'
+
+COPYLEFT_RECIPE_TYPE ?= '${@copyleft_recipe_type(d)}'
+COPYLEFT_RECIPE_TYPE[doc] = 'The "type" of the current recipe (e.g. target, native, cross)'
+
+COPYLEFT_RECIPE_TYPES ?= 'target'
+COPYLEFT_RECIPE_TYPES[type] = 'list'
+COPYLEFT_RECIPE_TYPES[doc] = 'Space separated list of recipe types to include'
+
+COPYLEFT_AVAILABLE_RECIPE_TYPES = 'target native nativesdk cross crosssdk cross-canadian'
+COPYLEFT_AVAILABLE_RECIPE_TYPES[type] = 'list'
+COPYLEFT_AVAILABLE_RECIPE_TYPES[doc] = 'Space separated list of available recipe types'
+
+def copyleft_recipe_type(d):
+    for recipe_type in oe.data.typed_value('COPYLEFT_AVAILABLE_RECIPE_TYPES', d):
+        if oe.utils.inherits(d, recipe_type):
+            return recipe_type
+    return 'target'
+
+def copyleft_should_include(d):
+    """Determine if this recipe's sources should be deployed for compliance"""
+    import ast
+    import oe.license
+    from fnmatch import fnmatchcase as fnmatch
+
+    recipe_type = d.getVar('COPYLEFT_RECIPE_TYPE', True)
+    if recipe_type not in oe.data.typed_value('COPYLEFT_RECIPE_TYPES', d):
+        return False, 'recipe type "%s" is excluded' % recipe_type
+
+    include = oe.data.typed_value('COPYLEFT_LICENSE_INCLUDE', d)
+    exclude = oe.data.typed_value('COPYLEFT_LICENSE_EXCLUDE', d)
+
+    try:
+        is_included, reason = oe.license.is_included(d.getVar('LICENSE', True), include, exclude)
+    except oe.license.LicenseError as exc:
+        bb.fatal('%s: %s' % (d.getVar('PF', True), exc))
+    else:
+        if is_included:
+            return True, 'recipe has included licenses: %s' % ', '.join(reason)
+        else:
+            return False, 'recipe has excluded licenses: %s' % ', '.join(reason)
+
+def tar_filter(d):
+    """Only tarball the packages belonging to COPYLEFT_LICENSE_INCLUDE and miss packages in COPYLEFT_LICENSE_EXCLUDE. Don't tarball any packages when \"FILTER\" is \"no\""""
+    if d.getVar('FILTER', True).upper() == "YES":
+        included, reason = copyleft_should_include(d)
+        if not included:
+                return False
+        else:
+                return True
+    else:
+        return False
 
 def get_bb_inc(d):
 	'''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}'''
@@ -293,7 +355,7 @@ def archive_sources_patches(d,stage_name):
 	import shutil
 
 	check_archiving_type(d)	
-	if not_tarball(d):
+	if not_tarball(d) or tar_filter(d):
 		return
 	
 	source_tar_name = archive_sources(d,stage_name)
@@ -320,6 +382,8 @@ def archive_sources_patches(d,stage_name):
 def archive_scripts_logs(d):
 	'''archive scripts and logs. scripts include .bb and .inc files and logs include stuff in "temp".'''
 
+        if tar_filter(d):
+                return
 	work_dir = d.getVar('WORKDIR', True)
 	temp_dir = os.path.join(work_dir,'temp')
 	source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True)
@@ -340,6 +404,9 @@ def archive_scripts_logs(d):
 
 def dumpdata(d):
 	'''dump environment to "${P}-${PR}.showdata.dump" including all kinds of variables and functions when running a task'''
+
+        if tar_filter(d):
+                return
 	workdir = bb.data.getVar('WORKDIR', d, 1)
 	distro = bb.data.getVar('DISTRO', d, 1)
 	s = d.getVar('S', True)
@@ -367,6 +434,8 @@ def create_diff_gz(d):
 	import shutil
 	import subprocess
 
+        if tar_filter(d):
+                return
 	work_dir = d.getVar('WORKDIR', True)
 	exclude_from = d.getVar('ARCHIVE_EXCLUDE_FROM', True).split()
 	pf = d.getVar('PF', True)
-- 
1.7.7.6




  parent reply	other threads:[~2012-06-27 15:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-27 15:43 [CONSOLIDATED PULL 00/20] Kernel Updates and other fixes Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 01/20] mx: Upgrade to 1.4.6 Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 02/20] mtd-utils: do not stage headers in sysroot Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 03/20] classes/image: Allow openssh empty passwords login Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 04/20] image/core-image: Handle conflicting IMAGE_FEATURES Saul Wold
2012-07-02 22:08   ` Dennis.Yxun
2012-07-02 23:41     ` Lu, Lianhao
2012-06-27 15:43 ` [CONSOLIDATED PULL 05/20] task-core-tools-debug: Added openssh-sftp-server Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 06/20] kern-tools: add buildall and robustness fixes Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 07/20] linux-yocto/3.4: update and categorize configuration options Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 08/20] linux-yocto/3.4: update to v3.4.3 Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 09/20] linux-yocto-rt/3.4: update qemuppc branch Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 10/20] linux-yocto/3.4: -rt build fixes + configuration audit (part2) Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 11/20] systemtap: update to version 1.8 Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 12/20] busybox: add correct ALTERNATIVE_TARGET for init.d/syslog Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 13/20] linux-dtb: add multi-dtb build support Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 14/20] native.bbclass: correct PATH to have native-intercept be prepended Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 15/20] gconf.bbclass: don't register schemas in the install stage Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 16/20] libxml: disable lzma Saul Wold
2012-06-27 15:43 ` Saul Wold [this message]
2012-06-27 15:43 ` [CONSOLIDATED PULL 18/20] local.conf.sample.extended: Add filtering function to archiver.bbclass Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 19/20] bitbake.conf: disable ccache explicitly if it is not enabled Saul Wold
2012-06-27 15:43 ` [CONSOLIDATED PULL 20/20] linux-yocto/3.0: update BSP descriptions to new kern-tools format Saul Wold
2012-07-02  1:01 ` [CONSOLIDATED PULL 00/20] Kernel Updates and other fixes Lu, Lianhao
2012-07-02  8:58   ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df58d93d9ab6eaecd26ba0b84eea747ab0d71700.1340811559.git.sgw@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.