- Fix handling of LVM and Multipath during the upgrade - Fix remediation command for making symlinks in root directory relative - Remove RPM GPG keys of the source distribution when upgrading and converting the system - Replace distro specific packages during upgrade and conversion - Improve error message when scanning invalid SSHD configuration - Update the leapp data files - Minor changes in logs and reports - Resolves: RHEL-14712, RHEL-30447, RHEL-19247, RHEL-127066, RHEL-124923, RHEL-119516
187 lines
8.1 KiB
Diff
187 lines
8.1 KiB
Diff
From 656e301fe7749a77f7f4a5c652610ac27105dd33 Mon Sep 17 00:00:00 2001
|
|
From: Matej Matuska <mmatuska@redhat.com>
|
|
Date: Thu, 21 Aug 2025 19:50:32 +0200
|
|
Subject: [PATCH 104/111] scanpkgmanager: Remove yum-related code
|
|
|
|
---
|
|
.../scanpkgmanager/libraries/pluginscanner.py | 21 ++++++-------------
|
|
.../libraries/scanpkgmanager.py | 13 ++++--------
|
|
.../tests/test_pluginscanner.py | 16 ++------------
|
|
.../tests/test_scanpkgmanager.py | 11 +++-------
|
|
4 files changed, 15 insertions(+), 46 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/scanpkgmanager/libraries/pluginscanner.py b/repos/system_upgrade/common/actors/scanpkgmanager/libraries/pluginscanner.py
|
|
index 7bb03996..f83050ee 100644
|
|
--- a/repos/system_upgrade/common/actors/scanpkgmanager/libraries/pluginscanner.py
|
|
+++ b/repos/system_upgrade/common/actors/scanpkgmanager/libraries/pluginscanner.py
|
|
@@ -1,6 +1,5 @@
|
|
import re
|
|
|
|
-from leapp.libraries.common.config.version import get_source_major_version
|
|
from leapp.libraries.stdlib import run
|
|
|
|
# When the output spans multiple lines, each of the lines after the first one
|
|
@@ -50,7 +49,7 @@ def _parse_loaded_plugins(package_manager_output):
|
|
|
|
def scan_enabled_package_manager_plugins():
|
|
"""
|
|
- Runs package manager (yum/dnf) command and parses its output for enabled/loaded plugins.
|
|
+ Runs package manager (dnf) command and parses its output for enabled/loaded plugins.
|
|
|
|
:return: A list of enabled plugins.
|
|
:rtype: List
|
|
@@ -60,16 +59,8 @@ def scan_enabled_package_manager_plugins():
|
|
# An alternative approach would be to check the install path for package manager plugins
|
|
# and parse corresponding plugin configuration files.
|
|
|
|
- if get_source_major_version() == '7':
|
|
- # in case of yum, set debuglevel=2 to be sure the output is always
|
|
- # same. The format of data is different for various debuglevels
|
|
- cmd = ['yum', '--setopt=debuglevel=2']
|
|
- else:
|
|
- # the verbose mode in dnf always set particular debuglevel, so the
|
|
- # output is not affected by the default debug level set on the
|
|
- # system
|
|
- cmd = ['dnf', '-v'] # On RHEL8 we need to supply an extra switch
|
|
-
|
|
- pkg_manager_output = run(cmd, split=True, checked=False) # The command will certainly fail (does not matter).
|
|
-
|
|
- return _parse_loaded_plugins(pkg_manager_output)
|
|
+ # the verbose mode in dnf always set particular debuglevel, so the
|
|
+ # output is not affected by the default debug level set on the
|
|
+ # system
|
|
+ output = run(['dnf', '-v'], split=True, checked=False) # The command will certainly fail (does not matter).
|
|
+ return _parse_loaded_plugins(output)
|
|
diff --git a/repos/system_upgrade/common/actors/scanpkgmanager/libraries/scanpkgmanager.py b/repos/system_upgrade/common/actors/scanpkgmanager/libraries/scanpkgmanager.py
|
|
index bf7ec0be..2fcac423 100644
|
|
--- a/repos/system_upgrade/common/actors/scanpkgmanager/libraries/scanpkgmanager.py
|
|
+++ b/repos/system_upgrade/common/actors/scanpkgmanager/libraries/scanpkgmanager.py
|
|
@@ -2,17 +2,13 @@ import os
|
|
import re
|
|
|
|
from leapp.libraries.actor import pluginscanner
|
|
-from leapp.libraries.common.config.version import get_source_major_version
|
|
from leapp.libraries.stdlib import api
|
|
from leapp.models import PkgManagerInfo
|
|
|
|
YUM_CONFIG_PATH = '/etc/yum.conf'
|
|
DNF_CONFIG_PATH = '/etc/dnf/dnf.conf'
|
|
|
|
-
|
|
-def _get_releasever_path():
|
|
- default_manager = 'yum' if get_source_major_version() == '7' else 'dnf'
|
|
- return '/etc/{}/vars/releasever'.format(default_manager)
|
|
+RELEASEVER_PATH = '/etc/dnf/vars/releasever'
|
|
|
|
|
|
def _releasever_exists(releasever_path):
|
|
@@ -20,13 +16,12 @@ def _releasever_exists(releasever_path):
|
|
|
|
|
|
def get_etc_releasever():
|
|
- """ Get release version from "/etc/{yum,dnf}/vars/releasever" file """
|
|
+ """ Get release version from "/etc/dnf/vars/releasever" file """
|
|
|
|
- releasever_path = _get_releasever_path()
|
|
- if not _releasever_exists(releasever_path):
|
|
+ if not _releasever_exists(RELEASEVER_PATH):
|
|
return None
|
|
|
|
- with open(releasever_path, 'r') as fo:
|
|
+ with open(RELEASEVER_PATH, 'r') as fo:
|
|
# we care about the first line only
|
|
releasever = fo.readline().strip()
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_pluginscanner.py b/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_pluginscanner.py
|
|
index f0260e54..0b2bd5b7 100644
|
|
--- a/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_pluginscanner.py
|
|
+++ b/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_pluginscanner.py
|
|
@@ -21,18 +21,11 @@ def assert_plugins_identified_as_enabled(expected_plugins, identified_plugins):
|
|
assert expected_enabled_plugin in identified_plugins, fail_description
|
|
|
|
|
|
-@pytest.mark.parametrize(
|
|
- ('source_major_version', 'command'),
|
|
- [
|
|
- ('7', ['yum', '--setopt=debuglevel=2']),
|
|
- ('8', ['dnf', '-v']),
|
|
- ]
|
|
-)
|
|
-def test_scan_enabled_plugins(monkeypatch, source_major_version, command):
|
|
+def test_scan_enabled_plugins(monkeypatch):
|
|
"""Tests whether the enabled plugins are correctly retrieved from the package manager output."""
|
|
|
|
def run_mocked(cmd, **kwargs):
|
|
- if cmd == command:
|
|
+ if cmd == ['dnf', '-v']:
|
|
return {
|
|
'stdout': CMD_YUM_OUTPUT.split('\n'),
|
|
'stderr': 'You need to give some command',
|
|
@@ -40,13 +33,9 @@ def test_scan_enabled_plugins(monkeypatch, source_major_version, command):
|
|
}
|
|
raise ValueError('Tried to run an unexpected command.')
|
|
|
|
- def get_source_major_version_mocked():
|
|
- return source_major_version
|
|
-
|
|
# The library imports `run` all the way into its namespace (from ...stdlib import run),
|
|
# we must overwrite it there then:
|
|
monkeypatch.setattr(pluginscanner, 'run', run_mocked)
|
|
- monkeypatch.setattr(pluginscanner, 'get_source_major_version', get_source_major_version_mocked)
|
|
|
|
enabled_plugins = pluginscanner.scan_enabled_package_manager_plugins()
|
|
assert_plugins_identified_as_enabled(
|
|
@@ -72,7 +61,6 @@ def test_yum_loaded_plugins_multiline_output(yum_output, monkeypatch):
|
|
}
|
|
|
|
monkeypatch.setattr(pluginscanner, 'run', run_mocked)
|
|
- monkeypatch.setattr(pluginscanner, 'get_source_major_version', lambda: '7')
|
|
|
|
enabled_plugins = pluginscanner.scan_enabled_package_manager_plugins()
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_scanpkgmanager.py b/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_scanpkgmanager.py
|
|
index 75c5c5ba..dc94060a 100644
|
|
--- a/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_scanpkgmanager.py
|
|
+++ b/repos/system_upgrade/common/actors/scanpkgmanager/tests/test_scanpkgmanager.py
|
|
@@ -2,15 +2,12 @@ import os
|
|
|
|
import pytest
|
|
|
|
-from leapp.libraries import stdlib
|
|
from leapp.libraries.actor import pluginscanner, scanpkgmanager
|
|
-from leapp.libraries.common import testutils
|
|
from leapp.libraries.common.testutils import CurrentActorMocked, produce_mocked
|
|
from leapp.libraries.stdlib import api
|
|
|
|
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
PROXY_ADDRESS = 'https://192.168.121.123:3128'
|
|
-YUM_CONFIG_PATH = '/etc/yum.conf'
|
|
DNF_CONFIG_PATH = '/etc/dnf/dnf.conf'
|
|
|
|
|
|
@@ -22,10 +19,6 @@ def mock_releasever_exists(overrides):
|
|
return mocked_releasever_exists
|
|
|
|
|
|
-def mocked_get_releasever_path():
|
|
- return os.path.join(CUR_DIR, 'files/releasever')
|
|
-
|
|
-
|
|
@pytest.mark.parametrize('etcrelease_exists', [True, False])
|
|
def test_get_etcreleasever(monkeypatch, etcrelease_exists):
|
|
monkeypatch.setattr(
|
|
@@ -38,7 +31,9 @@ def test_get_etcreleasever(monkeypatch, etcrelease_exists):
|
|
)
|
|
monkeypatch.setattr(scanpkgmanager.api, 'produce', produce_mocked())
|
|
monkeypatch.setattr(scanpkgmanager.api, 'current_actor', CurrentActorMocked())
|
|
- monkeypatch.setattr(scanpkgmanager, '_get_releasever_path', mocked_get_releasever_path)
|
|
+ monkeypatch.setattr(
|
|
+ scanpkgmanager, 'RELEASEVER_PATH', os.path.join(CUR_DIR, 'files/releasever')
|
|
+ )
|
|
monkeypatch.setattr(scanpkgmanager, '_get_proxy_if_set', lambda x: None)
|
|
monkeypatch.setattr(pluginscanner, 'scan_enabled_package_manager_plugins', lambda: [])
|
|
|
|
--
|
|
2.52.0
|
|
|