xsuchy / rpmconf

Tool to handle rpmnew and rpmsave files
44 stars 19 forks source link

rpmconf should be tolerant to missing repo files #49

Closed asmorodskyi closed 1 year ago

asmorodskyi commented 1 year ago

I am openSUSE Leap user . I have openSUSE-release package on my distro . Currently I have such failure when I am trying to invoke rpmconf --all :

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.6/site-packages/rpmconf/rpmconf.py", line 117, in run
    tested_files += self._handle_package(pkg_hdr)
  File "/usr/lib/python3.6/site-packages/rpmconf/rpmconf.py", line 357, in _handle_package
    tmp.format(conf_file, "rpmsave"))
  File "/usr/lib/python3.6/site-packages/rpmconf/rpmconf.py", line 426, in _handle_rpmsave
    and filecmp.cmp(conf_file, other_file):
  File "/usr/lib64/python3.6/filecmp.py", line 51, in cmp
    s1 = _sig(os.stat(f1))
FileNotFoundError: [Errno 2] No such file or directory: '/etc/zypp/repos.d/repo-backports-debug-update.repo'

As I understand the reason for failure is that openSUSE-release package has /etc/zypp/repos.d/repo-backports-debug-update.repo in config files but I deleted this repo from package manager without deleting package. Currently this small trick blocks me fully from executing rpmconf on my system.

While there is a lot of openSUSE special things in this scenario I find it valid as more common. Generally speaking absence of single config file in single package is not good reason for fully block execution. So I would recommend catching this exception , log warning message and go further .

asmorodskyi commented 1 year ago

I am happy to work on this and provide PR and before I will start I want to get general feedback if it make sense from author POV ?

xsuchy commented 1 year ago

If you can send PR ... that would be awesome. I think this is a valid situation and rpmconf should treat the missing file as an empty file (or /dev/null) so the diff is still possible.

asmorodskyi commented 1 year ago

https://github.com/xsuchy/rpmconf/pull/50

xsuchy commented 1 year ago

Fixed in https://github.com/xsuchy/rpmconf/pull/51