diff options
| -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) |
