summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-rw-r--r--scripts/lib/recipetool/create.py103
1 files changed, 53 insertions, 50 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index bc5b22b361..6ed4ad0ff7 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -481,51 +481,8 @@ def create_recipe(args):
481 # We need a blank line here so that patch_recipe_lines can rewind before the LICENSE comments 481 # We need a blank line here so that patch_recipe_lines can rewind before the LICENSE comments
482 lines_before.append('') 482 lines_before.append('')
483 483
484 licvalues = guess_license(srctree_use) 484 handled = []
485 lic_files_chksum = [] 485 licvalues = handle_license_vars(srctree_use, lines_before, handled, extravalues, tinfoil.config_data)
486 lic_unknown = []
487 if licvalues:
488 licenses = []
489 for licvalue in licvalues:
490 if not licvalue[0] in licenses:
491 licenses.append(licvalue[0])
492 lic_files_chksum.append('file://%s;md5=%s' % (licvalue[1], licvalue[2]))
493 if licvalue[0] == 'Unknown':
494 lic_unknown.append(licvalue[1])
495 lines_before.append('# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is')
496 lines_before.append('# your responsibility to verify that the values are complete and correct.')
497 if len(licvalues) > 1:
498 lines_before.append('#')
499 lines_before.append('# NOTE: multiple licenses have been detected; if that is correct you should separate')
500 lines_before.append('# these in the LICENSE value using & if the multiple licenses all apply, or | if there')
501 lines_before.append('# is a choice between the multiple licenses. If in doubt, check the accompanying')
502 lines_before.append('# documentation to determine which situation is applicable.')
503 if lic_unknown:
504 lines_before.append('#')
505 lines_before.append('# The following license files were not able to be identified and are')
506 lines_before.append('# represented as "Unknown" below, you will need to check them yourself:')
507 for licfile in lic_unknown:
508 lines_before.append('# %s' % licfile)
509 lines_before.append('#')
510 else:
511 lines_before.append('# Unable to find any files that looked like license statements. Check the accompanying')
512 lines_before.append('# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.')
513 lines_before.append('#')
514 lines_before.append('# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if')
515 lines_before.append('# this is not accurate with respect to the licensing of the software being built (it')
516 lines_before.append('# will not be in most cases) you must specify the correct value before using this')
517 lines_before.append('# recipe for anything other than initial testing/development!')
518 licenses = ['CLOSED']
519 pkg_license = extravalues.pop('LICENSE', None)
520 if pkg_license:
521 if licenses == ['Unknown']:
522 lines_before.append('# NOTE: The following LICENSE value was determined from the original package metadata')
523 licenses = [pkg_license]
524 else:
525 lines_before.append('# NOTE: Original package metadata indicates license is: %s' % pkg_license)
526 lines_before.append('LICENSE = "%s"' % ' '.join(licenses))
527 lines_before.append('LIC_FILES_CHKSUM = "%s"' % ' \\\n '.join(lic_files_chksum))
528 lines_before.append('')
529 486
530 classes = [] 487 classes = []
531 488
@@ -622,9 +579,6 @@ def create_recipe(args):
622 handlers = [item[0] for item in handlers] 579 handlers = [item[0] for item in handlers]
623 580
624 # Apply the handlers 581 # Apply the handlers
625 handled = []
626 handled.append(('license', licvalues))
627
628 if args.binary: 582 if args.binary:
629 classes.append('bin_package') 583 classes.append('bin_package')
630 handled.append('buildsystem') 584 handled.append('buildsystem')
@@ -771,6 +725,55 @@ def create_recipe(args):
771 725
772 return 0 726 return 0
773 727
728def handle_license_vars(srctree, lines_before, handled, extravalues, d):
729 licvalues = guess_license(srctree, d)
730 lic_files_chksum = []
731 lic_unknown = []
732 if licvalues:
733 licenses = []
734 for licvalue in licvalues:
735 if not licvalue[0] in licenses:
736 licenses.append(licvalue[0])
737 lic_files_chksum.append('file://%s;md5=%s' % (licvalue[1], licvalue[2]))
738 if licvalue[0] == 'Unknown':
739 lic_unknown.append(licvalue[1])
740 lines_before.append('# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is')
741 lines_before.append('# your responsibility to verify that the values are complete and correct.')
742 if len(licvalues) > 1:
743 lines_before.append('#')
744 lines_before.append('# NOTE: multiple licenses have been detected; if that is correct you should separate')
745 lines_before.append('# these in the LICENSE value using & if the multiple licenses all apply, or | if there')
746 lines_before.append('# is a choice between the multiple licenses. If in doubt, check the accompanying')
747 lines_before.append('# documentation to determine which situation is applicable.')
748 if lic_unknown:
749 lines_before.append('#')
750 lines_before.append('# The following license files were not able to be identified and are')
751 lines_before.append('# represented as "Unknown" below, you will need to check them yourself:')
752 for licfile in lic_unknown:
753 lines_before.append('# %s' % licfile)
754 lines_before.append('#')
755 else:
756 lines_before.append('# Unable to find any files that looked like license statements. Check the accompanying')
757 lines_before.append('# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.')
758 lines_before.append('#')
759 lines_before.append('# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if')
760 lines_before.append('# this is not accurate with respect to the licensing of the software being built (it')
761 lines_before.append('# will not be in most cases) you must specify the correct value before using this')
762 lines_before.append('# recipe for anything other than initial testing/development!')
763 licenses = ['CLOSED']
764 pkg_license = extravalues.pop('LICENSE', None)
765 if pkg_license:
766 if licenses == ['Unknown']:
767 lines_before.append('# NOTE: The following LICENSE value was determined from the original package metadata')
768 licenses = [pkg_license]
769 else:
770 lines_before.append('# NOTE: Original package metadata indicates license is: %s' % pkg_license)
771 lines_before.append('LICENSE = "%s"' % ' '.join(licenses))
772 lines_before.append('LIC_FILES_CHKSUM = "%s"' % ' \\\n '.join(lic_files_chksum))
773 lines_before.append('')
774 handled.append(('license', licvalues))
775 return licvalues
776
774def get_license_md5sums(d, static_only=False): 777def get_license_md5sums(d, static_only=False):
775 import bb.utils 778 import bb.utils
776 md5sums = {} 779 md5sums = {}
@@ -891,9 +894,9 @@ def crunch_license(licfile):
891 license = crunched_md5sums.get(md5val, None) 894 license = crunched_md5sums.get(md5val, None)
892 return license, md5val, lictext 895 return license, md5val, lictext
893 896
894def guess_license(srctree): 897def guess_license(srctree, d):
895 import bb 898 import bb
896 md5sums = get_license_md5sums(tinfoil.config_data) 899 md5sums = get_license_md5sums(d)
897 900
898 licenses = [] 901 licenses = []
899 licspecs = ['*LICEN[CS]E*', 'COPYING*', '*[Ll]icense*', 'LEGAL*', '[Ll]egal*', '*GPL*', 'README.lic*', 'COPYRIGHT*', '[Cc]opyright*'] 902 licspecs = ['*LICEN[CS]E*', 'COPYING*', '*[Ll]icense*', 'LEGAL*', '[Ll]egal*', '*GPL*', 'README.lic*', 'COPYRIGHT*', '[Cc]opyright*']