Skip to content

Commit

Permalink
Merge pull request rpm-software-management#1014 from tmzullinger/lice…
Browse files Browse the repository at this point in the history
…nse-exception-in-group

TagsCheck: handle license exception in grouping
  • Loading branch information
marxin committed Mar 6, 2023
2 parents 6dc3cc3 + 7d707f7 commit baf5da0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rpmlint/checks/TagsCheck.py
Expand Up @@ -21,7 +21,7 @@
leading_space_regex = re.compile(r'^\s+')
pkg_config_regex = re.compile(r'^/usr/(?:lib\d*|share)/pkgconfig/')
license_regex = re.compile(r'\(([^)]+)\)|\s(?:and|or|AND|OR)\s')
license_exception_regex = re.compile(r'(\S+)\s(?:WITH|with)\s(\S+)')
license_exception_regex = re.compile(r'(\S+)\s(?:WITH|with)\s([^)]+)')
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
# () are here for grouping purpose in the regexp
tag_regex = re.compile(r'^((?:Auto(?:Req|Prov|ReqProv)|Build(?:Arch(?:itectures)?|Root)|(?:Build)?Conflicts|(?:Build)?(?:Pre)?Requires|Copyright|(?:CVS|SVN)Id|Dist(?:ribution|Tag|URL)|DocDir|(?:Build)?Enhances|Epoch|Exclu(?:de|sive)(?:Arch|OS)|Group|Icon|License|Name|No(?:Patch|Source)|Obsoletes|Packager|Patch\d*|Prefix(?:es)?|Provides|(?:Build)?Recommends|Release|RHNPlatform|Serial|Source\d*|(?:Build)?Suggests|Summary|(?:Build)?Supplements|(?:Bug)?URL|Vendor|Version)(?:\([^)]+\))?:)\s*\S', re.IGNORECASE)
Expand Down
Binary file not shown.
12 changes: 12 additions & 0 deletions test/test_tags.py
Expand Up @@ -77,6 +77,18 @@ def test_valid_license_exception(tmpdir, package, tagscheck):
assert 'W: invalid-license-exception' not in out


@pytest.mark.parametrize('package', ['source/valid-exception-in-grouping'])
def test_valid_license_exception_in_grouping(tmpdir, package, tagscheck):
CONFIG.info = True
CONFIG.configuration['ValidLicenses'] = ['BSD-3-Clause', 'GPL-2.0-only']
CONFIG.configuration['ValidLicenseExceptions'] = ['Qt-GPL-exception-1.0']
output = Filter(CONFIG)
test = TagsCheck(CONFIG, output)
test.check(get_tested_package(package, tmpdir))
out = output.print_results(output.results)
assert 'W: invalid-license-exception' not in out


@pytest.mark.parametrize('package', ['binary/xtables-addons-kmp-default'])
def test_forbidden_controlchar_found_requires(tmpdir, package, tagscheck):
output, test = tagscheck
Expand Down

0 comments on commit baf5da0

Please sign in to comment.