diff --git a/craft_application/services/provider.py b/craft_application/services/provider.py index b99e65a2..1be3ce97 100644 --- a/craft_application/services/provider.py +++ b/craft_application/services/provider.py @@ -51,9 +51,14 @@ class ProviderService(base.ProjectService): """Manager for craft_providers in an application. - :param app: Metadata about this application. + :param app: Metadata about this application + :param services: Factory class for lazy-loading service classes :param project: The project model + :param work_dir: The working directory for parts processing + :param build_plan: The filtered build plan of platforms that are valid for + :param provider_name: The provider to use - "lxd" or "multipass" :param install_snap: Whether to install this app's snap from the host (default True) + :param intercept_mknod: If the host can, tell LXD instance to intercept mknod """ managed_mode_env_var = platforms.ENVIRONMENT_CRAFT_MANAGED_MODE @@ -68,6 +73,7 @@ def __init__( build_plan: list[models.BuildInfo], provider_name: str | None = None, install_snap: bool = True, + intercept_mknod: bool = True, ) -> None: super().__init__(app, services, project=project) self._provider: craft_providers.Provider | None = None @@ -75,6 +81,8 @@ def __init__( self._build_plan = build_plan self.snaps: list[Snap] = [] self._install_snap = install_snap + self._intercept_mknod = intercept_mknod + self.environment: dict[str, str | None] = {self.managed_mode_env_var: "1"} self.packages: list[str] = [] # this is a private attribute because it may not reflect the actual @@ -309,7 +317,11 @@ def _get_provider_by_name(self, name: str) -> craft_providers.Provider: def _get_lxd_provider(self) -> LXDProvider: """Get the LXD provider for this manager.""" lxd_remote = self._services.config.get("lxd_remote") - return LXDProvider(lxd_project=self._app.name, lxd_remote=lxd_remote) + return LXDProvider( + lxd_project=self._app.name, + lxd_remote=lxd_remote, + intercept_mknod=self._intercept_mknod, + ) def _get_multipass_provider(self) -> MultipassProvider: """Get the Multipass provider for this manager.""" diff --git a/pyproject.toml b/pyproject.toml index 21186059..33e0dcc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,8 @@ dependencies = [ "craft-grammar>=2.0.0", "craft-parts>=2.1.1", "craft-platforms>=0.5.0", - "craft-providers>=2.1.0", + "craft-providers @ git+https://github.com/canonical/craft-providers.git@work/CRAFT-2568-settable-mknod-intercept", + #"craft-providers>=2.1.0", "Jinja2~=3.1", "snap-helpers>=0.4.2", "platformdirs>=3.10", diff --git a/tests/unit/services/test_provider.py b/tests/unit/services/test_provider.py index c525405b..8061ed4c 100644 --- a/tests/unit/services/test_provider.py +++ b/tests/unit/services/test_provider.py @@ -237,7 +237,7 @@ def test_get_lxd_provider(monkeypatch, provider_service, lxd_remote, check): check.equal(actual, mock_provider.return_value) with check: mock_provider.assert_called_once_with( - lxd_project="testcraft", lxd_remote=lxd_remote + lxd_project="testcraft", lxd_remote=lxd_remote, intercept_mknod=True )