Bug 1249379

Summary: dnf downgrade of a broken package may leave package uninstalled
Product: [Fedora] Fedora Reporter: Ville Skyttä <ville.skytta>
Component: dnfAssignee: Honza Silhan <jsilhan>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: jsilhan, lkardos, mluscon, packaging-team-maint, pnemade, rholy, tim.lauridsen, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-plugins-core-0.1.10-1.fc23 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-15 02:13:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ville Skyttä 2015-08-02 07:58:59 UTC
# rpm -q dnf webkitgtk4
dnf-1.0.2-3.fc22.noarch  # from current updates-testing
webkitgtk4-2.8.4-3.fc22.x86_64

I had a broken earlier webkitgtk4 package downloaded, you can get one for example with:

curl -O -r 0-3000000 https://kojipkgs.fedoraproject.org//packages/webkitgtk4/2.8.4/2.fc22/x86_64/webkitgtk4-2.8.4-2.fc22.x86_64.rpm

This has nothing to do with webkitgtk4 in particular, it's just used as an example. I didn't notice it broken and tried to downgrade to it with dnf:

--------------------
# dnf -y downgrade ./webkitgtk4-2.8.4-2.fc22.x86_64.rpm
[...]
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Downgrading : webkitgtk4-2.8.4-2.fc22.x86_64
Error unpacking rpm package webkitgtk4-2.8.4-2.fc22.x86_64
error: unpacking of archive failed on file /usr/lib64/libwebkit2gtk-4.0.so.37.6.7;55bdcb5e: cpio: read
  Erasing     : webkitgtk4-2.8.4-3.fc22.x86_64
error: webkitgtk4-2.8.4-2.fc22.x86_64: install failed
webkitgtk4-2.8.4-2.fc22.x86_64 was supposed to be installed but is not!
  Verifying   : webkitgtk4-2.8.4-2.fc22.x86_64
  Verifying   : webkitgtk4-2.8.4-3.fc22.x86_64

Downgraded:
  webkitgtk4.x86_64 2.8.4-2.fc22                                                                                                    

Complete!
--------------------

There are two troubling things with this:

First, the output says Downgraded, but the package was not actually downgraded.

Second, and more importantly, the webkitgtk4 package is no longer installed at all as far as rpmdb is concerned:
    # rpm -q webkitgtk4
    package webkitgtk4 is not installed
And obviously I now have some broken dependencies but was not notified about them.

Not sure what exactly should/could be done about this, but I do think *something* should be done, maybe at least skip the erase step. Plain rpm doesn't work perfectly either in this scenario where I try to downgrade the same broken package with it (some files are upgraded, some not), but at least it doesn't leave the package uninstalled:

# rpm -U --oldpackage webkitgtk4-2.8.4-2.fc22.x86_64.rpm 
error: unpacking of archive failed on file /usr/lib64/libwebkit2gtk-4.0.so.37.6.7;55bdccc2: cpio: read
error: webkitgtk4-2.8.4-2.fc22.x86_64: install failed
error: webkitgtk4-2.8.4-3.fc22.x86_64: erase skipped
# rpm -q webkitgtk4
webkitgtk4-2.8.4-3.fc22.x86_64

Comment 1 Ville Skyttä 2015-08-02 08:00:10 UTC
BTW I'm not sure this happens just with downgrade or if upgrade is affected too -- I haven't tested anything but downgrade.

Comment 2 Honza Silhan 2015-08-11 15:26:31 UTC
DNF uses this sequence for downgrade:

ts.addErase(tsi.erased.idx)
hdr = tsi.installed.header
ts.addInstall(hdr, tsi, 'i')

Maybe that's why it remove the package first and then install the downgrade.
Lubos, does rpm downgrade the package differently through internal functions. I would expect there addDowngrade function analogue to addInstall, addErase and addReinstall.

Comment 3 Ľuboš Kardoš 2015-08-12 15:11:07 UTC
You should use this sequence for downgrade:

ts.addErase(tsi.erased.idx)
hdr = tsi.installed.header
ts.addInstall(hdr, tsi, 'u')

Comment 4 Honza Silhan 2015-08-12 15:24:57 UTC
Thanks Lubos.
Fixed in the upstream: https://github.com/rpm-software-management/dnf/commit/564f90e3941c402eb63b70c5ba9d89ace65d8135

Comment 5 Fedora Update System 2015-08-13 08:17:06 UTC
dnf-plugins-core-0.1.10-1.fc22, hawkey-0.6.0-1.fc22, dnf-1.1.0-2.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/FEDORA-2015-13162/dnf-plugins-core-0.1.10-1.fc22,dnf-1.1.0-2.fc22,hawkey-0.6.0-1.fc22

Comment 6 Fedora Update System 2015-08-13 08:17:14 UTC
dnf-plugins-core-0.1.10-1.fc23, hawkey-0.6.0-1.fc23, dnf-1.1.0-2.fc23 has been submitted as an update for Fedora 23.
https://admin.fedoraproject.org/updates/FEDORA-2015-13289/dnf-plugins-core-0.1.10-1.fc23,dnf-1.1.0-2.fc23,hawkey-0.6.0-1.fc23

Comment 7 Fedora Update System 2015-08-13 16:55:14 UTC
Package dnf-plugins-core-0.1.10-1.fc22, hawkey-0.6.0-1.fc22, dnf-1.1.0-2.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.10-1.fc22 hawkey-0.6.0-1.fc22 dnf-1.1.0-2.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-13162/dnf-plugins-core-0.1.10-1.fc22,dnf-1.1.0-2.fc22,hawkey-0.6.0-1.fc22
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2015-08-15 02:13:57 UTC
dnf-plugins-core-0.1.10-1.fc22, hawkey-0.6.0-1.fc22, dnf-1.1.0-2.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2015-08-19 07:51:47 UTC
dnf-plugins-core-0.1.10-1.fc23, hawkey-0.6.0-1.fc23, dnf-1.1.0-2.fc23 has been pushed to the Fedora 23 stable repository.  If problems still persist, please make note of it in this bug report.