From 6fd97ec2a591e6bd161e50e3016a8d6130ae487a Mon Sep 17 00:00:00 2001 From: Sheng Yu Date: Fri, 19 Jan 2024 15:31:30 -0500 Subject: [PATCH] fix(lifecycle): return correct base when using devel for build-base get_effective_base() should not return "devel" and pass it to the PartsLifecycle(), which make the parts think the coreXX is "devel". Thus checking the wrong path for dynamic linking. --- snapcraft/parts/yaml_utils.py | 2 +- snapcraft/utils.py | 14 ++++++++++---- tests/unit/commands/test_remote.py | 5 ++++- tests/unit/test_utils.py | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/snapcraft/parts/yaml_utils.py b/snapcraft/parts/yaml_utils.py index ca2bba350d..053c957c8b 100644 --- a/snapcraft/parts/yaml_utils.py +++ b/snapcraft/parts/yaml_utils.py @@ -33,7 +33,7 @@ _CORE_PART_NAME = "snapcraft/core" # All bases recognized by snapcraft -BASES = {"core", "core18", "core20", "core22", "devel"} +BASES = {"core", "core18", "core20", "core22", "core24", "devel"} # Bases no longer supported by the current version of snapcraft ESM_BASES = {"core", "core18"} # Bases handled by the legacy snapcraft codebase diff --git a/snapcraft/utils.py b/snapcraft/utils.py index 77c76c6b0e..8dcdb84f14 100644 --- a/snapcraft/utils.py +++ b/snapcraft/utils.py @@ -216,14 +216,20 @@ def get_effective_base( ) -> Optional[str]: """Return the base to use to create the snap. - Returns build-base if set, but if not, name is returned if the - snap is of type base. For all other snaps, the base is returned - as the build-base. + Return the build-base if set. + Exception: + "base" snaps will return name if build-base is not set. + "devel" snaps, return the base, where the true base is, except "base" snaps. """ + if project_type == "base": + return build_base if build_base else name + if build_base is not None: + if build_base == "devel": + return base return build_base - return name if project_type == "base" else base + return base def get_parallel_build_count() -> int: diff --git a/tests/unit/commands/test_remote.py b/tests/unit/commands/test_remote.py index 10167887d0..27c9156bc5 100644 --- a/tests/unit/commands/test_remote.py +++ b/tests/unit/commands/test_remote.py @@ -277,7 +277,10 @@ def test_get_effective_base_with_build_base( cli.run() - mock_run_new_or_fallback_remote_build.assert_called_once_with(build_base) + if build_base == "devel": + mock_run_new_or_fallback_remote_build.assert_called_once_with(base) + else: + mock_run_new_or_fallback_remote_build.assert_called_once_with(build_base) @pytest.mark.usefixtures("mock_argv", "mock_confirm") diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 9807f5ec5c..35c1aa904a 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -118,6 +118,8 @@ def test_strtobool_value_error(value: str): (None, None, "other", "name", None), ("base", "build_base", "other", "name", "build_base"), ("base", None, "other", "name", "base"), + ("base", "devel", "other", "name", "base"), + ("base", "devel", "base", "name", "devel"), ], ) def test_get_effective_base(base, build_base, project_type, name, expected_base):