Skip to content

Commit

Permalink
build providers: set snapd proxy settings prior to _setup_snapcraft()
Browse files Browse the repository at this point in the history
Snaps may be installed in _setup_snapcraft(), which runs before
_setup_snapd_proxy().

It works when snaps are injected from the host, but the snapd
proxy must be configured in case the host does not provide the
required snaps.

Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
  • Loading branch information
Chris Patterson committed Oct 29, 2020
1 parent 4d863eb commit 6e52c3e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions snapcraft/internal/build_providers/_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def _mount(self, host_source: str, target: str) -> None:
"""Mount host source directory to target mount point."""

def mount_project(self) -> None:
"""Provider steps needed to make the project available to the instance.
"""
"""Provider steps needed to make the project available to the instance."""
target = (self._get_home_directory() / "project").as_posix()
self._mount(self.project._project_dir, target)

Expand All @@ -180,8 +179,7 @@ def _mount_ssh(self) -> None:
self._mount(src, target)

def expose_prime(self) -> None:
"""Provider steps needed to expose the prime directory to the host.
"""
"""Provider steps needed to expose the prime directory to the host."""
os.makedirs(self.project.prime_dir, exist_ok=True)
if not self._mount_prime_directory():
self._run(command=["snapcraft", "clean", "--unprime"])
Expand Down Expand Up @@ -254,14 +252,15 @@ def launch_instance(self) -> None:
# image, but may be required for snapcraft to function.
self._run(["apt-get", "install", "--yes", "apt-transport-https"])

# Always update snapd proxy settings to match current http(s) proxy
# settings. All providers should have installed snapd upon completion
# of _setup_environment().
self._setup_snapd_proxy()

# Always setup snapcraft after a start to bring it up to speed with
# what is on the host.
self._setup_snapcraft()

# Always update snapd proxy settings to match current http(s) proxy
# settings.
self._setup_snapd_proxy()

# Install any CA certificates requested by the user.
certs_path = self.build_provider_flags.get("SNAPCRAFT_ADD_CA_CERTIFICATES")
if certs_path:
Expand Down

0 comments on commit 6e52c3e

Please sign in to comment.