Skip to content

Instantly share code, notes, and snippets.

@marxin
Created August 28, 2019 11:34
Show Gist options
  • Save marxin/4345da142ebf76117b6acd08d015c37e to your computer and use it in GitHub Desktop.
Save marxin/4345da142ebf76117b6acd08d015c37e to your computer and use it in GitHub Desktop.
From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Fri, 10 Apr 2015 14:54:18 +0200
Subject: [PATCH] check for self provides
---
TagsCheck.py | 6 ++++++
1 file changed, 6 insertions(+)
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -874,6 +874,10 @@ class TagsCheck(AbstractCheck.AbstractCh
obs_names = [x[0] for x in pkg.obsoletes()]
prov_names = [x[0].split(':/')[0] for x in pkg.provides()]
+ for p in pkg.provides():
+ if p[0] == pkg.name and not p[1]:
+ printError(pkg, 'unversioned-explicit-self-provides', p[0])
+
for o in (x for x in obs_names if x not in prov_names):
printWarning(pkg, 'obsolete-not-provided', o)
for o in pkg.obsoletes():
@@ -1219,6 +1223,10 @@ objects should thus not be depended on a
in the containing package. Get rid of the provides if appropriate, for example
by filtering it out during build. Note that in some cases this may require
disabling rpmbuild's internal dependency generator.''',
+
+'unversioned-explicit-self-provides',
+'''This package provides it's own name explicitely, which might break
+upgrade path. self-provides are autogenerated. Remove the provide.''',
)
for i in ("obsoletes", "conflicts", "provides", "recommends", "suggests",
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:39 +0200
Subject: [PATCH] devel-provide-is-devel-package.diff
===================================================================
---
FilesCheck.py | 4 ++++
1 file changed, 4 insertions(+)
Index: rpmlint-rpmlint-1.11/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.11/FilesCheck.py
@@ -446,6 +446,10 @@ class FilesCheck(AbstractCheck.AbstractC
# Check if the package is a development package
devel_pkg = devel_regex.search(pkg.name)
+ for p in pkg.provides():
+ if not devel_pkg and devel_regex.search(p[0]):
+ devel_pkg = True
+
config_files = pkg.configFiles()
ghost_files = pkg.ghostFiles()
doc_files = pkg.docFiles()
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:38 +0200
Subject: [PATCH] docdata-examples.diff
===================================================================
---
FilesCheck.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: rpmlint-rpmlint-1.11/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.11/FilesCheck.py
@@ -190,6 +190,7 @@ bin_regex = re.compile(r'^/(?:usr/(?:s?b
includefile_regex = re.compile(r'\.(c|h)(pp|xx)?$', re.IGNORECASE)
develfile_regex = re.compile(r'\.(a|cmxa?|mli?|gir)$')
buildconfigfile_regex = re.compile(r'(\.pc|/bin/.+-config)$')
+docdir_examples_regex = re.compile('^/usr/(?:share/doc/packages|lib(?:64))/[^/]+/(?:example|demo|script|contrib)')
# room for improvement with catching more -R, but also for false positives...
buildconfig_rpath_regex = re.compile(r'(?:-rpath|Wl,-R)\b')
sofile_regex = re.compile(r'/lib(64)?/(.+/)?lib[^/]+\.so$')
@@ -820,7 +821,7 @@ class FilesCheck(AbstractCheck.AbstractC
includefile_regex.search(f) or \
develfile_regex.search(f) or \
logrotate_regex.search(f)
- if nonexec_file:
+ if nonexec_file and not docdir_examples_regex.search(f):
printWarning(pkg, 'spurious-executable-perm', f)
elif f.startswith('/etc/') and f not in config_files and \
f not in ghost_files:
@@ -1196,7 +1197,10 @@ included in your package.''',
'spurious-executable-perm',
'''The file is installed with executable permissions, but was identified as one
that probably should not be executable. Verify if the executable bits are
-desired, and remove if not.''',
+desired, and remove if not.
+NOTE: example scripts should be packaged under %docdir/examples, which will avoid
+this warning.
+''',
'world-writable',
'''A file or directory in the package is installed with world writable
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:40 +0200
Subject: [PATCH] invalid-filerequires.diff
===================================================================
---
TagsCheck.py | 10 ++++++++++
1 file changed, 10 insertions(+)
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -456,6 +456,7 @@ invalid_version_regex = re.compile(r'([0
# () are here for grouping purpose in the regexp
forbidden_words_regex = re.compile(r'(%s)' % Config.getOption('ForbiddenWords'), re.IGNORECASE)
valid_buildhost_regex = re.compile(Config.getOption('ValidBuildHost'))
+valid_filedep_regex = re.compile(r'(?:/s?bin/|^/etc/|^/usr/lib/sendmail$)')
use_epoch = Config.getOption('UseEpoch', False)
use_utf8 = Config.getOption('UseUTF8', Config.USEUTF8_DEFAULT)
max_line_len = Config.getOption('MaxLineLength', 79)
@@ -636,6 +637,9 @@ class TagsCheck(AbstractCheck.AbstractCh
if d[0].startswith('/usr/local/'):
printError(pkg, 'invalid-dependency', d[0])
+ if d[0].startswith('/') and not valid_filedep_regex.search(d[0]):
+ printWarning(pkg, 'invalid-filepath-dependency', d[0])
+
if is_source:
if lib_devel_number_regex.search(d[0]):
printError(pkg, 'invalid-build-requires', d[0])
@@ -1166,6 +1170,12 @@ unneeded explicit Requires: tags.''',
'''This package provides 2 times the same capacity. It should only provide it
once.''',
+'invalid-filepath-dependency',
+'''A package has a file or path based dependency that is not resolveable for
+package solvers because it is not in the whitelist for path based dependencies
+and therefore not available in repository metadata. Please use a symbolic requires
+instead or require a file in bin or /etc.''',
+
'tag-not-utf8',
'''The character encoding of the value of this tag is not UTF-8.''',
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:38 +0200
Subject: [PATCH] no-doc-for-lib.diff
===================================================================
---
FilesCheck.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: rpmlint-rpmlint-1.11/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.11/FilesCheck.py
@@ -464,7 +464,7 @@ class FilesCheck(AbstractCheck.AbstractC
debuginfo_srcs = False
debuginfo_debugs = False
- if not doc_files:
+ if not lib_package and not doc_files:
printWarning(pkg, 'no-documentation')
if files:
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:39 +0200
Subject: [PATCH] only-reg-files-are-scripts.diff
===================================================================
---
InitScriptCheck.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: rpmlint-rpmlint-1.11/InitScriptCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/InitScriptCheck.py
+++ rpmlint-rpmlint-1.11/InitScriptCheck.py
@@ -17,7 +17,7 @@ import AbstractCheck
import Config
from Filter import addDetails, printError, printWarning
import Pkg
-
+import stat
chkconfig_content_regex = re.compile(r'^\s*#\s*chkconfig:\s*([-0-9]+)\s+[-0-9]+\s+[-0-9]+')
subsys_regex = re.compile(r'/var/lock/subsys/([^/"\'\s;&|]+)', re.MULTILINE)
@@ -49,6 +49,9 @@ class InitScriptCheck(AbstractCheck.Abst
not fname.startswith('/etc/rc.d/init.d/'):
continue
+ if not stat.S_ISREG(pkgfile.mode):
+ continue
+
basename = os.path.basename(fname)
initscript_list.append(basename)
if pkgfile.mode & 0o500 != 0o500:
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:39 +0200
Subject: [PATCH] rpmgroup-checks.diff
===================================================================
---
TagsCheck.py | 6 ++++++
1 file changed, 6 insertions(+)
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -750,6 +750,8 @@ class TagsCheck(AbstractCheck.AbstractCh
self._unexpanded_macros(pkg, 'Group', group)
if not group:
printError(pkg, 'no-group-tag')
+ elif pkg.name.endswith('-devel') and not group.startswith('Development/'):
+ printWarning(pkg, 'devel-package-with-non-devel-group', group)
elif VALID_GROUPS and group not in VALID_GROUPS:
printWarning(pkg, 'non-standard-group', group)
@@ -1085,6 +1087,10 @@ won't fool the specfile parser, and rebu
'''There is no Group tag in your package. You have to specify a valid group
in your spec file using the Group tag.''',
+'devel-package-with-non-devel-group',
+'''The package ends with -devel but does not have a RPM group starting with
+Development/''',
+
'non-standard-group',
'''The value of the Group tag in the package is not valid. Valid groups are:
"%s".''' % '", "'.join(VALID_GROUPS),
Index: rpmlint-rpmlint-1.10/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.10/TagsCheck.py
@@ -673,7 +673,7 @@ class TagsCheck(AbstractCheck.AbstractCh
base_or_libs = base + '*' + '/' + base + '-libs/lib' + base + '*'
# try to match *%_isa as well (e.g. "(x86-64)", "(x86-32)")
base_or_libs_re = re.compile(
- r'^(lib)?%s(-libs)?[\d_]*(\(\w+-\d+\))?$' % re.escape(base))
+ r'^(lib)?%s(-libs)?[\d_-]*(\(\w+-\d+\))?$' % re.escape(base))
for d in deps:
if base_or_libs_re.match(d[0]):
dep = d
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:38 +0200
Subject: [PATCH] suse-binarieschecks.diff
===================================================================
---
BinariesCheck.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
Index: rpmlint-rpmlint-1.11/BinariesCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/BinariesCheck.py
+++ rpmlint-rpmlint-1.11/BinariesCheck.py
@@ -16,7 +16,7 @@ import rpm
import AbstractCheck
import Config
-from Filter import addDetails, printError, printWarning
+from Filter import addDetails, printError, printWarning, printInfo
import Pkg
@@ -54,6 +54,9 @@ class BinaryInfo(object):
setuid_call_regex = create_regexp_call(r'set(?:res|e)?uid')
setgroups_call_regex = create_regexp_call(r'(?:ini|se)tgroups')
chroot_call_regex = create_regexp_call('chroot')
+ debuginfo_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.debug_.*\s+')
+ symtab_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.symtab\s+')
+ gethostbyname_call_regex = create_regexp_call(r'(gethostbyname|gethostbyname2|gethostbyaddr|gethostbyname_r|gethostbyname2_r|gethostbyaddr_r)')
forbidden_functions = Config.getOption("WarnOnFunction")
if forbidden_functions:
@@ -83,7 +86,10 @@ class BinaryInfo(object):
self.exec_stack = False
self.exit_calls = []
self.forbidden_calls = []
+ self.calls_gethostbyname = False
fork_called = False
+ self.debuginfo = False
+ self.symtab = False
self.tail = ''
self.lto_sections = False
@@ -134,6 +140,14 @@ class BinaryInfo(object):
self.non_pic = False
continue
+ if BinaryInfo.debuginfo_regex.search(line):
+ self.debuginfo = True
+ continue
+
+ if BinaryInfo.symtab_regex.search(line):
+ self.symtab = True
+ continue
+
r = BinaryInfo.soname_regex.search(line)
if r:
self.soname = r.group(1)
@@ -174,6 +188,9 @@ class BinaryInfo(object):
if BinaryInfo.chroot_call_regex.search(line):
self.chroot = True
+ if BinaryInfo.gethostbyname_call_regex.search(line):
+ self.calls_gethostbyname = True
+
if BinaryInfo.forbidden_functions:
for r_name, func in BinaryInfo.forbidden_functions.items():
ret = func['f_regex'].search(line)
@@ -432,13 +449,26 @@ class BinariesCheck(AbstractCheck.Abstra
continue
# stripped ?
- if 'not stripped' in pkgfile.magic:
+ if ('not stripped' in pkgfile.magic and
+ (os.environ.get('BUILD_DIR', '') == '' or
+ os.environ.get('BUILD_DEBUG', '') != '')):
printWarning(pkg, 'unstripped-binary-or-object', fname)
# inspect binary file
is_shlib = so_regex.search(fname)
bin_info = BinaryInfo(pkg, pkgfile.path, fname, is_ar, is_shlib)
+ # stripped static library
+ if is_ar:
+ if bin_info.readelf_error:
+ pass
+ elif not bin_info.symtab:
+ printError(pkg, 'static-library-without-symtab', fname)
+ elif (not bin_info.debuginfo and
+ (os.environ.get('BUILD_DIR', '') == '' or
+ os.environ.get('BUILD_DEBUG', '') != '')):
+ printWarning(pkg, 'static-library-without-debuginfo', fname)
+
if is_shlib:
has_lib = True
@@ -496,6 +526,10 @@ class BinariesCheck(AbstractCheck.Abstra
printWarning(pkg, ec, fname,
BinaryInfo.forbidden_functions[ec]['f_name'])
+ # gethostbyname ?
+ if bin_info.calls_gethostbyname:
+ printInfo(pkg, 'binary-or-shlib-calls-gethostbyname', fname)
+
# rpath ?
if bin_info.rpath:
for p in bin_info.rpath:
@@ -724,6 +758,14 @@ with the intended shared libraries only.
'ldd-failed',
'''Executing ldd on this file failed, all checks could not be run.''',
+'static-library-without-symtab',
+'''The static library doesn't contain any symbols and therefore can't be linked
+against. This may indicated that it was strip.''',
+
+'static-library-without-debuginfo',
+'''The static library doesn't contain any debuginfo. Binaries linking against
+this static library can't be properly debugged.''',
+
'executable-stack',
'''The binary declares the stack as executable. Executable stack is usually an
error as it is only needed if the code contains GCC trampolines or similar
@@ -736,6 +778,10 @@ don\'t define a proper .note.GNU-stack s
make the stack executable. Usual suspects include use of a non-GNU linker or
an old GNU linker version.''',
+'binary-or-shlib-calls-gethostbyname',
+'''The binary calls gethostbyname(). Please port the code to use
+getaddrinfo().''',
+
'shared-lib-calls-exit',
'''This library package calls exit() or _exit(), probably in a non-fork()
context. Doing so from a library is strongly discouraged - when a library
@@ -754,6 +800,12 @@ that use prelink, make sure that prelink
placing a blacklist file in /etc/prelink.conf.d. For more information, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900#49''',
+'unstripped-binary-or-object',
+'''stripping debug info from binaries happens automatically according to global
+project settings. So there's normally no need to manually strip binaries.
+Left over unstripped binaries could therefore indicate a bug in the automatic
+stripping process.''',
+
'non-position-independent-executable',
'''This executable must be position independent. Check that it is built with
-fPIE/-fpie in compiler flags and -pie in linker flags.''',
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -420,6 +420,7 @@ lib_devel_number_regex = re.compile(r'^l
invalid_url_regex = re.compile(Config.getOption('InvalidURL'), re.IGNORECASE)
lib_package_regex = re.compile(r'(?:^(?:compat-)?lib.*?(\.so.*)?|libs?[\d-]*)$', re.IGNORECASE)
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')
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
# () are here for grouping purpose in the regexp
@@ -639,10 +640,12 @@ class TagsCheck(AbstractCheck.AbstractCh
base = is_devel.group(1)
dep = None
has_so = False
+ has_pc = False
for fname in pkg.files():
if fname.endswith('.so'):
has_so = True
- break
+ if pkg_config_regex.match(fname) and fname.endswith('.pc'):
+ has_pc = True
if has_so:
base_or_libs = base + '/' + base + '-libs/lib' + base
# try to match *%_isa as well (e.g. "(x86-64)", "(x86-32)")
@@ -679,6 +682,15 @@ class TagsCheck(AbstractCheck.AbstractCh
if prov not in (x[0] for x in pkg.provides()):
printWarning(pkg, 'no-provides', prov)
+ if has_pc:
+ found_pkg_config_dep = False
+ for p in (x[0] for x in pkg.provides()):
+ if (p.startswith("pkgconfig(")):
+ found_pkg_config_dep = True
+ break
+ if not found_pkg_config_dep:
+ printWarning(pkg, 'no-pkg-config-provides')
+
# List of words to ignore in spell check
ignored_words = set()
for pf in pkg.files():
@@ -1126,6 +1138,11 @@ once.''',
'no-url-tag',
'''The URL tag is missing. Please add a http or ftp link to the project location.''',
+'no-pkg-config-provides',
+'''The package installs a .pc file but does not provide pkgconfig(..) provides.
+The most likely reason for that is that it was built without BuildRequires: pkg-config.
+Please double check your build dependencies.''',
+
'name-repeated-in-summary',
'''The name of the package is repeated in its summary. This is often redundant
information and looks silly in various programs' output. Make the summary
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:37 +0200
Subject: [PATCH] suse-python3-naming-policy.diff
===================================================================
---
NamingPolicyCheck.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: rpmlint-rpmlint-1.10/NamingPolicyCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/NamingPolicyCheck.py
+++ rpmlint-rpmlint-1.10/NamingPolicyCheck.py
@@ -89,7 +89,7 @@ check = NamingPolicyCheck()
# if somone as a elegant solution, I will be happy to implement and test it.
check.add_check('xmms', '^xmms(-|$)', '^/usr/lib(64)?/xmms/')
-check.add_check('python', '^python(-|$)', '^/usr/lib(64)?/python[1-9](-[1-9])?')
+#check.add_check('python', '^python(2|3)?(-|$)', '^/usr/lib(64)?/python[1-9](-[1-9])?')
check.add_check('perl5', '^perl(-|$)', '^/usr/lib(64)?/perl5/vendor_perl')
check.add_check('apache2', '^apache2-mod_', '^/usr/lib(64)?/apache2-')
check.add_check('fortune', '^fortune(-|$)', '^/usr/share/games/fortunes/')
Index: rpmlint-rpmlint-1.11/BinariesCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/BinariesCheck.py
+++ rpmlint-rpmlint-1.11/BinariesCheck.py
@@ -558,10 +558,14 @@ class BinariesCheck(AbstractCheck.Abstra
if ocaml_mixed_regex.search(bin_info.tail):
printWarning(pkg, 'ocaml-mixed-executable', fname)
- if ((not is_shobj and not is_pie_exec) and
- pie_exec_re and pie_exec_re.search(fname)):
- printError(pkg, 'non-position-independent-executable',
- fname)
+ if (not is_shobj and not is_pie_exec):
+ if pie_exec_re and pie_exec_re.search(fname):
+ printError(
+ pkg, 'non-position-independent-executable', fname)
+ else:
+ printWarning(
+ pkg, 'position-independent-executable-suggested',
+ fname)
if bin_info.readelf_error:
continue
@@ -810,6 +814,10 @@ stripping process.''',
'''This executable must be position independent. Check that it is built with
-fPIE/-fpie in compiler flags and -pie in linker flags.''',
+'position-independent-executable-suggested',
+'''This executable should be position independent (all binaries should). Check
+that it is built with -fPIE/-fpie in compiler flags and -pie in linker flags.''',
+
'missing-call-to-setgroups-before-setuid',
'''This executable is calling setuid and setgid without setgroups or
initgroups. There is a high probability this means it didn't relinquish all
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:39 +0200
Subject: [PATCH] suse-shlib-devel-dependency.diff
===================================================================
---
TagsCheck.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -667,10 +667,10 @@ class TagsCheck(AbstractCheck.AbstractCh
if pkg_config_regex.match(fname) and fname.endswith('.pc'):
has_pc = True
if has_so:
- base_or_libs = base + '/' + base + '-libs/lib' + base
+ base_or_libs = base + '*' + '/' + base + '-libs/lib' + base + '*'
# try to match *%_isa as well (e.g. "(x86-64)", "(x86-32)")
base_or_libs_re = re.compile(
- r'^(lib)?%s(-libs)?(\(\w+-\d+\))?$' % re.escape(base))
+ r'^(lib)?%s(-libs)?[\d_]*(\(\w+-\d+\))?$' % re.escape(base))
for d in deps:
if base_or_libs_re.match(d[0]):
dep = d
Index: rpmlint-rpmlint-1.11/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.11/TagsCheck.py
@@ -466,16 +466,6 @@ so_dep_regex = re.compile(r'\.so(\.[0-9a
# we assume that no rpm packages existed before rpm itself existed...
oldest_changelog_timestamp = calendar.timegm(time.strptime("1995-01-01", "%Y-%m-%d"))
-private_so_paths = set()
-for path in ('%perl_archlib', '%perl_vendorarch', '%perl_sitearch',
- '%python_sitearch', '%python2_sitearch', '%python3_sitearch',
- '%ruby_sitearch', '%php_extdir'):
- epath = rpm.expandMacro(path)
- if epath and epath != path:
- private_so_paths.add(epath)
- private_so_paths.add(re.sub(r'/lib64(?=/|$)', '/lib', epath))
- private_so_paths.add(re.sub(r'/lib(?=/|$)', '/lib64', epath))
-
_enchant_checkers = {}
@@ -934,14 +924,6 @@ class TagsCheck(AbstractCheck.AbstractCh
res = Pkg.b2s(pkg[getattr(rpm, 'RPMTAG_%s' % tag.upper())])
self._unexpanded_macros(pkg, tag, res)
- for path in private_so_paths:
- for fname, pkgfile in pkg.files().items():
- if fname.startswith(path):
- for prov in pkgfile.provides:
- if so_dep_regex.search(prov[0]):
- printWarning(pkg, "private-shared-object-provides",
- fname, Pkg.formatRequire(*prov))
-
def check_description(self, pkg, lang, ignored_words):
description = pkg.langtag(rpm.RPMTAG_DESCRIPTION, lang)
if use_utf8:
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,34 @@ DEFAULT_VALID_LICENSES = (
'Shareware',
)
+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',
@@ -408,6 +436,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'))
changelog_version_regex = re.compile(r'[^>]([^ >]+)\s*$')
@@ -422,6 +451,7 @@ lib_package_regex = re.compile(r'(?:^(?:
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+)\sWITH\s(\S+)')
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
# () are here for grouping purpose in the regexp
forbidden_words_regex = re.compile(r'(%s)' % Config.getOption('ForbiddenWords'), re.IGNORECASE)
@@ -795,6 +825,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 +839,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 +1136,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.
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:37 +0200
Subject: [PATCH] suse-version.diff
===================================================================
---
SpecCheck.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Index: rpmlint-rpmlint-1.11/SpecCheck.py
===================================================================
--- rpmlint-rpmlint-1.11.orig/SpecCheck.py
+++ rpmlint-rpmlint-1.11/SpecCheck.py
@@ -49,6 +49,7 @@ packager_regex = re_tag_compile('Package
buildarch_regex = re_tag_compile('BuildArch(?:itectures)?')
buildprereq_regex = re_tag_compile('BuildPreReq')
prereq_regex = re_tag_compile(r'PreReq(\(.*\))')
+suse_version_regex = re.compile(r'%suse_version\s*[<>=]+\s*(\d+)')
make_check_regex = re.compile(r'(^|\s|%{?__)make}?\s+(check|test)')
rm_regex = re.compile(r'(^|\s)((.*/)?rm|%{?__rm}?) ')
@@ -389,6 +390,12 @@ class SpecCheck(AbstractCheck.AbstractCh
if not res.group(1).startswith('%'):
printWarning(pkg, 'hardcoded-prefix-tag', res.group(1))
+ res = suse_version_regex.search(line)
+ if res and int(res.group(1)) > 0 and int(res.group(1)) < 1315:
+ printWarning(pkg, "obsolete-suse-version-check", res.group(1))
+ elif res and int(res.group(1)) > 1550:
+ printError(pkg, "invalid-suse-version-check", res.group(1))
+
res = prereq_regex.search(line)
if res:
printError(pkg, 'prereq-use', res.group(2))
@@ -806,6 +813,15 @@ architecture independent or if some othe
in some editors but can lead to obscure errors. It should be replaced by a
regular space.''',
+'obsolete-suse-version-check',
+'''The specfile contains a comparison of %suse_version against a suse release
+that is no longer in maintenance. Consider removing obsolete parts of your
+spec file to make it more readable.''',
+
+'invalid-suse-version-check',
+'''The specfile contains a comparison of %suse_version against a suse release
+that does not exist. Please double check.''',
+
'non-standard-group',
'''The value of the Group tag in the package is not valid. Valid groups are:
"%s".''' % '", "'.join(VALID_GROUPS),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment