From 21a07b38074afd2b6aa5a94aa90d472471c56c6c Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Fri, 6 Nov 2020 09:26:04 -0800 Subject: [PATCH] validate: validate_licenses_multiple_values: show different warning * 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 tag. "For any explanatory text about licensing caveats, please use the 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 --- src/catkin_pkg/package.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/catkin_pkg/package.py b/src/catkin_pkg/package.py index 88bfdf3f..426c564d 100644 --- a/src/catkin_pkg/package.py +++ b/src/catkin_pkg/package.py @@ -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): @@ -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 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):