From 52f6abe88c32b3781f26bf710b725d2b7ab14242 Mon Sep 17 00:00:00 2001 From: Yuriy Kohut Date: Mon, 22 Apr 2024 19:37:39 +0300 Subject: [PATCH] Change ELevate patch: enable CentOS Stream release 8 to 9 elevation --- SOURCES/leapp-repository-0.19.0-elevate.patch | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/SOURCES/leapp-repository-0.19.0-elevate.patch b/SOURCES/leapp-repository-0.19.0-elevate.patch index 8cd22b9..8798a65 100644 --- a/SOURCES/leapp-repository-0.19.0-elevate.patch +++ b/SOURCES/leapp-repository-0.19.0-elevate.patch @@ -193,10 +193,10 @@ index f42909f0..f08b7b82 100644 + if not has_grub_cfg: + run(['/sbin/grub2-mkconfig', '-o', grub_cfg_path]) diff --git a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py -index 9e213f64..73197e0b 100644 +index 9e213f64..7abb2b42 100644 --- a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py +++ b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py -@@ -47,6 +47,7 @@ def get_os_release(path): +@@ -47,15 +47,20 @@ def get_os_release(path): :return: `OSRelease` model if the file can be parsed :raises: `IOError` """ @@ -204,7 +204,13 @@ index 9e213f64..73197e0b 100644 try: with open(path) as f: data = dict(l.strip().split('=', 1) for l in f.readlines() if '=' in l) -@@ -55,7 +56,7 @@ def get_os_release(path): ++ release_id = data.get('ID', '').strip('"') ++ version_id = data.get('VERSION_ID', '').strip('"') ++ if release_id == 'centos' and '.' not in version_id: ++ os_version = "{}.999".format(version_id) + return OSRelease( +- release_id=data.get('ID', '').strip('"'), ++ release_id=release_id, name=data.get('NAME', '').strip('"'), pretty_name=data.get('PRETTY_NAME', '').strip('"'), version=data.get('VERSION', '').strip('"'), @@ -295,7 +301,7 @@ index 9dfa0f14..3dc8e6db 100644 context.copytree_from('/etc/rhsm', os.path.join(target_etc, 'rhsm')) # NOTE: we cannot just remove the original target yum.repos.d dir diff --git a/repos/system_upgrade/common/libraries/config/version.py b/repos/system_upgrade/common/libraries/config/version.py -index 0f1e5874..95f0d231 100644 +index 0f1e5874..5eb80c9c 100644 --- a/repos/system_upgrade/common/libraries/config/version.py +++ b/repos/system_upgrade/common/libraries/config/version.py @@ -15,8 +15,8 @@ OP_MAP = { @@ -305,10 +311,48 @@ index 0f1e5874..95f0d231 100644 - '7': {'rhel': ['7.9'], 'rhel-alt': [], 'rhel-saphana': ['7.9']}, - '8': {'rhel': ['8.6', '8.8', '8.9'], 'rhel-saphana': ['8.6', '8.8']}, + '7': {'rhel': ['7.9'], 'rhel-alt': [], 'rhel-saphana': ['7.9'], 'centos': ['7.9'], 'eurolinux': ['7.9'], 'ol': ['7.9'], 'scientific': ['7.9']}, -+ '8': {'rhel': ['8.5', '8.6', '8.8', '8.9', '8.10'], 'rhel-saphana': ['8.6', '8.8', '8.9', '8.10'], 'centos': ['8.5'], 'almalinux': ['8.6', '8.7', '8.8', '8.9', '8.10'], 'eurolinux': ['8.6', '8.7', '8.8', '8.9', '8.10'], 'ol': ['8.6', '8.7', '8.8', '8.9', '8.10'], 'rocky': ['8.6', '8.7', '8.8', '8.9', '8.10']}, ++ '8': {'rhel': ['8.5', '8.6', '8.8', '8.9', '8.10'], 'rhel-saphana': ['8.6', '8.8', '8.9', '8.10'], 'centos': ['8.5', '8.999'], 'almalinux': ['8.6', '8.7', '8.8', '8.9', '8.10'], 'eurolinux': ['8.6', '8.7', '8.8', '8.9', '8.10'], 'ol': ['8.6', '8.7', '8.8', '8.9', '8.10'], 'rocky': ['8.6', '8.7', '8.8', '8.9', '8.10']}, } +diff --git a/repos/system_upgrade/common/libraries/module.py b/repos/system_upgrade/common/libraries/module.py +index abde69e7..7d4e8aa4 100644 +--- a/repos/system_upgrade/common/libraries/module.py ++++ b/repos/system_upgrade/common/libraries/module.py +@@ -1,4 +1,3 @@ +-import os + import warnings + + from leapp.libraries.common.config.version import get_source_major_version +@@ -23,14 +22,20 @@ def _create_or_get_dnf_base(base=None): + # have repositories only for the exact system version (including the minor number). In a case when + # /etc/yum/vars/releasever is present, read its contents so that we can access repositores on such systems. + conf = dnf.conf.Conf() +- pkg_manager = 'yum' if get_source_major_version() == '7' else 'dnf' +- releasever_path = '/etc/{0}/vars/releasever'.format(pkg_manager) +- if os.path.exists(releasever_path): +- with open(releasever_path) as releasever_file: +- releasever = releasever_file.read().strip() +- conf.substitutions['releasever'] = releasever +- else: +- conf.substitutions['releasever'] = get_source_major_version() ++ ++ # preload releasever from what we know, this will be our fallback ++ conf.substitutions['releasever'] = get_source_major_version() ++ ++ # dnf on EL7 doesn't load vars from /etc/yum, so we need to help it a bit ++ if get_source_major_version() == '7': ++ try: ++ with open('/etc/yum/vars/releasever') as releasever_file: ++ conf.substitutions['releasever'] = releasever_file.read().strip() ++ except IOError: ++ pass ++ ++ # load all substitutions from etc ++ conf.substitutions.update_from_etc('/') + + base = dnf.Base(conf=conf) + base.init_plugins() diff --git a/repos/system_upgrade/common/libraries/rhsm.py b/repos/system_upgrade/common/libraries/rhsm.py index 4a5b0eb0..9fdec233 100644 --- a/repos/system_upgrade/common/libraries/rhsm.py