From 22cd1f3f409439da98a2f378ee2aeb3bb76562c2 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Mon, 9 Sep 2024 15:06:30 -0500 Subject: [PATCH 01/14] docs(changelog): add 8.3.3 release notes Signed-off-by: Callahan Kovacs --- docs/reference/changelog.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/reference/changelog.rst b/docs/reference/changelog.rst index ff8ef38273..de12b1aee6 100644 --- a/docs/reference/changelog.rst +++ b/docs/reference/changelog.rst @@ -230,6 +230,27 @@ Documentation For a complete list of commits, check out the `8.4.0`_ release on GitHub. +8.3.3 (2024-Aug-28) +------------------- + +Core +==== + +* Improve detection and error messages when LXD is not installed or not + properly enabled. + +Bases +##### + +core24 +"""""" + +* Require Multipass >= ``1.14.1`` when using Multipass to build ``core24`` + snaps. + +For a complete list of commits, check out the `8.3.3`_ release on GitHub. + + .. _7.5.6_changelog: 7.5.6 (2024-Aug-15) @@ -1215,5 +1236,6 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _8.3.0: https://github.com/canonical/snapcraft/releases/tag/8.3.0 .. _8.3.1: https://github.com/canonical/snapcraft/releases/tag/8.3.1 .. _8.3.2: https://github.com/canonical/snapcraft/releases/tag/8.3.2 +.. _8.3.3: https://github.com/canonical/snapcraft/releases/tag/8.3.3 .. _8.4.0: https://github.com/canonical/snapcraft/releases/tag/8.4.0 .. _8.4.1: https://github.com/canonical/snapcraft/releases/tag/8.4.1 From 1df696d689d114567786679c1807debca9aeb1ee Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Fri, 13 Sep 2024 12:53:01 -0500 Subject: [PATCH 02/14] docs(changelog): add 8.3.4 release notes Signed-off-by: Callahan Kovacs --- docs/reference/changelog.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/reference/changelog.rst b/docs/reference/changelog.rst index de12b1aee6..fbc344f8ac 100644 --- a/docs/reference/changelog.rst +++ b/docs/reference/changelog.rst @@ -129,6 +129,23 @@ Store For a complete list of changes, check out the `8.4.1`_ release on GitHub. +8.3.4 (2024-Sep-13) +------------------- + +Core +==== + +Plugins +####### + +NPM +""" +* Fix a bug where NPM parts fail to build if the ``pull`` and ``build`` steps + did not occur in the same execution of Snapcraft. + +For a complete list of commits, check out the `8.3.4`_ release on GitHub. + + 8.4.0 (2024-Sep-10) ------------------- @@ -1237,5 +1254,6 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _8.3.1: https://github.com/canonical/snapcraft/releases/tag/8.3.1 .. _8.3.2: https://github.com/canonical/snapcraft/releases/tag/8.3.2 .. _8.3.3: https://github.com/canonical/snapcraft/releases/tag/8.3.3 +.. _8.3.4: https://github.com/canonical/snapcraft/releases/tag/8.3.4 .. _8.4.0: https://github.com/canonical/snapcraft/releases/tag/8.4.0 .. _8.4.1: https://github.com/canonical/snapcraft/releases/tag/8.4.1 From caa0757c2f9d7e072898ce3b5136149cb395f712 Mon Sep 17 00:00:00 2001 From: Callahan Date: Wed, 2 Oct 2024 09:36:19 -0500 Subject: [PATCH 03/14] fix(remotebuild): do not auto clean interrupted builds (#5081) Fixes a bug where the remote builder would ignore the user and always clean the launchpad project. Also drops some magic values in favor of constants. Fixes #4929 Signed-off-by: Callahan Kovacs --- snapcraft/commands/remote.py | 9 +++++--- tests/unit/commands/test_remote.py | 33 ++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/snapcraft/commands/remote.py b/snapcraft/commands/remote.py index 2ac7b0e2b3..a38ea34a1f 100644 --- a/snapcraft/commands/remote.py +++ b/snapcraft/commands/remote.py @@ -308,7 +308,7 @@ def _run( # noqa: PLR0915 [too-many-statements] emit.progress("Remote repository already exists.", permanent=True) emit.progress("Cleaning up") builder.cleanup() - return 75 + return os.EX_TEMPFAIL try: returncode = self._monitor_and_complete(build_id, builds) @@ -316,10 +316,13 @@ def _run( # noqa: PLR0915 [too-many-statements] if confirm_with_user("Cancel builds?", default=True): emit.progress("Cancelling builds.") builder.cancel_builds() - returncode = 0 + emit.progress("Cleaning up.") + builder.cleanup() + return os.EX_OK except Exception: # noqa: BLE001 [blind-except] returncode = 1 # General error on any other exception - if returncode != 75: # TimeoutError + + if returncode != os.EX_TEMPFAIL: emit.progress("Cleaning up") builder.cleanup() return returncode diff --git a/tests/unit/commands/test_remote.py b/tests/unit/commands/test_remote.py index 6ebdc50633..c50abc9b21 100644 --- a/tests/unit/commands/test_remote.py +++ b/tests/unit/commands/test_remote.py @@ -22,7 +22,7 @@ import sys import time from pathlib import Path -from unittest.mock import ANY, Mock +from unittest.mock import ANY, Mock, call import pytest from craft_application import launchpad @@ -1019,9 +1019,13 @@ def test_monitor_build_error(mocker, emitter, snapcraft_yaml, base, fake_service @pytest.mark.parametrize("base", const.CURRENT_BASES) -@pytest.mark.usefixtures("mock_confirm") -def test_monitor_build_interrupt(mocker, emitter, snapcraft_yaml, base, fake_services): +@pytest.mark.parametrize("cleanup", [True, False]) +def test_monitor_build_interrupt( + cleanup, mock_confirm, mocker, emitter, snapcraft_yaml, base, fake_services +): """Test the monitor_build cleanup when a keyboard interrupt occurs.""" + # first prompt is for public upload, second is to cancel builds + mock_confirm.side_effect = [True, cleanup] mocker.patch.object(sys, "argv", ["snapcraft", "remote-build"]) snapcraft_yaml_dict = {"base": base, "build-base": "devel", "grade": "devel"} snapcraft_yaml(**snapcraft_yaml_dict) @@ -1043,6 +1047,10 @@ def test_monitor_build_interrupt(mocker, emitter, snapcraft_yaml, base, fake_ser "craft_application.services.remotebuild.RemoteBuildService.cleanup" ) + mock_cancel_builds = mocker.patch( + "craft_application.services.remotebuild.RemoteBuildService.cancel_builds" + ) + app = application.create_app() app.services.remote_build._name = get_build_id( app.services.app.name, app.project.name, app.project_dir @@ -1050,15 +1058,24 @@ def test_monitor_build_interrupt(mocker, emitter, snapcraft_yaml, base, fake_ser app.services.remote_build._is_setup = True app.services.remote_build.request.download_files_with_progress = Mock() - assert app.run() == 0 + assert app.run() == os.EX_OK mock_start_builds.assert_called_once() mock_monitor_builds.assert_called_once() mock_fetch_logs.assert_not_called() - mock_cleanup.assert_called_once() - emitter.assert_progress("Cancelling builds.") - emitter.assert_progress("Cleaning up") + cancel_emitted = call("progress", "Cancelling builds.") in emitter.interactions + clean_emitted = call("progress", "Cleaning up.") in emitter.interactions + if cleanup: + mock_cancel_builds.assert_called_once() + assert cancel_emitted + mock_cleanup.assert_called_once() + assert clean_emitted + else: + mock_cancel_builds.assert_not_called() + assert not cancel_emitted + mock_cleanup.assert_not_called() + assert not clean_emitted @pytest.mark.parametrize("base", const.CURRENT_BASES) @@ -1091,7 +1108,7 @@ def test_monitor_build_timeout(mocker, emitter, snapcraft_yaml, base, fake_servi app.services.app.name, app.project.name, app.project_dir ) - assert app.run() == 75 + assert app.run() == os.EX_TEMPFAIL mock_start_builds.assert_called_once() mock_monitor_builds.assert_called_once() From 1b5789fa81eb7560c3e27c9f932aa4fc436dea09 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Tue, 1 Oct 2024 12:46:59 -0500 Subject: [PATCH 04/14] build(deps): bump craft-store to 3.0.2 Signed-off-by: Callahan Kovacs --- requirements-devel.txt | 2 +- requirements-docs.txt | 2 +- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements-devel.txt b/requirements-devel.txt index 515ced5b6b..0b60799231 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -31,7 +31,7 @@ craft-grammar==2.0.1 craft-parts==2.1.1 craft-platforms==0.1.1 craft-providers==2.0.1 -craft-store==3.0.1 +craft-store==3.0.2 cryptography==43.0.1 cssutils==2.11.1 dict2css==0.3.0.post1 diff --git a/requirements-docs.txt b/requirements-docs.txt index 665fa0369f..31ce1e69fe 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -26,7 +26,7 @@ craft-grammar==2.0.1 craft-parts==2.1.1 craft-platforms==0.1.1 craft-providers==2.0.1 -craft-store==3.0.1 +craft-store==3.0.2 cryptography==43.0.1 cssutils==2.11.1 dict2css==0.3.0.post1 diff --git a/requirements.txt b/requirements.txt index 45c38f3fc6..b0d657e27a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ craft-grammar==2.0.1 craft-parts==2.1.1 craft-platforms==0.1.1 craft-providers==2.0.1 -craft-store==3.0.1 +craft-store==3.0.2 cryptography==43.0.1 distro==1.9.0 docutils==0.19 diff --git a/setup.py b/setup.py index 78ee0a0b6a..f81a57187d 100755 --- a/setup.py +++ b/setup.py @@ -105,7 +105,7 @@ def recursive_data_files(directory, install_directory): "craft-parts~=2.1", "craft-platforms~=0.1", "craft-providers~=2.0", - "craft-store>=3.0.1,<4.0.0", + "craft-store>=3.0.2,<4.0.0", "docutils<0.20", # Frozen until we can update sphinx dependencies. "gnupg", "jsonschema==2.5.1", From 5693b96eac6d04864d9ba448b33ae5330d62127e Mon Sep 17 00:00:00 2001 From: Dariusz Duda Date: Mon, 23 Sep 2024 17:38:33 -0400 Subject: [PATCH 05/14] fix: correctly set PIP_NO_BINARY Signed-off-by: Dariusz Duda --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 70754e382e..119cbef6e7 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -171,7 +171,7 @@ parts: build-environment: # Build PyNaCl from source since the wheel files interact # strangely with classic snaps. Well, build it all from source. - - "PIP_NO_BINARY": ":all" + - "PIP_NO_BINARY": ":all:" # Use base image's libsodium for PyNaCl. - "SODIUM_INSTALL": "system" - "CFLAGS": "$(pkg-config python-3.10 yaml-0.1 --cflags)" From bf90e90abbf733d824a0a54f350112a95236c25f Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Wed, 2 Oct 2024 13:46:26 -0500 Subject: [PATCH 06/14] build(deps): bump libgit2 to 1.7.2 Signed-off-by: Callahan Kovacs --- snap/snapcraft.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 119cbef6e7..ebbfea1d71 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -140,11 +140,12 @@ parts: -e 's/^ENABLE_USER_SITE = None$/ENABLE_USER_SITE = False/' libgit2: - source: https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.1.tar.gz - source-checksum: sha256/17d2b292f21be3892b704dddff29327b3564f96099a1c53b00edc23160c71327 + source: https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.2.tar.gz + source-checksum: sha256/de384e29d7efc9330c6cdb126ebf88342b5025d920dcb7c645defad85195ea7f plugin: cmake cmake-parameters: - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_BUILD_TYPE=RelWithDebInfo build-attributes: - enable-patchelf prime: From 495c41f0441fc375e95b9a8e3a14e5880c5d7caa Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Thu, 3 Oct 2024 08:48:19 -0500 Subject: [PATCH 07/14] build(deps): point craft-providers to 2.0.3 Signed-off-by: Callahan Kovacs --- requirements-devel.txt | 2 +- requirements-docs.txt | 2 +- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements-devel.txt b/requirements-devel.txt index 0b60799231..f9daa0d898 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -30,7 +30,7 @@ craft-cli==2.7.0 craft-grammar==2.0.1 craft-parts==2.1.1 craft-platforms==0.1.1 -craft-providers==2.0.1 +craft-providers==2.0.3 craft-store==3.0.2 cryptography==43.0.1 cssutils==2.11.1 diff --git a/requirements-docs.txt b/requirements-docs.txt index 31ce1e69fe..06ab3d0070 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -25,7 +25,7 @@ craft-cli==2.7.0 craft-grammar==2.0.1 craft-parts==2.1.1 craft-platforms==0.1.1 -craft-providers==2.0.1 +craft-providers==2.0.3 craft-store==3.0.2 cryptography==43.0.1 cssutils==2.11.1 diff --git a/requirements.txt b/requirements.txt index b0d657e27a..f6eac1072b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ craft-cli==2.7.0 craft-grammar==2.0.1 craft-parts==2.1.1 craft-platforms==0.1.1 -craft-providers==2.0.1 +craft-providers==2.0.3 craft-store==3.0.2 cryptography==43.0.1 distro==1.9.0 diff --git a/setup.py b/setup.py index f81a57187d..351f5a9379 100755 --- a/setup.py +++ b/setup.py @@ -104,7 +104,7 @@ def recursive_data_files(directory, install_directory): "craft-grammar>=2.0.1,<3.0.0", "craft-parts~=2.1", "craft-platforms~=0.1", - "craft-providers~=2.0", + "craft-providers>=2.0.3,<3.0.0", "craft-store>=3.0.2,<4.0.0", "docutils<0.20", # Frozen until we can update sphinx dependencies. "gnupg", From 78af8ea0b7859e090a886b627de463260f6d9a66 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Thu, 3 Oct 2024 07:55:42 -0500 Subject: [PATCH 08/14] refactor: rename snap_name Rename legacy variables to match snapd's definition: snap_name->snap_instance_name (possibly aliased) snap_store_name->snap_name (unaliased) Signed-off-by: Callahan Kovacs --- .../internal/build_providers/_snap.py | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/snapcraft_legacy/internal/build_providers/_snap.py b/snapcraft_legacy/internal/build_providers/_snap.py index 7bbb8b0063..6c56822670 100644 --- a/snapcraft_legacy/internal/build_providers/_snap.py +++ b/snapcraft_legacy/internal/build_providers/_snap.py @@ -58,9 +58,10 @@ def __init__( latest_revision: Optional[str], inject_from_host: bool = True ) -> None: - self.snap_name = snap_name - # the local snap name may have a suffix if it was installed with `--name` - self.snap_store_name = snap_name.split("_")[0] + # name of the snap instance, which may have an alias + self.snap_instance_name = snap_name + # name of the snap (no alias) + self.snap_name = snap_name.split("_")[0] self._remote_snap_dir = remote_snap_dir self._inject_from_host = inject_from_host @@ -74,7 +75,7 @@ def __init__( def _get_snap_repo(self): if self.__repo is None: - self.__repo = repo.snaps.SnapPackage(self.snap_name) + self.__repo = repo.snaps.SnapPackage(self.snap_instance_name) return self.__repo def get_op(self) -> _SnapOp: @@ -125,7 +126,7 @@ def get_op(self) -> _SnapOp: # This is a programmatic error raise RuntimeError( "Unhandled scenario for {!r} (host installed: {}, latest_revision {})".format( - self.snap_name, is_installed, self._latest_revision + self.snap_instance_name, is_installed, self._latest_revision ) ) @@ -136,9 +137,9 @@ def push_host_snap(self, *, file_pusher: Callable[..., None]) -> None: # TODO not being able to lock down on a snap revision can lead to races. host_snap_repo = self._get_snap_repo() with tempfile.TemporaryDirectory() as temp_dir: - snap_file_path = os.path.join(temp_dir, "{}.snap".format(self.snap_name)) + snap_file_path = os.path.join(temp_dir, "{}.snap".format(self.snap_instance_name)) assertion_file_path = os.path.join( - temp_dir, "{}.assert".format(self.snap_name) + temp_dir, "{}.assert".format(self.snap_instance_name) ) host_snap_repo.local_download( snap_path=snap_file_path, assertion_path=assertion_file_path @@ -171,7 +172,7 @@ def _set_data(self) -> None: switch_cmd = [ "snap", "switch", - self.snap_name, + self.snap_instance_name, "--channel", snap_channel, ] @@ -198,9 +199,9 @@ def _set_data(self) -> None: elif op == _SnapOp.INSTALL or op == _SnapOp.REFRESH: install_cmd = ["snap", op.name.lower()] - snap_channel = _get_snap_channel(self.snap_store_name) + snap_channel = _get_snap_channel(self.snap_name) - store_snap_info = storeapi.SnapAPI().get_info(self.snap_store_name) + store_snap_info = storeapi.SnapAPI().get_info(self.snap_name) snap_channel_map = store_snap_info.get_channel_mapping( risk=snap_channel.risk, track=snap_channel.track ) @@ -208,7 +209,7 @@ def _set_data(self) -> None: if snap_channel_map.confinement == "classic": install_cmd.append("--classic") install_cmd.extend(["--channel", snap_channel_map.channel_details.name]) - install_cmd.append(self.snap_store_name) + install_cmd.append(self.snap_name) self.__install_cmd = install_cmd self.__switch_cmd = switch_cmd @@ -224,7 +225,7 @@ def get_revision(self) -> str: # Shouldn't happen. raise RuntimeError( "Unhandled scenario for {!r} (revision {})".format( - self.snap_name, self.__revision + self.snap_instance_name, self.__revision ) ) @@ -238,7 +239,7 @@ def get_snap_install_cmd(self) -> List[str]: if self.__install_cmd is None: raise RuntimeError( "Unhandled scenario for {!r} (install_cmd {})".format( - self.snap_name, self.__install_cmd + self.snap_instance_name, self.__install_cmd ) ) @@ -259,7 +260,7 @@ def get_assertion_ack_cmd(self) -> List[str]: if self.__assertion_ack_cmd is None: raise RuntimeError( "Unhandled scenario for {!r} (assertion_ack_cmd {})".format( - self.snap_name, self.__assertion_ack_cmd + self.snap_instance_name, self.__assertion_ack_cmd ) ) @@ -379,7 +380,7 @@ def apply(self) -> None: return # Allow using snapd from the snapd snap to leverage newer snapd features. - if any(s.snap_name == "snapd" for s in self._snaps): + if any(s.snap_instance_name == "snapd" for s in self._snaps): self._enable_snapd_snap() # Disable refreshes so they do not interfere with installation ops. @@ -396,6 +397,6 @@ def apply(self) -> None: self._runner(snap.get_snap_install_cmd()) if snap.get_channel_switch_cmd() is not None: self._runner(snap.get_channel_switch_cmd()) - self._record_revision(snap.snap_store_name, snap.get_revision()) + self._record_revision(snap.snap_name, snap.get_revision()) _save_registry(self._registry_data, self._registry_filepath) From 6c18404b365d392e5d72254f1cd3242e5329162b Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Thu, 3 Oct 2024 08:51:30 -0500 Subject: [PATCH 09/14] fix(snapcraft_legacy): get assertions for aliased snaps Signed-off-by: Callahan Kovacs --- .../internal/build_providers/_snap.py | 6 +- snapcraft_legacy/internal/repo/snaps.py | 8 +- .../legacy/unit/build_providers/test_snap.py | 118 ++++++++++++++++++ tests/legacy/unit/repo/test_snaps.py | 42 +++++++ 4 files changed, 168 insertions(+), 6 deletions(-) diff --git a/snapcraft_legacy/internal/build_providers/_snap.py b/snapcraft_legacy/internal/build_providers/_snap.py index 6c56822670..28a9d757f1 100644 --- a/snapcraft_legacy/internal/build_providers/_snap.py +++ b/snapcraft_legacy/internal/build_providers/_snap.py @@ -170,11 +170,7 @@ def _set_data(self) -> None: if not snap_revision.startswith("x") and snap_channel: switch_cmd = [ - "snap", - "switch", - self.snap_instance_name, - "--channel", - snap_channel, + "snap", "switch", self.snap_name, "--channel", snap_channel ] if snap_revision.startswith("x"): diff --git a/snapcraft_legacy/internal/repo/snaps.py b/snapcraft_legacy/internal/repo/snaps.py index 75e286c5fc..0a779b0550 100644 --- a/snapcraft_legacy/internal/repo/snaps.py +++ b/snapcraft_legacy/internal/repo/snaps.py @@ -179,7 +179,13 @@ def local_download(self, *, snap_path: str, assertion_path: str) -> None: # We write an empty assertions file for dangerous installs to # have a consistent interface. if self.has_assertions(): - assertions.append(["snap-declaration", "snap-name={}".format(self.name)]) + assertions.append( + [ + "snap-declaration", + # use the snap name without any alias + f"snap-name={self.name.partition('_')[0]}" + ] + ) assertions.append( [ "snap-revision", diff --git a/tests/legacy/unit/build_providers/test_snap.py b/tests/legacy/unit/build_providers/test_snap.py index 40bff35b19..762ad15c88 100644 --- a/tests/legacy/unit/build_providers/test_snap.py +++ b/tests/legacy/unit/build_providers/test_snap.py @@ -162,6 +162,124 @@ def test_snapcraft_installed_on_host_from_store(self): ), ) + def test_snapcraft_installed_on_host_aliased_from_store(self): + self.fake_snapd.snaps_result = [ + { + "name": "snapd", + "confinement": "strict", + "id": "2kkitQ", + "channel": "edge", + "revision": "1", + "tracking-channel": "latest/edge", + }, + { + "name": "core18", + "confinement": "strict", + "id": "2kkibb", + "channel": "stable", + "revision": "123", + "tracking-channel": "latest/beta", + }, + { + "name": "snapcraft_alias", + "confinement": "classic", + "id": "3lljuR", + "channel": "edge", + "revision": "345", + "tracking-channel": "latest/candidate", + }, + ] + self.get_assertion_mock.side_effect = [ + b"fake-assertion-account-store", + b"fake-assertion-declaration-snapd", + b"fake-assertion-revision-snapd-1", + b"fake-assertion-account-store", + b"fake-assertion-declaration-core18", + b"fake-assertion-revision-core18-123", + b"fake-assertion-account-store", + b"fake-assertion-declaration-snapcraft", + b"fake-assertion-revision-snapcraft-345", + ] + + snap_injector = SnapInjector( + registry_filepath=self.registry_filepath, + runner=self.provider._run, + file_pusher=self.provider._push_file, + ) + snap_injector.add("snapd") + snap_injector.add("core18") + snap_injector.add("snapcraft_alias") + snap_injector.apply() + + get_assertion_calls = [ + call( + [ + "account-key", + "public-key-sha3-384=BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul", + ] + ), + call(["snap-declaration", "snap-name=snapd"]), + call(["snap-revision", "snap-revision=1", "snap-id=2kkitQ"]), + call( + [ + "account-key", + "public-key-sha3-384=BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul", + ] + ), + call(["snap-declaration", "snap-name=core18"]), + call(["snap-revision", "snap-revision=123", "snap-id=2kkibb"]), + call( + [ + "account-key", + "public-key-sha3-384=BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul", + ] + ), + call(["snap-declaration", "snap-name=snapcraft"]), + call(["snap-revision", "snap-revision=345", "snap-id=3lljuR"]), + ] + self.get_assertion_mock.assert_has_calls(get_assertion_calls) + self.provider.run_mock.assert_has_calls( + [ + call(["snap", "set", "system", "experimental.snapd-snap=true"]), + call(["snap", "set", "system", ANY]), + call(["snap", "watch", "--last=auto-refresh?"]), + call(["snap", "ack", "/var/tmp/snapd.assert"]), + call(["snap", "install", "/var/tmp/snapd.snap"]), + call(["snap", "switch", "snapd", "--channel", "latest/edge"]), + call(["snap", "ack", "/var/tmp/core18.assert"]), + call(["snap", "install", "/var/tmp/core18.snap"]), + call(["snap", "switch", "core18", "--channel", "latest/beta"]), + call(["snap", "ack", "/var/tmp/snapcraft_alias.assert"]), + call(["snap", "install", "--classic", "/var/tmp/snapcraft_alias.snap"]), + call(["snap", "switch", "snapcraft", "--channel", "latest/candidate"]), + ] + ) + self.provider.push_file_mock.assert_has_calls( + [ + call(source=ANY, destination="/var/tmp/snapd.snap"), + call(source=ANY, destination="/var/tmp/snapd.assert"), + call(source=ANY, destination="/var/tmp/core18.snap"), + call(source=ANY, destination="/var/tmp/core18.assert"), + call(source=ANY, destination="/var/tmp/snapcraft_alias.snap"), + call(source=ANY, destination="/var/tmp/snapcraft_alias.assert"), + ] + ) + self.assertThat( + self.registry_filepath, + FileContains( + dedent( + """\ + core18: + - revision: '123' + snapcraft: + - revision: '345' + snapd: + - revision: '1' + """ + ) + ), + ) + def test_snapcraft_installed_on_host_from_store_but_injection_disabled(self): self.useFixture(fixture_setup.FakeStore()) diff --git a/tests/legacy/unit/repo/test_snaps.py b/tests/legacy/unit/repo/test_snaps.py index bf7f8ffcb6..13d813dbc3 100644 --- a/tests/legacy/unit/repo/test_snaps.py +++ b/tests/legacy/unit/repo/test_snaps.py @@ -348,6 +348,48 @@ def test_download_from_host(self): ] ) + def test_download_from_host_alias(self): + """Download an aliased snap from the host.""" + fake_get_assertion = fixtures.MockPatch( + "snapcraft_legacy.internal.repo.snaps.get_assertion", + return_value=b"foo-assert", + ) + self.useFixture(fake_get_assertion) + + self.fake_snapd.snaps_result = [ + { + "id": "fake-snap-id", + "name": "fake-snap_alias", + "channel": "stable", + "revision": "10", + } + ] + + snap_pkg = snaps.SnapPackage("fake-snap_alias/strict/stable") + snap_pkg.local_download( + snap_path="fake-snap.snap", assertion_path="fake-snap.assert" + ) + + self.assertThat("fake-snap.snap", FileExists()) + self.assertThat( + "fake-snap.assert", FileContains("foo-assert\nfoo-assert\nfoo-assert\n") + ) + fake_get_assertion.mock.assert_has_calls( + [ + mock.call( + [ + "account-key", + "public-key-sha3-384=BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul", + ] + ), + # uses the non-aliased name + mock.call(["snap-declaration", "snap-name=fake-snap"]), + mock.call( + ["snap-revision", "snap-revision=10", "snap-id=fake-snap-id"] + ), + ] + ) + def test_download_from_host_dangerous(self): fake_get_assertion = fixtures.MockPatch( "snapcraft_legacy.internal.repo.snaps.get_assertion", From 604e927299751955c246096fa8f01e5d020fafbc Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Fri, 4 Oct 2024 15:56:43 -0500 Subject: [PATCH 10/14] build(deps): switch to requests-unixsocket2 Signed-off-by: Callahan Kovacs --- requirements-devel.txt | 14 +++++++------- requirements-docs.txt | 14 +++++++------- requirements.txt | 14 +++++++------- setup.py | 9 ++++----- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/requirements-devel.txt b/requirements-devel.txt index f9daa0d898..da45be35cf 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -24,13 +24,13 @@ click==8.1.7 codespell==2.3.0 colorama==0.4.6 coverage==7.6.1 -craft-application==4.2.4 +craft-application==4.2.6 craft-archives==2.0.0 craft-cli==2.7.0 craft-grammar==2.0.1 -craft-parts==2.1.1 +craft-parts==2.1.2 craft-platforms==0.1.1 -craft-providers==2.0.3 +craft-providers==2.0.4 craft-store==3.0.2 cryptography==43.0.1 cssutils==2.11.1 @@ -108,7 +108,7 @@ pyftpdlib==1.5.10 pygit2==1.13.3 Pygments==2.18.0 pylint==3.2.7 -pylxd==2.3.4 +pylxd==2.3.5 pymacaroons==0.13.0 PyNaCl==1.5.0 pyparsing==3.1.4 @@ -128,9 +128,9 @@ pyxdg==0.28 PyYAML==6.0.2 raven==6.10.0 regex==2024.7.24 -requests==2.31.0 +requests==2.32.3 requests-toolbelt==1.0.0 -requests-unixsocket==0.3.0 +requests-unixsocket2==0.4.2 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.8 SecretStorage==3.3.3 @@ -182,7 +182,7 @@ types-toml==0.10.8.20240310 types-urllib3==1.26.25.14 typing_extensions==4.12.2 uc-micro-py==1.0.3 -urllib3==1.26.20 +urllib3==2.2.3 uvicorn==0.30.6 validators==0.33.0 venusian==3.1.0 diff --git a/requirements-docs.txt b/requirements-docs.txt index 06ab3d0070..1c690ec149 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -19,13 +19,13 @@ chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 -craft-application==4.2.4 +craft-application==4.2.6 craft-archives==2.0.0 craft-cli==2.7.0 craft-grammar==2.0.1 -craft-parts==2.1.1 +craft-parts==2.1.2 craft-platforms==0.1.1 -craft-providers==2.0.3 +craft-providers==2.0.4 craft-store==3.0.2 cryptography==43.0.1 cssutils==2.11.1 @@ -81,7 +81,7 @@ pydantic_yaml==1.3.0 pyelftools==0.31 pygit2==1.13.3 Pygments==2.18.0 -pylxd==2.3.4 +pylxd==2.3.5 pymacaroons==0.13.0 PyNaCl==1.5.0 pyparsing==3.1.4 @@ -94,9 +94,9 @@ pyxdg==0.28 PyYAML==6.0.2 raven==6.10.0 regex==2024.7.24 -requests==2.31.0 +requests==2.32.3 requests-toolbelt==1.0.0 -requests-unixsocket==0.3.0 +requests-unixsocket2==0.4.2 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.8 SecretStorage==3.3.3 @@ -136,7 +136,7 @@ tinydb==4.8.0 toml==0.10.2 typing_extensions==4.12.2 uc-micro-py==1.0.3 -urllib3==1.26.20 +urllib3==2.2.3 uvicorn==0.30.6 validators==0.33.0 wadllib==1.3.6 diff --git a/requirements.txt b/requirements.txt index f6eac1072b..d69ae9cef6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,13 +7,13 @@ cffi==1.17.1 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 -craft-application==4.2.4 +craft-application==4.2.6 craft-archives==2.0.0 craft-cli==2.7.0 craft-grammar==2.0.1 -craft-parts==2.1.1 +craft-parts==2.1.2 craft-platforms==0.1.1 -craft-providers==2.0.3 +craft-providers==2.0.4 craft-store==3.0.2 cryptography==43.0.1 distro==1.9.0 @@ -47,7 +47,7 @@ pydantic_core==2.20.1 pydantic_yaml==1.3.0 pyelftools==0.31 pygit2==1.13.3 -pylxd==2.3.4 +pylxd==2.3.5 pymacaroons==0.13.0 PyNaCl==1.5.0 pyparsing==3.1.4 @@ -58,9 +58,9 @@ pytz==2024.1 pyxdg==0.28 PyYAML==6.0.2 raven==6.10.0 -requests==2.31.0 +requests==2.32.3 requests-toolbelt==1.0.0 -requests-unixsocket==0.3.0 +requests-unixsocket2==0.4.2 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.8 SecretStorage==3.3.3 @@ -72,7 +72,7 @@ tabulate==0.9.0 tinydb==4.8.0 toml==0.10.2 typing_extensions==4.12.2 -urllib3==1.26.20 +urllib3==2.2.3 validators==0.33.0 wadllib==1.3.6 wheel==0.44.0 diff --git a/setup.py b/setup.py index 351f5a9379..fdfb1be53b 100755 --- a/setup.py +++ b/setup.py @@ -98,13 +98,13 @@ def recursive_data_files(directory, install_directory): "attrs", "catkin-pkg; sys_platform == 'linux'", "click", - "craft-application>=4.2.4,<5.0.0", + "craft-application>=4.2.6,<5.0.0", "craft-archives~=2.0", "craft-cli~=2.6", "craft-grammar>=2.0.1,<3.0.0", - "craft-parts~=2.1", + "craft-parts>=2.1.2,<3.0.0", "craft-platforms~=0.1", - "craft-providers>=2.0.3,<3.0.0", + "craft-providers>=2.0.4,<3.0.0", "craft-store>=3.0.2,<4.0.0", "docutils<0.20", # Frozen until we can update sphinx dependencies. "gnupg", @@ -130,7 +130,7 @@ def recursive_data_files(directory, install_directory): "pyyaml", "raven", "requests-toolbelt", - "requests-unixsocket", + "requests-unixsocket2", "requests", "simplejson", "snap-helpers", @@ -138,7 +138,6 @@ def recursive_data_files(directory, install_directory): "toml", "tinydb", "typing-extensions", - "urllib3<2", # requests-unixsocket does not yet work with urllib3 v2.0+ "validators>=0.28.3", ] From 198c8dff9b3ae5f4bb292a8b3bc0cf855d1753ae Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Thu, 3 Oct 2024 14:41:51 -0400 Subject: [PATCH 11/14] fix(tests/legacy): don't send bad data --- tests/legacy/fake_servers/snapd.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/legacy/fake_servers/snapd.py b/tests/legacy/fake_servers/snapd.py index 4616b28a32..be5c52a01f 100644 --- a/tests/legacy/fake_servers/snapd.py +++ b/tests/legacy/fake_servers/snapd.py @@ -53,7 +53,6 @@ def _handle_snaps(self): def _handle_snap_file(self, parsed_url): self.send_response(200) - self.send_header("Content-Length", len(parsed_url)) self.send_header("Content-type", "text/plain") self.end_headers() self.wfile.write(parsed_url.encode()) From 29b95ffc5007ea927626c515f466deb69d9f5d6a Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Mon, 7 Oct 2024 15:00:47 -0500 Subject: [PATCH 12/14] tests: fix python unit tests --- tests/unit/parts/plugins/test_python_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/parts/plugins/test_python_plugin.py b/tests/unit/parts/plugins/test_python_plugin.py index d41f6d295a..5fa6d87337 100644 --- a/tests/unit/parts/plugins/test_python_plugin.py +++ b/tests/unit/parts/plugins/test_python_plugin.py @@ -66,7 +66,7 @@ def test_get_build_commands(plugin, new_dir): f'PARTS_PYTHON_VENV_INTERP_PATH="{new_dir}/parts/my-part/install/bin/${{PARTS_PYTHON_INTERPRETER}}"', f"{new_dir}/parts/my-part/install/bin/pip install -U pip setuptools wheel", f"[ -f setup.py ] || [ -f pyproject.toml ] && {new_dir}/parts/my-part/install/bin/pip install -U .", - f'find "{new_dir}/parts/my-part/install" -type f -executable -print0 | xargs -0 \\\n' + f'find "{new_dir}/parts/my-part/install" -type f -executable -print0 | xargs --no-run-if-empty -0 \\\n' ' sed -i "1 s|^#\\!${PARTS_PYTHON_VENV_INTERP_PATH}.*$|#!/usr/bin/env ${PARTS_PYTHON_INTERPRETER}|"\n', dedent( f"""\ From 73a26a6e1c5821bf74a268634661431cddfcbc12 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Fri, 4 Oct 2024 16:54:22 -0500 Subject: [PATCH 13/14] docs(changelog): add 7.5.7 release notes Signed-off-by: Callahan Kovacs --- docs/reference/changelog.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/reference/changelog.rst b/docs/reference/changelog.rst index fbc344f8ac..61cc599580 100644 --- a/docs/reference/changelog.rst +++ b/docs/reference/changelog.rst @@ -68,6 +68,19 @@ Changelog For a complete list of commits, check out the `X.Y.Z`_ release on GitHub. + +7.5.7 (2024-Oct-03) +------------------- + +Core +==== + +* Fix a bug where parallel installations of Snapcraft would not work if the + Snapcraft snap was installed from the store (`#4683`_, `#4927`_). + +For a complete list of commits, check out the `7.5.7`_ release on GitHub. + + 8.4.1 (2024-Sep-20) ------------------- @@ -1187,6 +1200,7 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _#4517: https://github.com/canonical/snapcraft/issues/4517 .. _#4520: https://github.com/canonical/snapcraft/issues/4520 .. _#4547: https://github.com/canonical/snapcraft/issues/4547 +.. _#4683: https://github.com/canonical/snapcraft/issues/4683 .. _#4685: https://github.com/canonical/snapcraft/issues/4685 .. _#4735: https://github.com/canonical/snapcraft/issues/4735 .. _#4744: https://github.com/canonical/snapcraft/issues/4744 @@ -1219,6 +1233,7 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _#4890: https://github.com/canonical/snapcraft/issues/4890 .. _#4908: https://github.com/canonical/snapcraft/issues/4908 .. _#4909: https://github.com/canonical/snapcraft/issues/4909 +.. _#4927: https://github.com/canonical/snapcraft/issues/4927 .. _#4930: https://github.com/canonical/snapcraft/issues/4930 .. _#4941: https://github.com/canonical/snapcraft/issues/4941 .. _#4942: https://github.com/canonical/snapcraft/issues/4942 @@ -1230,6 +1245,7 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _#5048: https://github.com/canonical/snapcraft/issues/5048 .. _7.5.6: https://github.com/canonical/snapcraft/releases/tag/7.5.6 +.. _7.5.7: https://github.com/canonical/snapcraft/releases/tag/7.5.7 .. _8.0.0: https://github.com/canonical/snapcraft/releases/tag/8.0.0 .. _8.0.1: https://github.com/canonical/snapcraft/releases/tag/8.0.1 .. _8.0.2: https://github.com/canonical/snapcraft/releases/tag/8.0.2 From df6ae078fa833954c7428194ded4542106f3ca45 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Fri, 4 Oct 2024 16:51:55 -0500 Subject: [PATCH 14/14] docs(changelog): add 8.4.2 release notes Signed-off-by: Callahan Kovacs --- docs/reference/changelog.rst | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/reference/changelog.rst b/docs/reference/changelog.rst index 61cc599580..61bd5ff297 100644 --- a/docs/reference/changelog.rst +++ b/docs/reference/changelog.rst @@ -69,6 +69,45 @@ Changelog For a complete list of commits, check out the `X.Y.Z`_ release on GitHub. +8.4.2 (2024-Oct-07) +------------------- + +Core +==== + +* Fix a regression where Snapcraft would fail to run on some architectures due + to a ``cryptography`` dependency that attempted to load legacy algorithms + (`#5077`_). + +* Fix a regression where Snapcraft would fail to run in a container if it was + not running as a snap (`#5079`_). + +* Fix a bug where parallel installations of Snapcraft would not work if the + Snapcraft snap was installed from the store (`#4683`_, `#4927`_). + +Plugins +####### + +Python +"""""" + +* Fix an issue where the ``python`` plugin would fail to build if the part + had no Python scripts. + +Remote build +============ + +* Fix a bug where the remote builder would ignore the user's response when a + build is interrupted and always clean the launchpad project (`#4929`_). + +Documentation +============= + +* Update Rust plugin doc with recent changes to the Rust toolchain. + +For a complete list of commits, check out the `8.4.2`_ release on GitHub. + + 7.5.7 (2024-Oct-03) ------------------- @@ -1234,6 +1273,7 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _#4908: https://github.com/canonical/snapcraft/issues/4908 .. _#4909: https://github.com/canonical/snapcraft/issues/4909 .. _#4927: https://github.com/canonical/snapcraft/issues/4927 +.. _#4929: https://github.com/canonical/snapcraft/issues/4929 .. _#4930: https://github.com/canonical/snapcraft/issues/4930 .. _#4941: https://github.com/canonical/snapcraft/issues/4941 .. _#4942: https://github.com/canonical/snapcraft/issues/4942 @@ -1243,6 +1283,8 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _#4995: https://github.com/canonical/snapcraft/issues/4995 .. _#5008: https://github.com/canonical/snapcraft/issues/5008 .. _#5048: https://github.com/canonical/snapcraft/issues/5048 +.. _#5077: https://github.com/canonical/snapcraft/issues/5077 +.. _#5079: https://github.com/canonical/snapcraft/issues/5079 .. _7.5.6: https://github.com/canonical/snapcraft/releases/tag/7.5.6 .. _7.5.7: https://github.com/canonical/snapcraft/releases/tag/7.5.7 @@ -1273,3 +1315,4 @@ For a complete list of commits, check out the `8.0.0`_ release on GitHub. .. _8.3.4: https://github.com/canonical/snapcraft/releases/tag/8.3.4 .. _8.4.0: https://github.com/canonical/snapcraft/releases/tag/8.4.0 .. _8.4.1: https://github.com/canonical/snapcraft/releases/tag/8.4.1 +.. _8.4.2: https://github.com/canonical/snapcraft/releases/tag/8.4.2