SHA256
1
0
forked from pool/rpmlint
rpmlint/suse-spdx-license-exceptions.patch

123 lines
4.7 KiB
Diff
Raw Normal View History

From a7e8eca225a09c08742627af7b0c9bc7db9f44b3 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Wed, 6 Apr 2016 11:29:40 +0200
Subject: [PATCH] Handle SPDX style license exceptions
---
TagsCheck.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -140,6 +140,50 @@ DEFAULT_VALID_LICENSES = (
'Shareware',
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
)
+DEFAULT_VALID_LICENSE_EXCEPTIONS = (
+ '389-exception',
+ 'Autoconf-exception-2.0',
+ 'Autoconf-exception-3.0',
+ 'Bison-exception-2.2',
+ 'Bootloader-exception',
+ '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',
+ 'GPL-3.0-linking-exception',
+ 'GPL-3.0-linking-source-exception',
+ 'GPL-CC-1.0',
+ 'LGPL-3.0-linking-exception',
+ 'LLVM-exception',
+ 'LZMA-exception',
+ 'Libtool-exception',
+ 'Linux-syscall-note',
+ 'Nokia-Qt-exception-1.1',
+ 'OCCT-exception-1.0',
+ 'OCaml-LGPL-linking-exception',
+ 'OpenJDK-assembly-exception-1.0',
+ 'PS-or-PDF-font-exception-20170817',
+ 'Qt-GPL-exception-1.0',
+ 'Qt-LGPL-exception-1.1',
+ 'Qwt-exception-1.0',
+ 'SHL-2.0',
+ 'SHL-2.1',
+ 'Swift-exception',
+ 'Universal-FOSS-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',
@@ -408,6 +452,7 @@ VALID_GROUPS = Config.getOption('ValidGr
if VALID_GROUPS is None: # get defaults from rpm package only if it's not set
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'))
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
changelog_version_regex = re.compile(r'[^>]([^ >]+)\s*$')
@@ -422,6 +467,7 @@ lib_package_regex = re.compile(r'(?:^(?:
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
leading_space_regex = re.compile(r'^\s+')
pkg_config_regex = re.compile(r'^/usr/(?:lib\d*|share)/pkgconfig/')
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
license_regex = re.compile(r'\(([^)]+)\)|\s(?:and|or|AND|OR)\s')
+license_exception_regex = re.compile(r'(\S+)\sWITH\s(\S+)')
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
# () are here for grouping purpose in the regexp
- update to 1.10: * test: Skip fedoradev GPG checks at least for now * test: Refresh fedora* packages on image build * test: Use assertEqual where appropriate, thanks to flake8/hacking * test: Update fedora24 config to fedora26, run it on Travis * Add a new test for tmpfiles.d snippets in the /etc/ tree. * Add new tests for systemd units and udev rules in /etc/ tree * test: Disable hacking for now until it's flake8 3.4+ compatible * test: Set up flake8-bugbear, enable it in fedoradev container * rpmlint: Avoid unused loop control variable * ZipCheck: Add TODO * *: Avoid mutable argument defaults * Be aware of -debugsource packages * rpmdiff: Fix unused variable from previous commit * rpmdiff: Support soft dependencies * BinariesCheck, FilesCheck: Ignore various .build-id dirs * Add python3-devel and rpm-build to fedoradev container to provoke some issues * BinariesCheck: Popen env consistency fix * Pkg.getstatusoutput: Set LC_ALL for all Popens, defaulting to C * rpmlint: Fix checking specfile from stdin * test.sh: Extract rpmlint command to run_rpmlint * Revert "Remove unused spec_lines check_spec argument" * BinariesCheck: Trivial cleanups * travis: Run make install too * FilesCheck: Allow multiple bytecode magic values per Python version * tests: Make output test tools easier to reuse * FilesCheck: hg.python.org -> github.com/python * Pkg: Return vendor and distribution as unicode strings * FilesCheck: Add Python 3.7 bytecode magic value * Pkg.b2s: Add some more test cases OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=482
2017-09-28 13:35:09 +02:00
forbidden_words_regex = re.compile(r'(%s)' % Config.getOption('ForbiddenWords'), re.IGNORECASE)
@@ -795,6 +841,10 @@ class TagsCheck(AbstractCheck.AbstractCh
# printWarning(pkg, 'package-provides-itself')
# break
+ def split_license_exception(license):
+ x, y = license_exception_regex.split(license)[1:3] or (license, "")
+ 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))
@@ -805,7 +855,17 @@ class TagsCheck(AbstractCheck.AbstractCh
else:
valid_license = True
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)
+ valid_license = False
+
+ for l1 in split_license(license_string):
if l1 in VALID_LICENSES:
continue
for l2 in split_license(l1):
@@ -1092,6 +1152,11 @@ your specfile.''',
'''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.