Red Hat Bugzilla – Bug 1466650
[DNF] TransactionSet object has no attribute 'addReinstall'
Last modified: 2018-04-10 11:59:42 EDT
This currently blocks DNF running on RHEL 7. The feature has to be either backported into RPM (preferred) or we need to find a workaround in the DNF code. Traceback (most recent call last): File "/usr/bin/dnf", line 58, in <module> main.user_main(sys.argv[1:], exit_code=True) File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 179, in user_main errcode = main(args) File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 64, in main return _main(base, args, cli_class, option_parser_class) File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 99, in _main return cli_run(cli, base) File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 123, in cli_run ret = resolving(cli, base) File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 154, in resolving base.do_transaction(display=displays) File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 235, in do_transaction super(BaseCli, self).do_transaction(display) File "/usr/lib/python2.7/site-packages/dnf/base.py", line 677, in do_transaction self.transaction._populate_rpm_ts(self._ts) File "/usr/lib/python2.7/site-packages/dnf/transaction.py", line 204, in _populate_rpm_ts ts.addReinstall(tsi.installed._header, tsi) File "/usr/lib/python2.7/site-packages/dnf/rpm/transaction.py", line 65, in __getattr__ return self.getMethod(attr) File "/usr/lib/python2.7/site-packages/dnf/rpm/transaction.py", line 75, in getMethod return getattr(self.ts, method) AttributeError: 'TransactionSet' object has no attribute 'addReinstall'
There are basically three options, in order of backporting complexity from rpm POV: 1) Make "reinstall" command in dnf only available if rpm supports it - no rpm changes, a conditional or two in dnf (but obvious con of missing feature) 2) Minimal backport on rpm side to permit install + erasure of same package within a transaction, implement addReinstall() as a trivialish wrapper in dnf 3) Backport all of --reinstall feature to rpm, changes to dnf For dnf, 3) is obviously easiest, 1) and 2) require some changes there as well. The relevant rpm commits to backport are: Preliminaries, equaling case 2) above: 1f3164ae6975747e72af383f2d74c27245e6fe36 fd40d58efa0fbff535f273e5ae5c200d43d28aef The API + python binding changes: bfa76529864b9dfb29258f4dedc3fa9de9c5aeca 6665503ec6fb6430ecaafb3e318a4730f146efa9 bf856744f2820a1625ef9428284b5788d18103f3 c5200145fa08da884ce2c1ed85941363eeae6407 --reinstall on rpm cli (optional from dnf POV, but I guess would be strange not to backport this along with the others): 80dee39fb1f97ab3927c10bdd13c7c438b5677be This should be a trivial backport, commits are cherry-pick'able to rpm 4.11, bfa76529864b9dfb29258f4dedc3fa9de9c5aeca and 6665503ec6fb6430ecaafb3e318a4730f146efa9 need a trivial tweak to compile. Didn't test the result but not expecting any problems.
how about following?: import rpm ts = rpm.TransactionSet() result = hasattr(ts, "addReinstall")
Yeah, that'll basically test that the relevant patch has been applied. If you want to test the actual functionality, try something like this: # dnf -y install telnet # ls /usr/share/doc/telnet README # dnf -y --nodocs reinstall telnet # ls /usr/share/doc/telnet ls: cannot access '/usr/share/doc/telnet': No such file or directory For an automated testcase you'd probably want 'test -d /usr/share/doc/telnet' rather than 'ls', with the expectation that first it exists and after the --nodocs reinstall it does not.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2018:0877