Fix detecting releasever_minor in dnf-automatic
Resolves: RHEL-106141
This commit is contained in:
parent
c86d9b262f
commit
1cdf57c414
92
0036-automatic-Fix-detecting-releasever_minor.patch
Normal file
92
0036-automatic-Fix-detecting-releasever_minor.patch
Normal file
@ -0,0 +1,92 @@
|
||||
From 341da1e3415980dceaf8d4792f2b46da638a6b10 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Mon, 28 Jul 2025 17:25:09 +0200
|
||||
Subject: [PATCH] automatic: Fix detecting releasever_minor
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Upstream commit: b7eb2e399c42d10444f7d045689fd50f91cf72db
|
||||
|
||||
When running dnf-automatic in RHEL 10.0 where releasever_minor should
|
||||
default to "0", releasever_minor variable was incorrectly detected as
|
||||
undefined. That led to expanding a metalink for an EPEL repository to
|
||||
a wrong URL.
|
||||
|
||||
The cause was a bad logic in updating the release, releasever_major,
|
||||
and releasever_minor triplet in dnf.cli.cli.Cli._read_conf_file():
|
||||
Setting release invalidates releasever_major and releasever_minor. At
|
||||
the same time for backward compatibilty detected release only contains
|
||||
the major number.
|
||||
|
||||
This bug did not manifest in "dnf upgrade" command because "dnf"
|
||||
program does not explicitly construct dnf.Base() before calling
|
||||
_read_conf_file(). That is dnf-automtic first detected releasever=10
|
||||
and releasever_minor=0 when calling _setup_default_conf() via
|
||||
dnf.Base(). But then _read_conf_file() called by dnf-automatic set
|
||||
releasever again to 10, that rewrote releasever_minor to None and
|
||||
then _read_conf_file() set releasever_minor to releasever_minor, i.e
|
||||
to None.
|
||||
|
||||
This patch does not change the code flow to minimize regressions.
|
||||
Instead it saves the original releasever_minor value to be able to
|
||||
default to it again.
|
||||
|
||||
Resolve: #2259
|
||||
Resolve: https://issues.redhat.com/browse/RHEL-106141
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
dnf/cli/cli.py | 8 ++++++--
|
||||
tests/test_config.py | 12 ++++++++++++
|
||||
2 files changed, 18 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
|
||||
index 289c88224..d4bf811c1 100644
|
||||
--- a/dnf/cli/cli.py
|
||||
+++ b/dnf/cli/cli.py
|
||||
@@ -1010,9 +1010,13 @@ class Cli(object):
|
||||
if arg is not None:
|
||||
return arg
|
||||
return None
|
||||
+ # Setting conf.releasever rewrites conf.releasever_major and
|
||||
+ # conf.releasever_minor. Copy them for later use.
|
||||
+ old_releasever_major = conf.releasever_major
|
||||
+ old_releasever_minor = conf.releasever_minor
|
||||
conf.releasever = or_else(releasever, conf.releasever)
|
||||
- conf.releasever_major = or_else(releasever_major, det_major, conf.releasever_major)
|
||||
- conf.releasever_minor = or_else(releasever_minor, det_minor, conf.releasever_minor)
|
||||
+ conf.releasever_major = or_else(releasever_major, det_major, old_releasever_major)
|
||||
+ conf.releasever_minor = or_else(releasever_minor, det_minor, old_releasever_minor)
|
||||
|
||||
if conf.releasever is None:
|
||||
logger.warning(_("Unable to detect release version (use '--releasever' to specify "
|
||||
diff --git a/tests/test_config.py b/tests/test_config.py
|
||||
index 69ba988c4..9445ea29b 100644
|
||||
--- a/tests/test_config.py
|
||||
+++ b/tests/test_config.py
|
||||
@@ -21,6 +21,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
|
||||
+import dnf
|
||||
import dnf.conf
|
||||
import dnf.conf.read
|
||||
import dnf.exceptions
|
||||
@@ -164,3 +165,14 @@ class ConfTest(tests.support.TestCase):
|
||||
self.assertEqual(conf.releasever, '1.2')
|
||||
self.assertEqual(conf.releasever_major, '3')
|
||||
self.assertEqual(conf.releasever_minor, '4')
|
||||
+
|
||||
+ def test__read_conf_file_preserves_autodetected_releasever_major_minor(self):
|
||||
+ base = dnf.Base()
|
||||
+ base.conf.releasever = '1' # Do not set to '1.2', autodetection pretends '1'
|
||||
+ base.conf.releasever_major = '1'
|
||||
+ base.conf.releasever_minor = '2'
|
||||
+ cli = dnf.cli.Cli(base)
|
||||
+ cli._read_conf_file()
|
||||
+ self.assertEqual(base.conf.releasever, '1')
|
||||
+ self.assertEqual(base.conf.releasever_major, '1')
|
||||
+ self.assertEqual(base.conf.releasever_minor, '2')
|
||||
--
|
||||
2.50.1
|
||||
|
6
dnf.spec
6
dnf.spec
@ -72,7 +72,7 @@ It supports RPMs, modules and comps groups & environments.
|
||||
|
||||
Name: dnf
|
||||
Version: 4.20.0
|
||||
Release: 17%{?dist}
|
||||
Release: 18%{?dist}
|
||||
Summary: %{pkg_summary}
|
||||
# For a breakdown of the licensing, see PACKAGE-LICENSING
|
||||
License: GPL-2.0-or-later AND GPL-1.0-only
|
||||
@ -113,6 +113,7 @@ Patch32: 0032-Load-filelists-if-there-are-any-usr_drift_protected_.patch
|
||||
Patch33: 0033-Obsolete-RHEL-9-only-multisig-DNF-plugin.patch
|
||||
Patch34: 0034-Add-deprecation-warning-for-module-commands.patch
|
||||
Patch35: 0035-Add-modularity-deprecation-warning-to-doc-pages.patch
|
||||
Patch36: 0036-automatic-Fix-detecting-releasever_minor.patch
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: cmake
|
||||
@ -474,6 +475,9 @@ popd
|
||||
# bootc subpackage does not include any files
|
||||
|
||||
%changelog
|
||||
* Tue Jul 29 2025 Petr Pisar <ppisar@redhat.com> - 4.20.0-18
|
||||
- Fix detecting releasever_minor in dnf-automatic (RHEL-106141)
|
||||
|
||||
* Fri Jul 18 2025 Evan Goode <egoode@redhat.com> - 4.20.0-17
|
||||
- Add deprecation warning to modularity commands/docs (RHEL-89940)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user