adjust for rpm-4.19.0 API changes

These changes were submitted upstream for review:

    https://github.com/rpm-software-management/rpmlint/pull/1066

The changes are backward compatible as far back as rpm-4.12¹.

¹ As long as I've read the rpm commit history properly, that is.
This commit is contained in:
Todd Zullinger 2023-05-25 15:52:41 -04:00
parent 3b8cdae343
commit 52c9006a4d
3 changed files with 117 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From c2a3d7506387110bc0d03147ecdc75aed3432122 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz@pobox.com>
Date: Thu, 25 May 2023 13:12:12 -0400
Subject: [PATCH] DocCheck: adjust for rpm-4.19.0 API changes
Apparently, using `dsFromHeader()` has been deprecated for a long time.
Using `rpm.ds()` is the preferred method. It has been available for ~10
years, according to rpm commit 8d32255ff (Drop hdr.dsFromHeader() and
hdr.dsOfHeader() methods, 2022-04-08).
---
rpmlint/checks/DocCheck.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rpmlint/checks/DocCheck.py b/rpmlint/checks/DocCheck.py
index a1922fcd..4e77e7a6 100644
--- a/rpmlint/checks/DocCheck.py
+++ b/rpmlint/checks/DocCheck.py
@@ -60,7 +60,7 @@ class DocCheck(AbstractCheck):
core_reqs = {} # dependencies of non-doc files
doc_reqs = {} # dependencies of doc files
- for dep in pkg.header.dsFromHeader():
+ for dep in rpm.ds(pkg.header, 'requires'):
# skip deps which were found by find-requires
if dep.Flags() & rpm.RPMSENSE_FIND_REQUIRES != 0:
continue

View File

@ -0,0 +1,82 @@
From c228e8edcdc64e6e2877b48da4c43dbeae124c23 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz@pobox.com>
Date: Thu, 25 May 2023 14:11:56 -0400
Subject: [PATCH] rpmdiff: adjust for rpm-4.19.0 API changes
The `fiFromHeader()` method has been removed from rpm-4.19.0, in rpm
commit 742be88cd (Drop the klunky and ugly rpm.fi python binding
finally, 2022-04-08)
It has (apparently) been deprecated since rpm commit f0c3985a7 (Make
fiFromHeader() static inside header-py, deprecate, 2009-09-23).
Use `rpm.files()` instead, which was added in rpm commit 3b086277b (New
rpmfile[s] python bindings, 2013-12-18). This was released in
rpm-4.12.0.
---
rpmlint/rpmdiff.py | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/rpmlint/rpmdiff.py b/rpmlint/rpmdiff.py
index 34249ba3..a9e972bd 100644
--- a/rpmlint/rpmdiff.py
+++ b/rpmlint/rpmdiff.py
@@ -21,19 +21,17 @@ class Rpmdiff:
PRCO = ('REQUIRES', 'PROVIDES', 'CONFLICTS', 'OBSOLETES',
'RECOMMENDS', 'SUGGESTS', 'ENHANCES', 'SUPPLEMENTS')
- # {fname : (size, mode, mtime, flags, dev, inode,
- # nlink, state, vflags, user, group, digest)}
- __FILEIDX = [['S', 0],
- ['M', 1],
- ['5', 11],
- ['D', 4],
- ['N', 6],
- ['L', 7],
- ['V', 8],
- ['U', 9],
- ['G', 10],
- ['F', 3],
- ['T', 2]]
+ __FILEIDX = [['S', 'size'],
+ ['M', 'mode'],
+ ['5', 'digest'],
+ ['D', 'rdev'],
+ ['N', 'nlink'],
+ ['L', 'state'],
+ ['V', 'vflags'],
+ ['U', 'user'],
+ ['G', 'group'],
+ ['F', 'fflags'],
+ ['T', 'mtime']]
DEPFORMAT = '%-12s%s %s %s %s'
FORMAT = '%-12s%s'
@@ -78,9 +76,8 @@ class Rpmdiff:
self.__comparePRCOs(old, new, tag)
# compare the files
-
- old_files_dict = self.__fileIteratorToDict(old.fiFromHeader())
- new_files_dict = self.__fileIteratorToDict(new.fiFromHeader())
+ old_files_dict = self.__fileIteratorToDict(rpm.files(old))
+ new_files_dict = self.__fileIteratorToDict(rpm.files(new))
files = list(set(chain(iter(old_files_dict), iter(new_files_dict))))
files.sort()
@@ -101,7 +98,7 @@ class Rpmdiff:
fmt = ''
for entry in FILEIDX:
if entry[1] is not None and \
- old_file[entry[1]] != new_file[entry[1]]:
+ getattr(old_file, entry[1]) != getattr(new_file, entry[1]):
fmt += entry[0]
diff = True
else:
@@ -236,5 +233,5 @@ class Rpmdiff:
def __fileIteratorToDict(self, fi):
result = {}
for filedata in fi:
- result[filedata[0]] = filedata[1:]
+ result[filedata.name] = filedata
return result

View File

@ -3,7 +3,7 @@
Name: rpmlint
Version: 2.4.0
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Tool for checking common errors in RPM packages
License: GPL-2.0-or-later
URL: https://github.com/rpm-software-management/rpmlint
@ -23,6 +23,11 @@ Patch1: https://github.com/rpm-software-management/rpmlint/commit/7d707f
Patch2: https://github.com/rpm-software-management/rpmlint/commit/48aa148b.patch#/0001-TagsCheck-restore-space-exclusion-to-license_excepti.patch
Patch3: https://github.com/rpm-software-management/rpmlint/commit/65abdbd3.patch#/0002-TagsCheck-handle-license-exception-in-first-item-of-.patch
# rpm-4.19.0 api fixes
# https://github.com/rpm-software-management/rpmlint/pull/1066
Patch4: 0001-DocCheck-adjust-for-rpm-4.19.0-API-changes.patch
Patch5: 0002-rpmdiff-adjust-for-rpm-4.19.0-API-changes.patch
BuildArch: noarch
# use git to apply patches; it handles binary diffs
@ -88,6 +93,9 @@ cp -a %{SOURCE1} %{SOURCE3} %{SOURCE4} %{SOURCE5} %{buildroot}%{_sysconfdir}/xdg
%{_bindir}/rpmlint
%changelog
* Thu May 25 2023 Todd Zullinger <tmz@pobox.com> - 2.4.0-7
- adjust for rpm-4.19.0 API changes
* Mon Mar 20 2023 Todd Zullinger <tmz@pobox.com> - 2.4.0-6
- handle license exception in grouping, better (rhbz#2175241)