Skip to content

Commit

Permalink
validate: validate_licenses_multiple_values: show different warning
Browse files Browse the repository at this point in the history
* when the license value lists multiple licenses (one of currenly used combinations)
* show a link to REP-0149 format definition which explicitly says:
  "For multiple licenses multiple separate tags must be used."
  but unfortunately it doesn't define how to express e.g.
  dual-license or other more complicated scheme, other than pointing
  to <description> tag.
  "For any explanatory text about licensing caveats, please use the <description> tag."

* e.g. OpenEmbedded supports '&' '|' '(' ')' to express more compilcated scheme:
  http://git.openembedded.org/openembedded-core/tree/meta/lib/oe/license.py?id=8e2d0575e4e7036b5f60e632f377a8ab2b96ead8#n42 )
  but that would require change to Package Manifest Format

Signed-off-by: Martin Jansa <[email protected]>
  • Loading branch information
shr-project committed Nov 6, 2020
1 parent 5f61240 commit 21a07b3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/catkin_pkg/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,25 @@ def map_license_to_more_common_format(lic):
'TODO': 'TODO-CATKIN-PACKAGE-LICENSE'
}.get(lic, None)

def validate_licenses_multiple_values(lic):
"""
Check if the license tag contains multiple license values.
Show warning about using multiple license tags when the
value is one of the listed.
"""
return lic in [
'LGPLv2.1, modified BSD',
'Lesser GPL and Apache License',
'BSD,GPL because of list.h; other files released under BSD,GPL',
'GPL because of list.h; other files released under BSD',
'BSD, some icons are licensed under the GNU Lesser General Public License (LGPL) or Creative Commons Attribution-Noncommercial 3.0 License',
'BSD,LGPL,LGPL (amcl)',
'BSD, GPL',
'BSD, Apache 2.0',
'BSD, LGPL',
'BSD,LGPL,Apache 2.0']

def validate_licenses(licenses, warnings):
for lic in licenses:
if is_valid_spdx_identifier(lic):
Expand All @@ -362,6 +381,9 @@ def validate_licenses(licenses, warnings):
spdx = map_license_to_spdx(lic)
if not spdx:
warnings.append('The license value "%s" cannot be mapped to valid SPDX identifier' % (lic))
if validate_licenses_multiple_values(lic):
warnings.append('The license value "%s" contains multiple licenses, you should use multiple <license> flags instead, '
'see https://www.ros.org/reps/rep-0149.html#license-multiple-but-at-least-one')
elif spdx != lic:
# double check that what we mapped it to, is one of valid SPDX identifiers
if not is_valid_spdx_identifier(spdx):
Expand Down

0 comments on commit 21a07b3

Please sign in to comment.