From d97ee23962f64a2e4114ac3fc999d93ca0437879 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Mon, 15 Sep 2025 12:06:23 +0000 Subject: [PATCH] import CS kdump-anaconda-addon-006-15.20220128git9603258.el9 --- SOURCES/0003.patch | 58 ++++++++++++++ SOURCES/0004.patch | 137 ++++++++++++++++++++++++++++++++ SPECS/kdump-anaconda-addon.spec | 16 +++- 3 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 SOURCES/0003.patch create mode 100644 SOURCES/0004.patch diff --git a/SOURCES/0003.patch b/SOURCES/0003.patch new file mode 100644 index 0000000..b93410a --- /dev/null +++ b/SOURCES/0003.patch @@ -0,0 +1,58 @@ +From 1434290fa4b5cfdf4aeb944df17b2221954bb722 Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Wed, 19 Mar 2025 17:10:46 +0800 +Subject: [PATCH] Disable kdump.service explicitly if users request to + +Resolves: https://issues.redhat.com/browse/RHEL-41082 + +Currently, kdump.service isn't disabled even users request to. This +happens because RHEL/CentOS systemd presets have kdump.service enabled. +So explicitly disable kdump.service to address this case. + +Signed-off-by: Coiby Xu +--- + com_redhat_kdump/service/installation.py | 7 ++++--- + test/unit_tests/test_installation.py | 6 +++++- + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/com_redhat_kdump/service/installation.py b/com_redhat_kdump/service/installation.py +index bb5bad2..5c5d9c2 100644 +--- a/com_redhat_kdump/service/installation.py ++++ b/com_redhat_kdump/service/installation.py +@@ -138,12 +138,13 @@ class KdumpInstallationTask(Task): + + def run(self): + """Run the task.""" ++ systemctl_action = "enable" + if not self._kdump_enabled: +- log.debug("Kdump is disabled. Skipping.") +- return ++ log.debug("kdump.serivce will be disabled.") ++ systemctl_action = "disable" + + util.execWithRedirect( + "systemctl", +- ["enable", "kdump.service"], ++ [systemctl_action, "kdump.service"], + root=self._sysroot + ) +diff --git a/test/unit_tests/test_installation.py b/test/unit_tests/test_installation.py +index f100dda..e1234be 100644 +--- a/test/unit_tests/test_installation.py ++++ b/test/unit_tests/test_installation.py +@@ -187,7 +187,11 @@ class KdumpInstallationTestCase(TestCase): + kdump_enabled=False + ) + task.run() +- mock_util.execWithRedirect.assert_not_called() ++ mock_util.execWithRedirect.assert_called_once_with( ++ "systemctl", ++ ["disable", "kdump.service"], ++ root="/mnt/sysroot" ++ ) + + @patch("com_redhat_kdump.service.installation.util") + def test_installation_kdump_enabled(self, mock_util): +-- +2.48.1 + diff --git a/SOURCES/0004.patch b/SOURCES/0004.patch new file mode 100644 index 0000000..120ae7a --- /dev/null +++ b/SOURCES/0004.patch @@ -0,0 +1,137 @@ +From 05a6faed1c0f89d21acc0c0d21cda32a9ee75d11 Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Tue, 15 Apr 2025 10:19:16 +0800 +Subject: [PATCH] Handle the case where systemd isn't installed + +Resolvs: https://issues.redhat.com/browse/RHEL-86873 + +Anaconda may be used to create [1] minimal container image which doesn't +have systemd/systemctl installed. + +When using the following kickstart to create a container image, + bootloader --disabled + # boot partitions are irrelevant as the final container image is a tarball + zerombr + clearpart --all + autopart --noboot --nohome --noswap --nolvm --fstype=ext4 + + %addon com_redhat_kdump --disable + %end + + %packages --nocore --excludedocs + redhat-release + bash + rootfiles + coreutils-single + curl-minimal + libcurl-minimal + glibc-minimal-langpack + crypto-policies-scripts + -kernel + -dosfstools + -e2fsprogs + + # s390utils-base needs fuse-libs. Comment it for now. + #-fuse-libs + -gnupg2-smime + -libss # used by e2fsprogs + -pinentry + # gdk-pixbuf2-2.40.0-3.el9.s390x requires shared-mime-info + #-shared-mime-info + -trousers + -xkeyboard-config + -xfsprogs + -qemu-guest-agent + + # For minimal + microdnf + libusbx + -crypto-policies-scripts + %end + + rootpw --lock --iscrypted locked + +Anaconda installation will fail with the following error, + No such file or directory: 'systemctl + +So skip KdumpInstallationTask when systemd/systemctl isn't installed. + +[1] https://issues.redhat.com/browse/RHEL-86873?focusedId=26986146&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-26986146 + +Signed-off-by: Coiby Xu +--- + com_redhat_kdump/service/installation.py | 9 +++++++++ + test/unit_tests/test_installation.py | 19 +++++++++++++++++-- + 2 files changed, 26 insertions(+), 2 deletions(-) + +diff --git a/com_redhat_kdump/service/installation.py b/com_redhat_kdump/service/installation.py +index 5c5d9c2..1e0096a 100644 +--- a/com_redhat_kdump/service/installation.py ++++ b/com_redhat_kdump/service/installation.py +@@ -17,6 +17,7 @@ + # + import logging + import os ++import shutil + + from pyanaconda.core import util + from pyanaconda.modules.common.constants.objects import BOOTLOADER +@@ -138,6 +139,14 @@ class KdumpInstallationTask(Task): + + def run(self): + """Run the task.""" ++ ++ # Anaconda may be used to create minimal container image which doesn't ++ # have systemd installed ++ # https://issues.redhat.com/browse/RHEL-41082?focusedId=26969576&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-26969576 ++ if not shutil.which(self._sysroot + "/systemctl"): ++ log.debug("systemd not installed, skip KdumpInstallationTask") ++ return ++ + systemctl_action = "enable" + if not self._kdump_enabled: + log.debug("kdump.serivce will be disabled.") +diff --git a/test/unit_tests/test_installation.py b/test/unit_tests/test_installation.py +index e1234be..43f5166 100644 +--- a/test/unit_tests/test_installation.py ++++ b/test/unit_tests/test_installation.py +@@ -181,7 +181,9 @@ class KdumpInstallationTestCase(TestCase): + assert mock_exec.call_count == 2 + + @patch("com_redhat_kdump.service.installation.util") +- def test_installation_kdump_disabled(self, mock_util): ++ @patch("shutil.which") ++ def test_installation_kdump_disabled(self, mock_shutil, mock_util): ++ mock_shutil.return_value = True + task = KdumpInstallationTask( + sysroot="/mnt/sysroot", + kdump_enabled=False +@@ -194,7 +196,9 @@ class KdumpInstallationTestCase(TestCase): + ) + + @patch("com_redhat_kdump.service.installation.util") +- def test_installation_kdump_enabled(self, mock_util): ++ @patch("shutil.which") ++ def test_installation_kdump_enabled(self, mock_shutil, mock_util): ++ mock_shutil.return_value = True + task = KdumpInstallationTask( + sysroot="/mnt/sysroot", + kdump_enabled=True +@@ -205,3 +209,14 @@ class KdumpInstallationTestCase(TestCase): + ["enable", "kdump.service"], + root="/mnt/sysroot" + ) ++ ++ @patch("com_redhat_kdump.service.installation.util") ++ @patch("shutil.which") ++ def test_installation_kdump_disable_no_systemctl(self, mock_shutil, mock_util): ++ mock_shutil.return_value = False ++ task = KdumpInstallationTask( ++ sysroot="/mnt/sysroot", ++ kdump_enabled=False ++ ) ++ task.run() ++ mock_util.execWithRedirect.assert_not_called() +-- +2.49.0 + diff --git a/SPECS/kdump-anaconda-addon.spec b/SPECS/kdump-anaconda-addon.spec index e760369..9dadc56 100644 --- a/SPECS/kdump-anaconda-addon.spec +++ b/SPECS/kdump-anaconda-addon.spec @@ -4,7 +4,7 @@ Name: kdump-anaconda-addon Version: 006 -Release: 13.%{snapshotdate}git%{gitshortcommit}%{?dist} +Release: 15.%{snapshotdate}git%{gitshortcommit}%{?dist} Url: https://github.com/daveyoung/kdump-anaconda-addon License: GPLv2 Summary: Kdump configuration anaconda addon @@ -21,6 +21,8 @@ Source0: https://github.com/daveyoung/kdump-anaconda-addon/archive/%{gitcommit}/ Patch1: 0001.patch Patch2: 0002.patch +Patch3: 0003.patch +Patch4: 0004.patch %description Kdump anaconda addon @@ -44,13 +46,19 @@ Kdump anaconda addon %{_datadir}/icons/hicolor/scalable/apps/kdump.svg %changelog -* Thu Jan 20 2022 Coiby - 006-1.20220128git9603258 +* Tue Apr 29 2025 Coiby Xu - 006-15.20220128git9603258 +- Handle the case where systemd isn't installed (RHEL-86873) + +* Tue Mar 25 2025 Coiby Xu - 006-14.20220128git9603258 +- Disable kdump.service explicitly if users request to (RHEL-41082) + +* Thu Jan 20 2022 Coiby - 006-13.20220128git9603258 - Update to latest git snapshot (20220128). Resolves: bz2046612 -* Thu Jan 20 2022 Coiby - 006-1.20220120git44fe737 +* Thu Jan 20 2022 Coiby - 006-12.20220120git44fe737 - Update to latest git snapshot (20220120). Resolves: bz2003131 -* Thu Jan 13 2022 Coiby - 006-1.20220113git4c5a91d +* Thu Jan 13 2022 Coiby - 006-11.20220113git4c5a91d - Update to latest git snapshot (20220113). Resolves: bz2034491 * Thu Oct 14 2021 Kairui Song - 006-10.20211014git641a7b7