From 26a6ecdc6c188849e1264b278104ab1e7ad6de56 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Tue, 14 Nov 2023 16:18:12 +0100 Subject: [PATCH] Use 'os.uname().machine' to get machine architecture instead of 'uname -i' uname -i returns unknown. Resolves: rhbz#2248930 --- pyanaconda/modules/payloads/payload/dnf/installation.py | 2 +- .../payloads/payload/test_module_payload_dnf_installation.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyanaconda/modules/payloads/payload/dnf/installation.py b/pyanaconda/modules/payloads/payload/dnf/installation.py index 222cceebb58..d5722fd7688 100644 --- a/pyanaconda/modules/payloads/payload/dnf/installation.py +++ b/pyanaconda/modules/payloads/payload/dnf/installation.py @@ -360,7 +360,7 @@ def run(self): # Get substitutions for variables. # TODO: replace the interpolation with DNF once possible - basearch = util.execWithCapture("uname", ["-i"]).strip().replace("'", "") + basearch = os.uname().machine releasever = util.get_os_release_value("VERSION_ID", sysroot=self._sysroot) or "" # Import GPG keys to RPM database. diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py index 8914c3b5102..f8dc81857e7 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py @@ -196,11 +196,12 @@ def test_import_keys(self, mock_exec): call("rpm", ["--import", key_2], root=sysroot), ]) + @patch("pyanaconda.modules.payloads.payload.dnf.installation.os.uname") @patch("pyanaconda.modules.payloads.payload.dnf.installation.util") - def test_import_substitution(self, mock_util): + def test_import_substitution(self, mock_util, mock_uname): """Import GPG keys with variables.""" mock_util.execWithRedirect.return_value = 0 - mock_util.execWithCapture.return_value = "s390x" + mock_uname.return_value = Mock(machine='s390x') mock_util.get_os_release_value.return_value = "34" key = "/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch"