-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(legacy): export sources method to local plugins
Support legacy local plugins that invoke `snapcraft.sources.get` by redirecting imports to `snapcraft_legacy`. This is similar to the strategy used for V1 and V2 plugins. Fixes #4285 Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
- Loading branch information
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright 2023 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Legacy support for local plugins.""" | ||
|
||
from snapcraft_legacy.sources import get | ||
|
||
__all__ = [ | ||
"get", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/spread/plugins/v1/x-local/snaps/source-get/snap/plugins/x_local_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright 2023 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import snapcraft | ||
from snapcraft.plugins.v1 import PluginV1 | ||
|
||
|
||
class LocalPlugin(PluginV1): | ||
@classmethod | ||
def schema(cls): | ||
schema = super().schema() | ||
|
||
schema["properties"]["foo"] = {"type": "string"} | ||
|
||
return schema | ||
|
||
@classmethod | ||
def get_pull_properties(cls): | ||
return ["foo", "stage-packages"] | ||
|
||
@classmethod | ||
def get_build_properties(cls): | ||
return ["foo", "stage-packages"] | ||
|
||
def pull(self): | ||
super().pull() | ||
x = snapcraft.sources.get | ||
|
||
def build(self): | ||
return self.run(["touch", "build-stamp"], self.installdir) |
12 changes: 12 additions & 0 deletions
12
tests/spread/plugins/v1/x-local/snaps/source-get/snap/snapcraft.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: test-local-plugins | ||
base: core18 | ||
version: "0.1" | ||
summary: local plugin using snapcraft.sources.get | ||
description: Tests if local plugins load and can build | ||
confinement: strict | ||
grade: devel | ||
|
||
parts: | ||
x-local-plugin: | ||
plugin: x-local-plugin | ||
source: . |