Skip to content

Commit

Permalink
fix: 24.04 package clash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yanksyoon committed Jan 10, 2025
1 parent 024ea8e commit 685d9be
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
16 changes: 12 additions & 4 deletions rockcraft/extensions/expressjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class ExpressJSFramework(Extension):
"package-lock.json",
]
BUILD_GENERATED_DIRS = ["node_modules", ".npmrc"]
RUNTIME_SLICES = [
"ca-certificates_data",
RUNTIME_SLICES = ["ca-certificates_data"]
BARE_RUNTIME_SLICES = [
"bash_bins",
"coreutils_bins",
"libc6_libs",
Expand All @@ -68,7 +68,7 @@ def get_root_snippet(self) -> dict[str, Any]:
Default values:
- run_user: _daemon_
- build-base: ubuntu:22.04 (only if user specify bare without a build-base)
- build-base: ubuntu:24.04
- platform: amd64
- services: a service to run the ExpressJS server
- parts: see ExpressJSFramework._gen_parts
Expand Down Expand Up @@ -131,11 +131,19 @@ def _gen_install_app_part(self) -> dict:

def _gen_runtime_part(self) -> dict:
"""Generate the runtime debs part."""
runtime_packages = [*self.RUNTIME_SLICES]
if self._rock_base == "bare":
runtime_packages += [*self.BARE_RUNTIME_SLICES]
return {
"plugin": "nil",
"stage-packages": self.RUNTIME_SLICES,
"stage-packages": runtime_packages,
}

@property
def _rock_base(self) -> str:
"""Return the base of the rockcraft project."""
return self.yaml_data["base"]

@property
def _app_package_json(self) -> dict:
"""Return the app package.json contents."""
Expand Down
37 changes: 30 additions & 7 deletions tests/unit/extensions/test_expressjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ def test_expressjs_extension_default(
},
"expressjs-framework/runtime": {
"plugin": "nil",
"stage-packages": [
"ca-certificates_data",
"bash_bins",
"coreutils_bins",
"libc6_libs",
"libnode109_libs",
],
"stage-packages": ["ca-certificates_data"],
},
},
"services": {
Expand Down Expand Up @@ -200,3 +194,32 @@ def test_expressjs_install_app_prime_to_organize_map(
applied["parts"]["expressjs-framework/install-app"]["organize"]
== expected_organize
)


@pytest.mark.parametrize(
"rock_base, expected_runtime_packages",
[
pytest.param(
"bare",
[
"ca-certificates_data",
"bash_bins",
"coreutils_bins",
"libc6_libs",
"libnode109_libs",
],
id="bare",
),
pytest.param("[email protected]", ["ca-certificates_data"], id="[email protected]"),
],
)
@pytest.mark.usefixtures("expressjs_extension", "package_json_file")
def test_expressjs_gen_runtime_part(
tmp_path, expressjs_input_yaml, rock_base, expected_runtime_packages
):
expressjs_input_yaml["base"] = rock_base
applied = extensions.apply_extensions(tmp_path, expressjs_input_yaml)
assert (
applied["parts"]["expressjs-framework/runtime"]["stage-packages"]
== expected_runtime_packages
)

0 comments on commit 685d9be

Please sign in to comment.