Skip to content

Commit

Permalink
Use rpm.files instead of rpm.fi
Browse files Browse the repository at this point in the history
RPM 4.19 removed a deprecated rpm.fi class in favour of rpm.files:

    # rpmconf -a
    Traceback (most recent call last):
      File "/usr/sbin/rpmconf", line 105, in <module>
        main()
      File "/usr/sbin/rpmconf", line 95, in main
        rconf.run()
      File "/usr/lib/python3.11/site-packages/rpmconf/rpmconf.py", line 122, in run
        tested_files += self._handle_package(pkg_hdr)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/rpmconf/rpmconf.py", line 346, in _handle_package
        for conf_file in self.get_list_of_config(package):
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/rpmconf/rpmconf.py", line 159, in get_list_of_config
        files = rpm.fi(package) # pylint: disable=no-member
                ^^^^^^
    AttributeError: module 'rpm' has no attribute 'fi'. Did you mean: 'fd'?

This patch fixes it by porting to rpm.files API. According to RPM git
log, the new API is available since 2013. Thus I did not implement any
fallback.
  • Loading branch information
ppisar authored and xsuchy committed Jul 7, 2023
1 parent 57d892d commit 8cfcc14
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rpmconf/rpmconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ def get_list_of_config(self, package):
:rtype: list
"""
files = rpm.fi(package) # pylint: disable=no-member
files = rpm.files(package) # pylint: disable=no-member
result = []
for rpm_file in files:
if rpm_file[4] & rpm.RPMFILE_CONFIG: # pylint: disable=no-member
file_name = rpm_file[0]
if rpm_file.fflags & rpm.RPMFILE_CONFIG: # pylint: disable=no-member
file_name = rpm_file.name
if self.root:
file_name = os.path.normpath(self.root + file_name)
result.append(file_name)
Expand Down

0 comments on commit 8cfcc14

Please sign in to comment.