8221668e34
On installs where documentation or additional languages are not installed, rpmlint fails while attempting to iterate over the file list. The files are only opened for their 'magic numbers' which is used in a few tests in BinariesCheck and SourceCheck. Fedora container images sets nodocs and '%_install_langs en_US' (which causes locale files not to be installed). Running rpmlint in such a container results in a traceback when rpmlint attempts to check the packages files. Backport patch from upstream to fix the issue. Resolves: https://bugzilla.redhat.com/1574509 Source: https://github.com/rpm-software-management/rpmlint/commit/d59bc2a
45 lines
1.6 KiB
Diff
45 lines
1.6 KiB
Diff
From 3a072351314c3a3ec11650ad8efd2fc6ececf987 Mon Sep 17 00:00:00 2001
|
|
From: Dirk Mueller <dirk@dmllr.de>
|
|
Date: Sat, 4 Nov 2017 02:17:52 +0100
|
|
Subject: [PATCH] Properly handle the exception on missing files
|
|
|
|
Missing files raises a FileNotFoundError, not OSError. Also
|
|
simplify logic.
|
|
|
|
(cherry picked from commit d59bc2a1e2698040553c09610cb2befa1ef8d76a)
|
|
---
|
|
Pkg.py | 11 +++--------
|
|
1 file changed, 3 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/Pkg.py b/Pkg.py
|
|
index e257243..01d0289 100644
|
|
--- a/Pkg.py
|
|
+++ b/Pkg.py
|
|
@@ -714,20 +714,15 @@ class Pkg(AbstractPkg):
|
|
pkgfile.magic = "symbolic link to `%s'" % pkgfile.linkto
|
|
elif not pkgfile.size:
|
|
pkgfile.magic = 'empty'
|
|
- if not pkgfile.magic and _magic:
|
|
+ if (not pkgfile.magic and
|
|
+ not pkgfile.is_ghost and _magic):
|
|
# file() method evaluates every file twice with python2,
|
|
# use descriptor() method instead
|
|
try:
|
|
fd = os.open(pkgfile.path, os.O_RDONLY)
|
|
- except OSError:
|
|
- if not pkgfile.is_ghost:
|
|
- raise
|
|
- else:
|
|
pkgfile.magic = b2s(_magic.descriptor(fd))
|
|
- # libmagic up to 5.18 already closes the descriptor
|
|
- try:
|
|
os.close(fd)
|
|
- except OSError:
|
|
+ except FileNotFoundError:
|
|
pass
|
|
if pkgfile.magic is None:
|
|
pkgfile.magic = ''
|
|
--
|
|
2.17.0
|
|
|