Backport PR #199 to fix crash caused by using removed rpm Python API

This commit is contained in:
Adam Williamson 2023-09-14 11:35:28 -07:00
parent 191b01baa5
commit eabb594a20
2 changed files with 47 additions and 1 deletions

39
199.patch Normal file
View File

@ -0,0 +1,39 @@
From 16e3e39fe8ee4483a7aaa328fdc4d2304c14cb11 Mon Sep 17 00:00:00 2001
From: Jakub Kadlcik <frostyx@email.cz>
Date: Wed, 16 Aug 2023 22:06:42 +0200
Subject: [PATCH] Stop using deprecated rpm.fi
Fix #198
Per `help(rpm.fi)`:
> DEPRECATED! This old API mixes storing and iterating over the meta data
> of the files of a package. Use rpm.files and rpm.file data types as a
> much cleaner API.
We could use
return [x.name for x in rpm.files(hdr)]
but this seems easier
return hdr[rpm.RPMTAG_FILENAMES]
---
tracer/packageManagers/rpm.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tracer/packageManagers/rpm.py b/tracer/packageManagers/rpm.py
index 87fb5f1..e8e7347 100644
--- a/tracer/packageManagers/rpm.py
+++ b/tracer/packageManagers/rpm.py
@@ -102,8 +102,8 @@ def package_files(self, pkg_name):
if self._is_installed(pkg_name):
ts = rpm.TransactionSet()
mi = ts.dbMatch("name", pkg_name)
- fi = rpm.fi(next(mi))
- return [f[0] for f in fi]
+ hdr = next(mi)
+ return hdr[rpm.RPMTAG_FILENAMES]
# Tracer will not find uninstalled applications
return []

View File

@ -18,7 +18,7 @@
Name: tracer
Version: 0.7.11
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Finds outdated running applications in your system
BuildArch: noarch
@ -29,6 +29,10 @@ URL: http://tracer-package.com/
# cd tracer
# tito build --tgz
Source0: %{name}-%{version}.tar.gz
# Fix a crash that can occur when tracer is run after package updates
# https://bugzilla.redhat.com/show_bug.cgi?id=2235578
# https://github.com/FrostyX/tracer/pull/199
Patch0: 199.patch
BuildRequires: asciidoc
BuildRequires: gettext
@ -197,6 +201,9 @@ make DESTDIR=%{buildroot}%{_datadir} mo
%changelog
* Thu Sep 14 2023 Adam Williamson <awilliam@redhat.com> - 0.7.11-4
- Backport PR #199 to fix crash caused by using removed rpm Python API
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild