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 28, 2024
1 parent 9e84357 commit d976422
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 11 additions & 8 deletions mock/integration-tests/24-postinstall.tst
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ TMPDIR=$(mktemp -d)
cleanup() { rm -rf "$TMPDIR"; }
trap cleanup EXIT

# Test the default chroot (DNF5) and one with DNF4
for chroot in "" "-r centos-stream+epel-9-x86_64"; do
for isolation in simple nspawn; do
for bootstrap in no-bootstrap-chroot bootstrap-chroot; do
mock="$MOCKCMD --isolation=$isolation --$bootstrap"
: "${TESTSRPM=$TESTDIR/test-C-1.1-0.src.rpm}"
runcmd "$mock --rebuild \"$TESTSRPM\" --postinstall --no-cleanup-after"
runcmd "$mock --shell 'rpm -qa' | grep test-C"
runcmd "$mock --scrub=chroot"
runcmd "$mock --scrub=bootstrap"
done
for bootstrap in no-bootstrap-chroot bootstrap-chroot; do
mock="$MOCKCMD $chroot --isolation=$isolation --$bootstrap"
: "${TESTSRPM=$TESTDIR/test-C-1.1-0.src.rpm}"
runcmd "$mock $chroot --rebuild \"$TESTSRPM\" --postinstall --no-cleanup-after"
runcmd "$mock $chroot --shell 'rpm -qa' | grep test-C"
runcmd "$mock $chroot --scrub=chroot"
runcmd "$mock $chroot --scrub=bootstrap"
done
done
done
exit 0
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 d976422

Please sign in to comment.