Skip to content

Commit

Permalink
fix: allow coreXX-desktop bases
Browse files Browse the repository at this point in the history
Fixes #4818
  • Loading branch information
lengau committed Jun 11, 2024
1 parent 6aa3696 commit 578cfc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion snapcraft/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,15 @@ def _providers_base(cls, base: str) -> bases.BaseAlias | None:
"""
if base == "bare":
return None
# Desktop bases are extended versions of the regular core bases.
# For bases that end with "-desktop", use the equivalent provider base.
if base.endswith("-desktop"):
core_base = base.rpartition("-")[0]
else:
core_base = base

try:
return SNAPCRAFT_BASE_TO_PROVIDER_BASE[base]
return SNAPCRAFT_BASE_TO_PROVIDER_BASE[core_base]
except KeyError as err:
raise CraftValidationError(f"Unknown base {base!r}") from err

Expand Down
7 changes: 6 additions & 1 deletion tests/unit/models/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,12 @@ def test_project_build_base_devel_grade_stable_error(self, project_yaml_data):

@pytest.mark.parametrize(
("base", "expected_base"),
[("bare", None), *providers.SNAPCRAFT_BASE_TO_PROVIDER_BASE.items()],
[
("bare", None),
*providers.SNAPCRAFT_BASE_TO_PROVIDER_BASE.items(),
("core22-desktop", providers.SNAPCRAFT_BASE_TO_PROVIDER_BASE["core22"]),
("core24-desktop", providers.SNAPCRAFT_BASE_TO_PROVIDER_BASE["core24"]),
],
)
def test_provider_base(self, base, expected_base, project_yaml_data):
providers_base = Project._providers_base(base)
Expand Down

0 comments on commit 578cfc1

Please sign in to comment.