From 72a2c20da6cf1c7b748495876652517ed944d351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Po=C5=82awski?= Date: Fri, 31 Jan 2025 17:48:35 +0100 Subject: [PATCH] Update anaconda variables source Anaconda IsFinal property use to be processed out of ANACONDA_ISFINAL environmental variable. This commit changes this behaviour to use RELEASE_TYPE variable out of /etc/os-release instead. Related change in Fedora spec file: - https://src.fedoraproject.org/rpms/fedora-release/pull-request/347 Resolves: INSTALLER-4068 --- pyanaconda/core/product.py | 13 ++++++++++++- .../pyanaconda_tests/core/test_product.py | 11 ++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pyanaconda/core/product.py b/pyanaconda/core/product.py index 1e126438c567..56ba2620ef4e 100644 --- a/pyanaconda/core/product.py +++ b/pyanaconda/core/product.py @@ -80,7 +80,18 @@ def get_product_values(): # .buildstamp, environment, stupid last ditch hardcoded defaults. config = configparser.ConfigParser() config.add_section("Main") - config.set("Main", "IsFinal", os.environ.get("ANACONDA_ISFINAL", "false")) + + # Get IsFinal property from /etc/os-release file + with open('/etc/os-release') as file: + for line in file: + key, value = line.split('=') + value = value.strip() + if key == 'RELEASE_TYPE': + if value == 'release' or value == 'stable': + config.set("Main", "IsFinal", str(True)) + else: + config.set("Main", "IsFinal", str(False)) + config.set("Main", "Product", os.environ.get("ANACONDA_PRODUCTNAME", "anaconda")) config.set("Main", "Version", os.environ.get("ANACONDA_PRODUCTVERSION", "bluesky")) diff --git a/tests/unit_tests/pyanaconda_tests/core/test_product.py b/tests/unit_tests/pyanaconda_tests/core/test_product.py index f9b252c77bde..047540cd2783 100644 --- a/tests/unit_tests/pyanaconda_tests/core/test_product.py +++ b/tests/unit_tests/pyanaconda_tests/core/test_product.py @@ -154,7 +154,16 @@ def test_buildstamp_multiple(self, mock_cfp_open): @patch("pyanaconda.core.product.configparser.open", side_effect=FileNotFoundError) def test_env(self, mock_cfp_open): """Test product values loaded from environment variables.""" - values = get_product_values() + # ANACONDA_ISFINAL variable is processed out of /etc/os-release host file + FAKE_OS_RELEASE = """\ +NAME="Fedora Linux" +VERSION="41 (Workstation Edition)" +RELEASE_TYPE=stable +ID=fedora +""" + m = mock_open(read_data=FAKE_OS_RELEASE) + with patch("builtins.open", m): + values = get_product_values() expected = ProductData(True, "TestProduct", "rawhide", "testproduct") assert values == expected