From ba7171481bc712cf6b5e87a58bd309527b26adb4 Mon Sep 17 00:00:00 2001 From: Yuriy Kohut Date: Mon, 23 Jun 2025 12:42:03 +0300 Subject: [PATCH] Add Vendors patch created against upstream hash 2646484407bef15688fb4838c2f61d06f2098f81 Bump version to 0.22.0-3.elevate.2 --- SOURCES/leapp-repository-0.22.0-elevate.patch | 262 ++++++++++++++++++ SPECS/leapp-repository.spec | 6 +- 2 files changed, 267 insertions(+), 1 deletion(-) diff --git a/SOURCES/leapp-repository-0.22.0-elevate.patch b/SOURCES/leapp-repository-0.22.0-elevate.patch index 307ceb8..6e7be6a 100644 --- a/SOURCES/leapp-repository-0.22.0-elevate.patch +++ b/SOURCES/leapp-repository-0.22.0-elevate.patch @@ -1,3 +1,60 @@ +diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml +index 37748396..ed82e0e5 100644 +--- a/.github/workflows/unit-tests.yml ++++ b/.github/workflows/unit-tests.yml +@@ -9,43 +9,43 @@ on: + + jobs: + test: +- name: Run unit tests in containers ++ name: 'Run: ${{ matrix.scenarios.name }}' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + scenarios: + # 9to10 +- - name: Run unit tests for el9toel10 and common repositories on python 3.12 ++ - name: 'Unit tests (python:3.12; repos:el9toel10,common)' + python: python3.12 + repos: 'el9toel10,common' + container: ubi9 +- - name: Run python linters for el9toel10 and common repositories on python 3.12 ++ - name: 'Linters (python:3.12; repos:el9toel10,common)' + python: python3.12 + repos: 'el9toel10,common' + container: ubi9-lint +- - name: Run unit tests for el9toel10 and common repositories on python 3.9 ++ - name: 'Unit tests (python:3.9; repos:el9toel10,common)' + python: python3.9 + repos: 'el9toel10,common' + container: ubi9 +- - name: Run python linters for el9toel10 and common repositories on python 3.9 ++ - name: 'Linters (python:3.9; repos:el9toel10,common)' + python: python3.9 + repos: 'el9toel10,common' + container: ubi9-lint + # 8to9 +- - name: Run unit tests for el8toel9 and common repositories on python 3.9 ++ - name: 'Unit tests (python:3.9; repos:el8toel9,common)' + python: python3.9 + repos: 'el8toel9,common' + container: ubi9 +- - name: Run python linters for el8toel9 and common repositories on python 3.9 ++ - name: 'Linters (python:3.9; repos:el8toel9,common)' + python: python3.9 + repos: 'el8toel9,common' + container: ubi9-lint +- - name: Run unit tests for el8toel9 and common repositories on python 3.6 ++ - name: 'Unit tests (python:3.6; repos:el8toel9,common)' + python: python3.6 + repos: 'el8toel9,common' + container: ubi8 +- - name: Run python linters for el8toel9 and common repositories on python 3.6 ++ - name: 'Linters (python:3.6; repos:el8toel9,common)' + python: python3.6 + repos: 'el8toel9,common' + container: ubi8-lint diff --git a/.gitignore b/.gitignore index 0bb92d3d..a04c7ded 100644 --- a/.gitignore @@ -10,6 +67,75 @@ index 0bb92d3d..a04c7ded 100644 # pycharm .idea +diff --git a/Makefile b/Makefile +index ceb013ab..6769b2f3 100644 +--- a/Makefile ++++ b/Makefile +@@ -164,9 +164,9 @@ help: + @echo " PR=7 SUFFIX='my_additional_suffix' make " + @echo " MR=6 COPR_CONFIG='path/to/the/config/copr/file' make " + @echo " ACTOR= TEST_LIBS=y make test" +- @echo " BUILD_CONTAINER=el7 make build_container" ++ @echo " BUILD_CONTAINER=rhel8 make build_container" + @echo " TEST_CONTAINER=f34 make test_container" +- @echo " CONTAINER_TOOL=docker TEST_CONTAINER=rhel7 make test_container_no_lint" ++ @echo " CONTAINER_TOOL=docker TEST_CONTAINER=rhel8 make test_container_no_lint" + @echo "" + + clean: +@@ -459,30 +459,33 @@ test_container: + $(_CONTAINER_TOOL) ps -q -f name=$$_CONT_NAME && { $(_CONTAINER_TOOL) kill $$_CONT_NAME; $(_CONTAINER_TOOL) rm $$_CONT_NAME; }; \ + $(_CONTAINER_TOOL) run -di --name $$_CONT_NAME -v "$$PWD":/repo:Z -e PYTHON_VENV=$$_VENV $$TEST_IMAGE && \ + $(_CONTAINER_TOOL) exec $$_CONT_NAME rsync -aur --delete --exclude "tut*" /repo/ /repocopy && \ ++ export res=0; \ + case $$_VENV in \ + python2.7) \ +- TEST_CONT_IPU=el7toel8 $(MAKE) _test_container_ipu; \ ++ TEST_CONT_IPU=el7toel8 $(MAKE) _test_container_ipu || res=1; \ + ;;\ + python3.6) \ +- TEST_CONT_IPU=el7toel8 $(MAKE) _test_container_ipu; \ +- TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu; \ ++ echo "INFO: Skipping testing of el7toel8 repository. Obsoleted"; \ ++ TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu || res=1; \ + ;; \ + python3.9) \ +- TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu; \ +- TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu; \ ++ TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu || res=1; \ ++ TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu || res=1; \ + ;; \ + python3.12) \ +- TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu; \ ++ TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu || res=1; \ + ;; \ + *) \ +- TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu; \ +- ;;\ ++ TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu || res=1; \ ++ ;; \ + esac; \ + $(_CONTAINER_TOOL) kill $$_CONT_NAME; \ +- $(_CONTAINER_TOOL) rm $$_CONT_NAME ++ $(_CONTAINER_TOOL) rm $$_CONT_NAME; \ ++ [ $$res -ne 0 ] && echo "TIP: If you do not see an error in the end of logs, scroll up. Multiple tests could be executed." ; \ ++ exit $$res + + test_container_all: +- @for container in "f34" "rhel7" "rhel8"; do \ ++ @for container in "f34" "rhel7" "rhel8" "rhel9"; do \ + TEST_CONTAINER=$$container $(MAKE) test_container || exit 1; \ + done + +@@ -490,7 +493,7 @@ test_container_no_lint: + @_TEST_CONT_TARGET="test_no_lint" $(MAKE) test_container + + test_container_all_no_lint: +- @for container in "f34" "rhel7" "rhel8"; do \ ++ @for container in "f34" "rhel7" "rhel8" "rhel9"; do \ + TEST_CONTAINER=$$container $(MAKE) test_container_no_lint || exit 1; \ + done + diff --git a/ci/.gitignore b/ci/.gitignore new file mode 100644 index 00000000..e6f97f0f @@ -4158,6 +4284,142 @@ index 43ac1fc4..62aefaf4 100644 + to_reinstall=to_reinstall_filtered, to_keep=load_tasks_file(os.path.join(base_dir, 'to_keep'), logger), to_remove=load_tasks_file(os.path.join(base_dir, 'to_remove'), logger)) +diff --git a/repos/system_upgrade/common/actors/scankernelcmdline/actor.py b/repos/system_upgrade/common/actors/scankernelcmdline/actor.py +index 9f8fef30..2f1a5ae2 100644 +--- a/repos/system_upgrade/common/actors/scankernelcmdline/actor.py ++++ b/repos/system_upgrade/common/actors/scankernelcmdline/actor.py +@@ -1,12 +1,12 @@ + from leapp.actors import Actor +-from leapp.libraries.stdlib import run +-from leapp.models import KernelCmdline, KernelCmdlineArg ++from leapp.libraries.actor import scankernelcmdline ++from leapp.models import KernelCmdline + from leapp.tags import FactsPhaseTag, IPUWorkflowTag + + + class ScanKernelCmdline(Actor): + """ +- No documentation has been provided for the scan_kernel_cmdline actor. ++ Scan the kernel command line of the booted system. + """ + + name = 'scan_kernel_cmdline' +@@ -15,12 +15,4 @@ class ScanKernelCmdline(Actor): + tags = (FactsPhaseTag, IPUWorkflowTag) + + def process(self): +- cmdline = run(['cat', '/proc/cmdline'])['stdout'].strip() +- parameters = [] +- for parameter in cmdline.split(' '): +- if '=' in parameter: +- kv = parameter.split('=') +- parameters.append(KernelCmdlineArg(key=kv[0], value=kv[1])) +- else: +- parameters.append(KernelCmdlineArg(key=parameter)) +- self.produce(KernelCmdline(parameters=parameters)) ++ scankernelcmdline.parse_cmdline_input() +diff --git a/repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py b/repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py +new file mode 100644 +index 00000000..9cffa70e +--- /dev/null ++++ b/repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py +@@ -0,0 +1,23 @@ ++from leapp.libraries.stdlib import api, CalledProcessError, run ++from leapp.models import KernelCmdline, KernelCmdlineArg ++ ++ ++def get_cmdline_input(): ++ try: ++ cmdline_input = run(['cat', '/proc/cmdline'])['stdout'].strip() ++ return cmdline_input ++ except (OSError, CalledProcessError): ++ api.current_logger().debug('Executing `cat /proc/cmdline` failed', exc_info=True) ++ return '' ++ ++ ++def parse_cmdline_input(): ++ cmdline = get_cmdline_input() ++ parameters = [] ++ for parameter in cmdline.split(' '): ++ if '=' in parameter: ++ kv = parameter.split('=', 1) ++ parameters.append(KernelCmdlineArg(key=kv[0], value=kv[1])) ++ else: ++ parameters.append(KernelCmdlineArg(key=parameter)) ++ api.produce(KernelCmdline(parameters=parameters)) +diff --git a/repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py b/repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py +new file mode 100644 +index 00000000..ff79054f +--- /dev/null ++++ b/repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py +@@ -0,0 +1,67 @@ ++import pytest ++ ++from leapp.libraries.actor import scankernelcmdline ++from leapp.libraries.common.testutils import CurrentActorMocked, produce_mocked ++from leapp.libraries.stdlib import api, CalledProcessError ++from leapp.models import KernelCmdline, KernelCmdlineArg ++ ++ ++def mock_cmd_output(): ++ expected_cmd_output = ( ++ 'BOOT_IMAGE=(hd0,msdos1)/vmlinuz-xxx root=UUID=some_uid ro console=tty0' ++ ' console=ttyS0,115200 rd_NO_PLYMOUTH biosdevname=0 net.ifnames=0 crashkernel=auto' ++ ) ++ return expected_cmd_output ++ ++ ++def test_cmdline_output(monkeypatch): ++ ++ monkeypatch.setattr(scankernelcmdline, 'get_cmdline_input', mock_cmd_output) ++ current_actor = CurrentActorMocked(src_ver='8.10', dst_ver='9.6') ++ monkeypatch.setattr(api, 'current_actor', current_actor) ++ monkeypatch.setattr(api, 'produce', produce_mocked()) ++ ++ scankernelcmdline.parse_cmdline_input() ++ ++ expected_params = [KernelCmdlineArg(key=k, value=v) for k, v in [ ++ ('BOOT_IMAGE', '(hd0,msdos1)/vmlinuz-xxx'), ++ ('root', 'UUID=some_uid'), ++ ('ro', None), ++ ('console', 'tty0'), ++ ('console', 'ttyS0,115200'), ++ ('rd_NO_PLYMOUTH', None), ++ ('biosdevname', '0'), ++ ('net.ifnames', '0'), ++ ('crashkernel', 'auto')]] ++ ++ expected_output_msg = KernelCmdline(parameters=expected_params) ++ assert api.produce.model_instances ++ assert expected_output_msg == api.produce.model_instances[0] ++ ++ ++def test_cmdline_content(monkeypatch): ++ ++ def run_mocked(cmd, **kwargs): ++ assert cmd == ['cat', '/proc/cmdline'] ++ output = mock_cmd_output() ++ return {'stdout': output} ++ ++ monkeypatch.setattr(scankernelcmdline, 'run', run_mocked) ++ cmd_output = scankernelcmdline.get_cmdline_input() ++ expected_cmd_output = mock_cmd_output() ++ ++ assert cmd_output == expected_cmd_output ++ ++ ++@pytest.mark.parametrize('is_os_error', [True, False]) ++def test_cmdline_run_failed(monkeypatch, is_os_error): ++ ++ def run_mocked_error(cmd, **kwargs): ++ assert cmd == ['cat', '/proc/cmdline'] ++ if is_os_error: ++ raise OSError('OSError raised') ++ raise CalledProcessError("CalledProcessError raised", cmd, "result") ++ ++ monkeypatch.setattr(scankernelcmdline, 'run', run_mocked_error) ++ cmd_output = scankernelcmdline.get_cmdline_input() ++ assert cmd_output == '' diff --git a/repos/system_upgrade/common/actors/scanvendorrepofiles/actor.py b/repos/system_upgrade/common/actors/scanvendorrepofiles/actor.py new file mode 100644 index 00000000..a5e481cb diff --git a/SPECS/leapp-repository.spec b/SPECS/leapp-repository.spec index 9809ff9..29fe795 100644 --- a/SPECS/leapp-repository.spec +++ b/SPECS/leapp-repository.spec @@ -53,7 +53,7 @@ py2_byte_compile "%1" "%2"} Epoch: 1 Name: leapp-repository Version: 0.22.0 -Release: 3%{?dist}.elevate.1 +Release: 3%{?dist}.elevate.2 Summary: Repositories for leapp License: ASL 2.0 @@ -408,6 +408,10 @@ ln -s 10.0 %{next_major_ver} # no files here %changelog +* Mon Jun 23 2025 Yuriy Kohut - 0.22.0-3.elevate.2 +- Update ELevate patch: + - rebase to upstream hash 2646484407bef15688fb4838c2f61d06f2098f81 + * Thu May 15 2025 Yuriy Kohut - 0.22.0-3.elevate.1 - Update ELevate patch: - rebase to upstream 0.22.0-3 (hash ffd6d8e456484630f99d98d5bff955914af02aa5)