Skip to content

Commit

Permalink
package_manager: fix the DNF4 fallback for --no-bootstrap-chroot
Browse files Browse the repository at this point in the history
When package_manager = dnf, 'dnf4' is to be selected and used when
bootstrap chroot is disabled.

This was not detected by test-suite; my bet is that we do tests with
testConfig=fedora-40-x86_64 which is already dnf5 and we have dnf5
installed on the testing machines.  I'm trying to modify one test-case
to test DNF4 chroot explicitly.

Fixes: rpm-software-management#1475
  • Loading branch information
praiskup committed Sep 30, 2024
1 parent 0aa9b7a commit 6b4971c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
15 changes: 9 additions & 6 deletions mock/integration-tests/23-local-mirrorlist.tst
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ gpgcheck=0
"""
EOF

# default chroot is DNF5, centos-stream is DNF4
for chroot in "" "-r centos-stream+epel-9-x86_64"; do
for isolation in simple nspawn; do
for bootstrap in bootstrap-chroot no-bootstrap-chroot; do
mock="$MOCKCMD --isolation=$isolation --$bootstrap -r $config"
$mock --install always-installable
$mock --scrub=chroot
$mock --scrub=bootstrap
done
for bootstrap in bootstrap-chroot no-bootstrap-chroot; do
mock="$MOCKCMD $chroot --isolation=$isolation --$bootstrap -r $config"
$mock --install always-installable
$mock --scrub=chroot
$mock --scrub=bootstrap
done
done
done
7 changes: 5 additions & 2 deletions mock/py/mockbuild/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

fallbacks = {
'dnf4': ['dnf4', 'dnf5', 'yum'],
'dnf': ['dnf4', 'dnf5', 'yum'], # backward-compat
'yum': ['yum', 'dnf4', 'dnf5'],
'microdnf': ['microdnf', 'dnf4', 'dnf5', 'yum'],
'dnf5': ['dnf5', 'dnf4', 'yum'],
Expand All @@ -31,7 +30,7 @@ def package_manager_from_string(name):
return Dnf5
if name == 'yum':
return Yum
if name in ['dnf4', 'dnf']: # dnf for backward compat
if name in 'dnf4':
return Dnf
if name == 'microdnf':
return MicroDnf
Expand All @@ -54,6 +53,10 @@ def package_manager_exists(pm_class, config_opts, chroot=None):

def package_manager_class_fallback(config_opts, buildroot, fallback):
desired = config_opts['package_manager']

if desired == 'dnf': # backward compat
desired = 'dnf4'

if not fallback:
return package_manager_from_string(desired)

Expand Down
3 changes: 3 additions & 0 deletions releng/release-notes-next/dnf-to-dnf4-fallback-fix.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A fix for the DNF → DNF4 fallback has been applied. Now Mock correctly selects
DNF4, even when the `--no-bootstrap-chroot` command is used. See
[issue#1475][] for more info.

0 comments on commit 6b4971c

Please sign in to comment.