Skip to content

Commit 1aa5d47

Browse files
committed
Merge branch 'main' into opensuse
2 parents 7717a72 + 0349170 commit 1aa5d47

15 files changed

Lines changed: 80 additions & 80 deletions

.packit/rpmlint.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%{!?python3: %global python3 %{__python3}}
22

33
Name: rpmlint
4-
Version: 2.7.0
4+
Version: 2.8.0
55
Release: 0%{?dist}
66
Summary: Tool for checking common errors in RPM packages
77

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "rpmlint"
9-
version = "2.7.0"
9+
version = "2.8.0"
1010
description = "Check for common errors in RPM packages"
1111
license = {text = "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)"}
1212
authors = [

rpmlint/checks/AbstractCheck.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def check_binary(self, pkg):
5050
# start with the biggest files first
5151
filenames = sorted(filenames, key=lambda x: pkg.files[x].size, reverse=True)
5252
with concurrent.futures.ThreadPoolExecutor() as executor:
53-
futures = []
54-
for filename in filenames:
55-
futures.append(executor.submit(self.check_file, pkg, filename))
53+
futures = [executor.submit(self.check_file, pkg, filename) for filename in filenames]
5654
concurrent.futures.wait(futures)
5755
for future in futures:
5856
err = future.exception()

rpmlint/checks/AlternativesCheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AlternativesCheck(AbstractCheck):
2222
Requires(post) and Requires(postun) must depend on update-alternatives
2323
"""
2424
# Regex to match anything that can be in requires for update-alternatives
25-
re_requirement = re.compile(r'^(/usr/sbin/|%{?_sbindir}?/)?update-alternatives$')
25+
re_requirement = re.compile(r'^(/usr/s?bin/|%{?_s?bindir}?/)?update-alternatives$')
2626
re_install = re.compile(r'--install\s+(?P<link>\S+)\s+(?P<name>\S+)\s+(\S+)\s+(\S+)')
2727
re_slave = re.compile(r'--slave\s+(?P<link>\S+)\s+(\S+)\s+(\S+)')
2828
command = 'update-alternatives'

rpmlint/checks/I18NCheck.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def is_valid_lang(lang):
7070

7171
class I18NCheck(AbstractCheck):
7272
def check_binary(self, pkg):
73-
files = list(pkg.files.keys())
74-
files.sort()
73+
files = sorted(pkg.files.keys())
7574
locales = [] # list of locales for this packages
7675
webapp = False
7776

rpmlint/checks/InitScriptCheck.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def shell_var_value(var, script):
4242
if res2 and res2.group(2) == var: # infinite loop
4343
return None
4444
return substitute_shell_vars(res.group(1), script)
45-
else:
46-
return None
45+
return None
4746

4847

4948
def substitute_shell_vars(val, script):
@@ -54,8 +53,7 @@ def substitute_shell_vars(val, script):
5453
value = ''
5554
return res.group(1) + value + \
5655
substitute_shell_vars(res.group(3), script)
57-
else:
58-
return val
56+
return val
5957

6058

6159
class InitScriptCheck(AbstractCheck):

rpmlint/checks/ZipCheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _check_classpath(self, pkg, fname, jarfile):
7878
return
7979

8080
# otherwise check for the hardcoded classpath
81-
manifest = jarfile.read(mf).decode()
81+
manifest = jarfile.read(mf).decode(errors='replace')
8282
if classpath_regex.search(manifest):
8383
self.output.add_info('W', pkg, 'class-path-in-manifest', fname)
8484

rpmlint/cli.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def process_lint_args(argv):
101101
if options.rpmlintrc:
102102
if not options.rpmlintrc.exists():
103103
print_warning(f"User specified rpmlintrc '{options.rpmlintrc}' does not exist")
104-
exit(2)
104+
sys.exit(2)
105105
# make it a list
106106
options.rpmlintrc = [options.rpmlintrc]
107107
else:
@@ -126,7 +126,7 @@ def process_lint_args(argv):
126126
f_path.update(p_path)
127127

128128
if invalid_path:
129-
exit(2)
129+
sys.exit(2)
130130
# convert options to dict
131131
options_dict = vars(options)
132132
# use computed rpmfile
@@ -155,7 +155,7 @@ def _validate_conf_location(string):
155155
if not path.exists():
156156
print_warning(
157157
f"File or dir with user specified configuration '{string}' does not exist")
158-
exit(2)
158+
sys.exit(2)
159159

160160
if path.is_dir():
161161
config_paths.extend(path.glob('*.toml'))
@@ -180,8 +180,7 @@ def lint():
180180
# TODO: remove once OBS integration is done
181181
options = process_lint_args(sys.argv[1:] + ['--permissive'])
182182

183-
lint = Lint(options)
184-
sys.exit(lint.run())
183+
sys.exit(Lint(options).run())
185184

186185

187186
def diff():

rpmlint/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ def _sort_config_files(self, config_file):
123123
"""
124124
if config_file == self.config_defaults:
125125
return 0
126-
elif not self._is_override_config(config_file):
126+
if not self._is_override_config(config_file):
127127
return 1
128-
else:
129-
return 2
128+
return 2
130129

131130
def load_config(self, config=None):
132131
"""

rpmlint/lint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def _run(self):
8282
if self.options['explain']:
8383
self.print_explanation(self.options['explain'], self.config)
8484
return retcode
85+
8586
# if there are installed arguments just load them up as extra
8687
# items to the rpmfile option
8788
if self.options['installed']:
@@ -240,8 +241,10 @@ def _print_header(self):
240241
print('')
241242

242243
def validate_installed_packages(self, packages):
244+
# Do not run post checks if there are also plain rpm/spec files to validate
245+
run_post_checks = not bool(self.options['rpmfile'])
243246
for pkg in packages:
244-
self.run_checks(pkg, pkg == packages[-1])
247+
self.run_checks(pkg, run_post_checks and pkg == packages[-1])
245248
self.reset_checks()
246249

247250
def validate_files(self, files):
@@ -275,7 +278,7 @@ def _expand_filelist(self, files):
275278

276279
def validate_file(self, pname, is_last):
277280
try:
278-
if pname.suffix == '.rpm' or pname.suffix == '.spm':
281+
if pname.suffix in ('.rpm', '.spm'):
279282
with Pkg(pname, self.config.configuration['ExtractDir'],
280283
verbose=self.config.info) as pkg:
281284
for k, v in pkg.timers.items():
@@ -288,8 +291,7 @@ def validate_file(self, pname, is_last):
288291
print_warning(f'(none): E: fatal error while reading {pname}: {e}')
289292
if self.config.info:
290293
raise e
291-
else:
292-
sys.exit(3)
294+
sys.exit(3)
293295

294296
def run_checks(self, pkg, is_last):
295297
spec_checks = isinstance(pkg, FakePkg)

0 commit comments

Comments
 (0)