Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1466650 - [DNF] TransactionSet object has no attribute 'addReinstall'
[DNF] TransactionSet object has no attribute 'addReinstall'
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rpm (Show other bugs)
7.5
Unspecified Unspecified
unspecified Severity unspecified
: pre-dev-freeze
: ---
Assigned To: Igor Gnatenko
Jan Blazek
:
Depends On:
Blocks: 1465896 1466368 1461652
  Show dependency treegraph
 
Reported: 2017-06-30 03:19 EDT by Daniel Mach
Modified: 2018-04-10 11:59 EDT (History)
5 users (show)

See Also:
Fixed In Version: rpm-4.11.3-27.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-04-10 11:58:38 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0877 None None None 2018-04-10 11:59 EDT

  None (edit)
Description Daniel Mach 2017-06-30 03:19:37 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'
Comment 1 Panu Matilainen 2017-06-30 04:26:57 EDT
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.
Comment 5 Daniel Mach 2017-12-07 04:25:07 EST
how about following?:

import rpm
ts = rpm.TransactionSet()
result = hasattr(ts, "addReinstall")
Comment 6 Panu Matilainen 2017-12-07 04:38:39 EST
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.
Comment 10 errata-xmlrpc 2018-04-10 11:58:38 EDT
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

Note You need to log in before you can comment on or make changes to this bug.