Fedora Black Magic — Using Questionable dnf Invocations to "Fix" a Botched Upgrade
Today, after upgrading from Fedora 37 to 38, I still several Fedora 37 packages installed, and when I run dnf commands, it still uses the Fedora 37 repos. So, let's fix my system! (but, please don't try this yourself unless you're comfortable with dnf)
To fix that the wrong repos are used (Fedora 37 instead of 38), I checked my installation of fedora-repos:
[neboula@shock ~]$ sudo dnf install fedora-repos
Last metadata expiration check: 0:04:00 ago on ons 19 apr 2023 19:11:59.
Package fedora-repos-37-2.noarch is already installed.
Package fedora-repos-38-1.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
As we can see, the repo packages for both 37 and 38 are installed. Simply removing fedora-release-37 (which in turn removes fedora-repos-37) solved this:
[neboula@shock ~]$ sudo dnf remove fedora-release-37
Dependencies resolved.
===============================================================================================================
Package Architecture Version Repository Size
===============================================================================================================
Removing:
fedora-release noarch 37-16 @updates 0
Removing dependent packages:
fedora-release-common noarch 37-16 @updates 18 k
fedora-repos noarch 37-2 @updates 4.5 k
Transaction Summary
===============================================================================================================
Remove 3 Packages
Freed space: 22 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Erasing : fedora-repos-37-2.noarch 1/3
Erasing : fedora-release-37-16.noarch 2/3
Erasing : fedora-release-common-37-16.noarch 3/3
Verifying : fedora-release-37-16.noarch 1/3
Verifying : fedora-release-common-37-16.noarch 2/3
Verifying : fedora-repos-37-2.noarch 3/3
Removed:
fedora-release-37-16.noarch fedora-release-common-37-16.noarch fedora-repos-37-2.noarch
Complete!
After doing that, subsequent dnf commands use the Fedora 38 repos. Success!
However, there's still all the duplicate Fedora 37 and Fedora 38 packages. I
tried doing # dnf remove --duplicates, but sadly this didn't work:
[neboula@shock ~]$ sudo dnf remove --duplicates
Installed package python3-3.11.3-1.fc37.x86_64 not available.
Installed package podman-5:4.5.0-1.fc37.x86_64 not available.
Installed package libpcap-14:1.10.4-1.fc37.x86_64 not available.
Installed package python3-dnf-4.15.0-1.fc37.noarch not available.
Installed package annobin-plugin-gcc-12.02-1.fc37.x86_64 not available.
Installed package dnf-data-4.15.0-1.fc37.noarch not available.
Installed package python3-libs-3.11.3-1.fc37.x86_64 not available.
Installed package python3-tkinter-3.11.3-1.fc37.x86_64 not available.
Installed package podman-gvproxy-5:4.5.0-1.fc37.x86_64 not available.
Installed package annobin-docs-12.02-1.fc37.noarch not available.
Installed package aardvark-dns-1.6.0-1.fc37.x86_64 not available.
Installed package netavark-1.6.0-2.fc37.x86_64 not available.
Error:
Problem: The operation would result in removing the following protected packages: dnf
(try to add '--skip-broken' to skip uninstallable packages)
Oh well. I did a regular # dnf upgrade to see if that would help, and then I
realised that # dnf distrosync might be a good idea too. However, the latter
wouldn't work unless I added --setopt=protected_packages= at the end, and
said that it would remove 2499 packages and free 6,9 GB of space, which felt too
risky to try. As such, I didn't go through with the distrosync.
I then looked at the output of # dnf remove --duplicates. I'll put it right
below:
[neboula@shock ~]$ sudo dnf remove --duplicates
Last metadata expiration check: 0:13:52 ago on ons 19 apr 2023 19:23:16.
Installed package python3-3.11.3-1.fc37.x86_64 not available.
Installed package libpcap-14:1.10.4-1.fc37.x86_64 not available.
Installed package python3-dnf-4.15.0-1.fc37.noarch not available.
Installed package annobin-plugin-gcc-12.02-1.fc37.x86_64 not available.
Installed package dnf-data-4.15.0-1.fc37.noarch not available.
Installed package python3-libs-3.11.3-1.fc37.x86_64 not available.
Installed package annobin-docs-12.02-1.fc37.noarch not available.
Error:
Problem: The operation would result in removing the following protected packages: dnf
(try to add '--skip-broken' to skip uninstallable packages)
I'm guessing the reason it thinks it needs to remove dnf is because it can't find some dependencies of dnf. Presumably, python3, python3-dnf, python3-libs, and dnf-data.
I'm guessing that all these packages have both Fedora 37 and Fedora 38 versions
installed, so let's try removing the Fedora 37 versions using # dnf swap,
starting with python3-dnf:
[neboula@shock ~]$ sudo dnf swap python3-dnf-4.15.0-1.fc37 python3-dnf-4.14.0-2.fc38
Last metadata expiration check: 0:15:02 ago on ons 19 apr 2023 19:23:16.
Package python3-dnf-4.14.0-2.fc38.noarch is already installed.
Dependencies resolved.
===============================================================================================================
Package Architecture Version Repository Size
===============================================================================================================
Removing:
python3-dnf noarch 4.15.0-1.fc37 @updates 2.7 M
Transaction Summary
===============================================================================================================
Remove 1 Package
Freed space: 2.7 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Erasing : python3-dnf-4.15.0-1.fc37.noarch 1/1
Verifying : python3-dnf-4.15.0-1.fc37.noarch 1/1
Removed:
python3-dnf-4.15.0-1.fc37.noarch
Complete!
This works! For some reason. Let's look at the output of
# dnf remove --duplicates again and see if python3-dnf is gone from it:
[neboula@shock ~]$ sudo dnf remove --duplicates
[sudo] password for neboula:
Last metadata expiration check: 0:20:25 ago on ons 19 apr 2023 19:23:16.
Installed package python3-3.11.3-1.fc37.x86_64 not available.
Installed package libpcap-14:1.10.4-1.fc37.x86_64 not available.
Installed package annobin-plugin-gcc-12.02-1.fc37.x86_64 not available.
Installed package dnf-data-4.15.0-1.fc37.noarch not available.
Installed package python3-libs-3.11.3-1.fc37.x86_64 not available.
Installed package annobin-docs-12.02-1.fc37.noarch not available.
Error:
Problem 1: package annobin-plugin-gcc-12.02-1.fc37.x86_64 requires (gcc >= 12 with gcc < 13), but none of the providers can be installed
- package redhat-rpm-config-252-1.fc38.noarch requires (annobin-plugin-gcc if gcc), but none of the providers can be installed
- conflicting requests
Problem 2: problem with installed package python3-3.11.2-1.fc38.i686
- python3-3.11.2-1.fc38.i686 has inferior architecture
- conflicting requests
Problem 3: problem with installed package libpcap-devel-14:1.10.3-2.fc38.x86_64
- package libpcap-devel-14:1.10.3-2.fc38.x86_64 requires libpcap(x86-64) = 14:1.10.3-2.fc38, but none of the providers can be installed
- conflicting requests
Problem 4: package python3-libreport-2.17.9-1.fc38.x86_64 requires python3-dnf, but none of the providers can be installed
- package python3-dnf-4.14.0-2.fc38.noarch requires dnf-data = 4.14.0-2.fc38, but none of the providers can be installed
- conflicting requests
Problem 5: problem with installed package python3-devel-3.11.2-1.fc38.x86_64
- package python3-devel-3.11.2-1.fc38.x86_64 requires python3-libs(x86-64) = 3.11.2-1.fc38, but none of the providers can be installed
- conflicting requests
Problem 6: problem with installed package annobin-plugin-gcc-12.02-1.fc37.x86_64
- package annobin-plugin-gcc-12.02-1.fc37.x86_64 requires (gcc >= 12 with gcc < 13), but none of the providers can be installed
- package annobin-plugin-gcc-12.01-1.fc38.x86_64 requires annobin-docs = 12.01-1.fc38, but none of the providers can be installed
- package gcc-12.2.1-4.fc37.x86_64 requires cpp = 12.2.1-4.fc37, but none of the providers can be installed
- conflicting requests
(try to add '--skip-broken' to skip uninstallable packages)
It is! But now there's a bunch of other errors. I'll fix up the other packages it can't find and see if that helps (which I won't add here because it's just the same as with python3-dnf except repeated with different package names and versions).
After repeating the # dnf swap process for all the other packages, I tried
# dnf remove --duplicates, and now it lets me do it!
To be safe, I went into a tty (as opposed to the graphical interface) by pressing Ctrl + Alt + F3. I then logged in there and ran the command. After it finished, I rebooted, and now my system is fine!