2016-05-19 21:49:57 +02:00
|
|
|
From a7e8eca225a09c08742627af7b0c9bc7db9f44b3 Mon Sep 17 00:00:00 2001
|
2016-04-06 16:18:58 +02:00
|
|
|
From: Dirk Mueller <dirk@dmllr.de>
|
|
|
|
Date: Wed, 6 Apr 2016 11:29:40 +0200
|
|
|
|
Subject: [PATCH] Handle SPDX style license exceptions
|
|
|
|
|
|
|
|
---
|
2016-05-19 21:49:57 +02:00
|
|
|
TagsCheck.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
|
1 file changed, 50 insertions(+), 1 deletion(-)
|
2016-04-06 16:18:58 +02:00
|
|
|
|
2017-09-28 13:35:09 +02:00
|
|
|
Index: rpmlint-rpmlint-1.10/TagsCheck.py
|
2017-01-31 16:01:29 +01:00
|
|
|
===================================================================
|
2017-09-28 13:35:09 +02:00
|
|
|
--- rpmlint-rpmlint-1.10.orig/TagsCheck.py
|
|
|
|
+++ rpmlint-rpmlint-1.10/TagsCheck.py
|
2016-04-06 16:18:58 +02:00
|
|
|
@@ -139,6 +139,34 @@ DEFAULT_VALID_LICENSES = (
|
|
|
|
'Shareware',
|
2017-09-28 13:35:09 +02:00
|
|
|
)
|
2016-04-06 16:18:58 +02:00
|
|
|
|
|
|
|
+DEFAULT_VALID_LICENSE_EXCEPTIONS = (
|
|
|
|
+ '389-exception',
|
|
|
|
+ 'Autoconf-exception-2.0',
|
|
|
|
+ 'Autoconf-exception-3.0',
|
|
|
|
+ 'Bison-exception-2.2',
|
|
|
|
+ 'CLISP-exception-2.0',
|
|
|
|
+ 'Classpath-exception-2.0',
|
|
|
|
+ 'DigiRule-FOSS-exception',
|
|
|
|
+ 'FLTK-exception',
|
|
|
|
+ 'Fawkes-Runtime-exception',
|
|
|
|
+ 'Font-exception-2.0',
|
|
|
|
+ 'GCC-exception-2.0',
|
|
|
|
+ 'GCC-exception-3.1',
|
|
|
|
+ 'LZMA-exception',
|
|
|
|
+ 'Libtool-exception',
|
|
|
|
+ 'Nokia-Qt-exception-1.1',
|
|
|
|
+ 'OCCT-exception-1.0',
|
|
|
|
+ 'Qwt-exception-1.0',
|
|
|
|
+ 'WxWindows-exception-3.1',
|
|
|
|
+ 'eCos-exception-2.0',
|
|
|
|
+ 'freertos-exception-2.0',
|
|
|
|
+ 'gnu-javamail-exception',
|
|
|
|
+ 'i2p-gpl-java-exception',
|
|
|
|
+ 'mif-exception',
|
|
|
|
+ 'openvpn-openssl-exception',
|
|
|
|
+ 'u-boot-exception-2.0',
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
BAD_WORDS = {
|
|
|
|
'alot': 'a lot',
|
|
|
|
'accesnt': 'accent',
|
2017-01-31 16:01:29 +01:00
|
|
|
@@ -404,6 +432,7 @@ VALID_GROUPS = Config.getOption('ValidGr
|
2016-05-19 21:49:57 +02:00
|
|
|
if VALID_GROUPS is None: # get defaults from rpm package only if it's not set
|
2016-04-06 16:18:58 +02:00
|
|
|
VALID_GROUPS = Pkg.get_default_valid_rpmgroups()
|
|
|
|
VALID_LICENSES = Config.getOption('ValidLicenses', DEFAULT_VALID_LICENSES)
|
|
|
|
+VALID_LICENSE_EXCEPTIONS = Config.getOption('ValidLicenseExceptions', DEFAULT_VALID_LICENSE_EXCEPTIONS)
|
|
|
|
INVALID_REQUIRES = map(re.compile, Config.getOption('InvalidRequires', DEFAULT_INVALID_REQUIRES))
|
|
|
|
packager_regex = re.compile(Config.getOption('Packager'))
|
2017-09-28 13:35:09 +02:00
|
|
|
changelog_version_regex = re.compile(r'[^>]([^ >]+)\s*$')
|
|
|
|
@@ -418,6 +447,7 @@ lib_package_regex = re.compile(r'(?:^(?:
|
|
|
|
leading_space_regex = re.compile(r'^\s+')
|
2017-01-31 16:01:29 +01:00
|
|
|
pkg_config_regex = re.compile('^/usr/(?:lib\d*|share)/pkgconfig/')
|
2017-09-28 13:35:09 +02:00
|
|
|
license_regex = re.compile(r'\(([^)]+)\)|\s(?:and|or|AND|OR)\s')
|
2016-04-06 16:18:58 +02:00
|
|
|
+license_exception_regex = re.compile('(\S+)\sWITH\s(\S+)')
|
2017-09-28 13:35:09 +02:00
|
|
|
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
|
2016-04-06 16:18:58 +02:00
|
|
|
# () are here for grouping purpose in the regexp
|
2017-09-28 13:35:09 +02:00
|
|
|
forbidden_words_regex = re.compile(r'(%s)' % Config.getOption('ForbiddenWords'), re.IGNORECASE)
|
|
|
|
@@ -788,6 +818,10 @@ class TagsCheck(AbstractCheck.AbstractCh
|
2016-04-06 16:18:58 +02:00
|
|
|
# printWarning(pkg, 'package-provides-itself')
|
|
|
|
# break
|
|
|
|
|
|
|
|
+ def split_license_exception(license):
|
2016-04-12 09:31:50 +02:00
|
|
|
+ x, y = license_exception_regex.split(license)[1:3] or (license, "")
|
2016-04-06 16:18:58 +02:00
|
|
|
+ return x.strip(), y.strip()
|
|
|
|
+
|
|
|
|
def split_license(license):
|
|
|
|
return (x.strip() for x in
|
|
|
|
(l for l in license_regex.split(license) if l))
|
2017-09-28 13:35:09 +02:00
|
|
|
@@ -798,7 +832,17 @@ class TagsCheck(AbstractCheck.AbstractCh
|
2016-04-06 16:18:58 +02:00
|
|
|
else:
|
2016-05-19 21:49:57 +02:00
|
|
|
valid_license = True
|
2016-04-06 16:18:58 +02:00
|
|
|
if rpm_license not in VALID_LICENSES:
|
|
|
|
- for l1 in split_license(rpm_license):
|
|
|
|
+ license_string = rpm_license
|
|
|
|
+
|
|
|
|
+ l1, lexception = split_license_exception(rpm_license)
|
|
|
|
+ # SPDX allows "<license> WITH <license-exception>"
|
|
|
|
+ if lexception:
|
|
|
|
+ license_string = l1
|
|
|
|
+ if lexception not in VALID_LICENSE_EXCEPTIONS:
|
|
|
|
+ printWarning(pkg, 'invalid-license-exception', lexception)
|
2016-05-19 21:49:57 +02:00
|
|
|
+ valid_license = False
|
2016-04-06 16:18:58 +02:00
|
|
|
+
|
|
|
|
+ for l1 in split_license(license_string):
|
|
|
|
if l1 in VALID_LICENSES:
|
|
|
|
continue
|
|
|
|
for l2 in split_license(l1):
|
2017-09-28 13:35:09 +02:00
|
|
|
@@ -1074,6 +1118,11 @@ your specfile.''',
|
2016-04-06 16:18:58 +02:00
|
|
|
'''The value of the License tag was not recognized. Known values are:
|
|
|
|
"%s".''' % '", "'.join(VALID_LICENSES),
|
|
|
|
|
|
|
|
+'invalid-license-exception',
|
|
|
|
+'''The ' WITH <x> ' license exception of the License tag was not recognized.
|
|
|
|
+Known values are:
|
|
|
|
+"%s".''' % '", "'.join(VALID_LICENSE_EXCEPTIONS),
|
|
|
|
+
|
|
|
|
'obsolete-not-provided',
|
|
|
|
'''If a package is obsoleted by a compatible replacement, the obsoleted package
|
|
|
|
should also be provided in order to not cause unnecessary dependency breakage.
|