Skip to content

Commit

Permalink
fix(lifecycle): return correct base when using devel for build-base
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
syu-w committed Jan 19, 2024
1 parent b9d13d7 commit 6fd97ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion snapcraft/parts/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions snapcraft/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/commands/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6fd97ec

Please sign in to comment.