diff options
author | Xiaofeng Yan <xiaofeng.yan@windriver.com> | 2012-06-26 13:59:41 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-28 16:26:44 +0100 |
commit | c3d8b100a2d98770aa977555f11dc70de0a2e1d4 (patch) | |
tree | 9fae887ff1fa0633e1778c8b3ae965a70ef61ed7 | |
parent | fb4a1c88eb4bd93086b542a7fdc8defaac73e08f (diff) | |
download | poky-c3d8b100a2d98770aa977555f11dc70de0a2e1d4.tar.gz |
archiver.bbclass: Add the function of filtering packages
This function can miss packages whose license is in
"COPYLEFT_LICENSE_EXCLUDE" and tarball packages with license in
"COPYLEFT_LICENSE_INCLUDE".
[YOCTO #2473]
(From OE-Core rev: 4800bed394ebd7fb50552a96d6a5f83d98fe790f)
Signed-off-by: Xiaofeng Yan <xiaofeng.yan@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | 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 083bb1dfa5..2b5404f1da 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') | |||
10 | if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'logs_with_scripts'}' | 10 | if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'logs_with_scripts'}' |
11 | SOURCE_ARCHIVE_PACKAGE_TYPE ?= '${@d.getVarFlag('ARCHIVER_MODE','type') \ | 11 | SOURCE_ARCHIVE_PACKAGE_TYPE ?= '${@d.getVarFlag('ARCHIVER_MODE','type') \ |
12 | if d.getVarFlag('ARCHIVER_MODE', 'log_type')!= 'none' else 'tar'}' | 12 | if d.getVarFlag('ARCHIVER_MODE', 'log_type')!= 'none' else 'tar'}' |
13 | FILTER ?= '${@d.getVarFlag('ARCHIVER_MODE','filter') \ | ||
14 | if d.getVarFlag('ARCHIVER_MODE', 'filter')!= 'none' else 'no'}' | ||
15 | |||
16 | |||
17 | COPYLEFT_LICENSE_INCLUDE ?= 'GPL* LGPL*' | ||
18 | COPYLEFT_LICENSE_INCLUDE[type] = 'list' | ||
19 | COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which include licenses' | ||
20 | |||
21 | COPYLEFT_LICENSE_EXCLUDE ?= 'CLOSED Proprietary' | ||
22 | COPYLEFT_LICENSE_EXCLUDE[type] = 'list' | ||
23 | COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which exclude licenses' | ||
24 | |||
25 | COPYLEFT_RECIPE_TYPE ?= '${@copyleft_recipe_type(d)}' | ||
26 | COPYLEFT_RECIPE_TYPE[doc] = 'The "type" of the current recipe (e.g. target, native, cross)' | ||
27 | |||
28 | COPYLEFT_RECIPE_TYPES ?= 'target' | ||
29 | COPYLEFT_RECIPE_TYPES[type] = 'list' | ||
30 | COPYLEFT_RECIPE_TYPES[doc] = 'Space separated list of recipe types to include' | ||
31 | |||
32 | COPYLEFT_AVAILABLE_RECIPE_TYPES = 'target native nativesdk cross crosssdk cross-canadian' | ||
33 | COPYLEFT_AVAILABLE_RECIPE_TYPES[type] = 'list' | ||
34 | COPYLEFT_AVAILABLE_RECIPE_TYPES[doc] = 'Space separated list of available recipe types' | ||
35 | |||
36 | def copyleft_recipe_type(d): | ||
37 | for recipe_type in oe.data.typed_value('COPYLEFT_AVAILABLE_RECIPE_TYPES', d): | ||
38 | if oe.utils.inherits(d, recipe_type): | ||
39 | return recipe_type | ||
40 | return 'target' | ||
41 | |||
42 | def copyleft_should_include(d): | ||
43 | """Determine if this recipe's sources should be deployed for compliance""" | ||
44 | import ast | ||
45 | import oe.license | ||
46 | from fnmatch import fnmatchcase as fnmatch | ||
47 | |||
48 | recipe_type = d.getVar('COPYLEFT_RECIPE_TYPE', True) | ||
49 | if recipe_type not in oe.data.typed_value('COPYLEFT_RECIPE_TYPES', d): | ||
50 | return False, 'recipe type "%s" is excluded' % recipe_type | ||
51 | |||
52 | include = oe.data.typed_value('COPYLEFT_LICENSE_INCLUDE', d) | ||
53 | exclude = oe.data.typed_value('COPYLEFT_LICENSE_EXCLUDE', d) | ||
54 | |||
55 | try: | ||
56 | is_included, reason = oe.license.is_included(d.getVar('LICENSE', True), include, exclude) | ||
57 | except oe.license.LicenseError as exc: | ||
58 | bb.fatal('%s: %s' % (d.getVar('PF', True), exc)) | ||
59 | else: | ||
60 | if is_included: | ||
61 | return True, 'recipe has included licenses: %s' % ', '.join(reason) | ||
62 | else: | ||
63 | return False, 'recipe has excluded licenses: %s' % ', '.join(reason) | ||
64 | |||
65 | def tar_filter(d): | ||
66 | """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\"""" | ||
67 | if d.getVar('FILTER', True).upper() == "YES": | ||
68 | included, reason = copyleft_should_include(d) | ||
69 | if not included: | ||
70 | return False | ||
71 | else: | ||
72 | return True | ||
73 | else: | ||
74 | return False | ||
13 | 75 | ||
14 | def get_bb_inc(d): | 76 | def get_bb_inc(d): |
15 | '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}''' | 77 | '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}''' |
@@ -293,7 +355,7 @@ def archive_sources_patches(d,stage_name): | |||
293 | import shutil | 355 | import shutil |
294 | 356 | ||
295 | check_archiving_type(d) | 357 | check_archiving_type(d) |
296 | if not_tarball(d): | 358 | if not_tarball(d) or tar_filter(d): |
297 | return | 359 | return |
298 | 360 | ||
299 | source_tar_name = archive_sources(d,stage_name) | 361 | source_tar_name = archive_sources(d,stage_name) |
@@ -320,6 +382,8 @@ def archive_sources_patches(d,stage_name): | |||
320 | def archive_scripts_logs(d): | 382 | def archive_scripts_logs(d): |
321 | '''archive scripts and logs. scripts include .bb and .inc files and logs include stuff in "temp".''' | 383 | '''archive scripts and logs. scripts include .bb and .inc files and logs include stuff in "temp".''' |
322 | 384 | ||
385 | if tar_filter(d): | ||
386 | return | ||
323 | work_dir = d.getVar('WORKDIR', True) | 387 | work_dir = d.getVar('WORKDIR', True) |
324 | temp_dir = os.path.join(work_dir,'temp') | 388 | temp_dir = os.path.join(work_dir,'temp') |
325 | source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True) | 389 | source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True) |
@@ -340,6 +404,9 @@ def archive_scripts_logs(d): | |||
340 | 404 | ||
341 | def dumpdata(d): | 405 | def dumpdata(d): |
342 | '''dump environment to "${P}-${PR}.showdata.dump" including all kinds of variables and functions when running a task''' | 406 | '''dump environment to "${P}-${PR}.showdata.dump" including all kinds of variables and functions when running a task''' |
407 | |||
408 | if tar_filter(d): | ||
409 | return | ||
343 | workdir = bb.data.getVar('WORKDIR', d, 1) | 410 | workdir = bb.data.getVar('WORKDIR', d, 1) |
344 | distro = bb.data.getVar('DISTRO', d, 1) | 411 | distro = bb.data.getVar('DISTRO', d, 1) |
345 | s = d.getVar('S', True) | 412 | s = d.getVar('S', True) |
@@ -367,6 +434,8 @@ def create_diff_gz(d): | |||
367 | import shutil | 434 | import shutil |
368 | import subprocess | 435 | import subprocess |
369 | 436 | ||
437 | if tar_filter(d): | ||
438 | return | ||
370 | work_dir = d.getVar('WORKDIR', True) | 439 | work_dir = d.getVar('WORKDIR', True) |
371 | exclude_from = d.getVar('ARCHIVE_EXCLUDE_FROM', True).split() | 440 | exclude_from = d.getVar('ARCHIVE_EXCLUDE_FROM', True).split() |
372 | pf = d.getVar('PF', True) | 441 | pf = d.getVar('PF', True) |