Skip to content

Commit

Permalink
Merge branch 'main' into sgmoore/kde-neon-qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
ScarlettGatelyMoore authored Mar 3, 2025
2 parents 95100b0 + 99735c7 commit de523b7
Show file tree
Hide file tree
Showing 140 changed files with 2,934 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Release Drafter
uses: release-drafter/release-drafter@v6.0.0
uses: release-drafter/release-drafter@v6.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 49 additions & 2 deletions .github/workflows/spread-scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
type: [craft-parts, v2]
type: [plugins/craft-parts, plugins/v2]
steps:
- name: Cleanup job workspace
run: |
Expand All @@ -49,7 +49,7 @@ jobs:
path: tests
- name: Kernel plugin test
run: |
spread google:ubuntu-22.04-64:tests/spread/plugins/${{ matrix.type }}/kernel
spread google:ubuntu-22.04-64:tests/spread/${{ matrix.type }}/kernel
remote-build:
runs-on: [spread-installed]
Expand Down Expand Up @@ -78,3 +78,50 @@ jobs:
google:ubuntu-22.04-64:tests/spread/core22/remote-build \
google:ubuntu-24.04-64:tests/spread/core24/remote-build \
google:fedora-39-64:tests/spread/core24/remote-build:no_platforms
matter-sdk:
runs-on: [spread-installed]
needs: [snap-build]
steps:
- name: Cleanup job workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout snapcraft
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
name: snap
path: tests
- name: matter-sdk test
run: |
spread google:ubuntu-22.04-64:tests/spread/core24-suites/plugins/matter-sdk
colcon-plugins:
runs-on: [spread-installed]
needs: [snap-build]
steps:
- name: Cleanup job workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout snapcraft
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
name: snap
path: tests
- name: colcon plugin test
run: |
spread google:ubuntu-22.04-64:tests/spread/core24-suites/plugins/colcon-hello \
google:ubuntu-22.04-64:tests/spread/core24-suites/plugins/colcon-msg-package \
google:ubuntu-22.04-64:tests/spread/core24-suites/plugins/colcon-packages-ignore \
google:ubuntu-22.04-64:tests/spread/core24-suites/plugins/colcon-talker-listener
Empty file removed .shellcheckrc
Empty file.
10 changes: 2 additions & 8 deletions docs/release-notes/snapcraft-8-7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ Try it out by typing ``snapcraft`` and pressing :kbd:`Tab` in your terminal.
Improved remote builder
~~~~~~~~~~~~~~~~~~~~~~~

Previously, the remote builder only supported natively built snaps and failed to
build cross-compiled snaps with an unhelpful error. Now, the remote builder supports
both natively and cross-compiled snaps.

Additionally, remote builds can now use the ``--build-for`` option to filter entries in
an ``architectures`` or ``platforms`` key in a project file.
Remote builds can now use the ``--build-for`` option to filter entries in an
``architectures`` or ``platforms`` key in a project file.


Support for confdbs
Expand Down Expand Up @@ -102,7 +98,6 @@ Fixed bugs and issues

The following issues have been resolved in Snapcraft 8.7:

- `#4996`_ Remote build gives an unfriendly error when attempting to cross-compile.
- `#5258`_ The Flutter plugin failed to install Flutter for ``core22`` and ``core24``
snaps.
- `#5250`_ Resources path for ``QtWebEngineProcess`` wasn't exported for snaps
Expand Down Expand Up @@ -130,7 +125,6 @@ this release.
:literalref:`@mr-cal<https://github.com/mr-cal>`,
and :literalref:`@sergio-costas<https://github.com/sergio-costas>`

.. _#4996: https://github.com/canonical/snapcraft/issues/4996
.. _#5250: https://github.com/canonical/snapcraft/pull/5250
.. _#5258: https://github.com/canonical/snapcraft/pull/5258
.. _craft-application#600: https://github.com/canonical/craft-application/issues/600
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies = [
"craft-platforms~=0.6",
"craft-providers~=2.1",
"craft-store>=3.0.2,<4.0.0",
"cryptography==43.0.3", # Pinned due to https://github.com/canonical/snapcraft/issues/5217
"cryptography",
"gnupg",
"jsonschema==2.5.1",
"launchpadlib",
Expand Down
26 changes: 26 additions & 0 deletions snap/local/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Dynamically load stage-package from another snap into our sys.path.
https://docs.python.org/3/library/site.html#module-sitecustomize
"""

import hashlib
import os
import sys
from pathlib import Path

TARGET_HASH = "8641d59472d54186f68939ab09cd4882cfba8f20efe278e6a539973c0b3e512c84d952e80f1d7297f8fd025e6878ea58"


def _find_pkg() -> None:
for craft_dir in Path("/snap").glob("*craft*/current"):
hasher = hashlib.sha3_384()
hasher.update(str(craft_dir).encode())
pkg_dir_hash = hasher.hexdigest()
if pkg_dir_hash != TARGET_HASH:
continue
pkg_path = craft_dir / "craft-plugins"
sys.path.insert(0, os.fspath(pkg_path))
return


_find_pkg()
4 changes: 4 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ parts:
plugin: dump
organize:
craft.git: libexec/snapcraft/craft.git
# Put sitecustomize in site-packages
sitecustomize.py: lib/python3.12/site-packages/sitecustomize.py

stage:
- "libexec/"
- "lib/"

git:
plugin: nil
Expand Down
69 changes: 29 additions & 40 deletions snapcraft_legacy/internal/pluginhandler/_plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def load_plugin(
definitions_schema,
) -> plugins.v2.PluginV2:
local_plugins_dir = project._get_local_plugins_dir()
if local_plugins_dir is not None:
plugin_class = _get_local_plugin_class(
plugin_name=plugin_name, local_plugins_dir=local_plugins_dir
)

plugin_class = _get_local_plugin_class(
plugin_name=plugin_name, local_plugins_dir=Path(local_plugins_dir)
)
if plugin_class is None:
plugin_class = plugins.get_plugin_for_base(
plugin_name, build_base=project._get_build_base()
Expand All @@ -57,57 +57,46 @@ def load_plugin(
return plugin


def _load_compat_x_prefix(plugin_name: str, module_name: str, local_plugin_dir: str):
compat_path = Path(local_plugin_dir, f"x-{plugin_name}.py")
if not compat_path.exists():
return None

preferred_name = f"{module_name}.py"
logger.warning(
f"Legacy plugin name detected, please rename the plugin's file name {compat_path.name!r} to {preferred_name!r}."
def _load_local(plugin_name: str, local_plugin_dir: Path):
# The legacy module path is for the case when we allowed the plugin
# file name to have '-', this is the first entry
module_names = (
Path(f"x-{plugin_name}.py"),
Path(f"{plugin_name.replace('-', '_')}.py"),
)
module_paths = (local_plugin_dir / m for m in module_names)
valid_paths = [m for m in module_paths if m.exists()]
# No valid paths means no local plugin to load
if not valid_paths:
return None

spec = importlib.util.spec_from_file_location(plugin_name, compat_path)
module_path = valid_paths[0]
spec = importlib.util.spec_from_file_location(plugin_name, module_path)
if spec.loader is None:
return None
raise errors.PluginError(f"unknown plugin: {plugin_name!r}")

# Prevent mypy type complaints by asserting type.
assert isinstance(spec.loader, importlib.abc.Loader)

module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module


def _load_local(plugin_name: str, local_plugin_dir: str):
module_name = plugin_name.replace("-", "_")

module = _load_compat_x_prefix(plugin_name, module_name, local_plugin_dir)
if module is None:
sys.path = [local_plugin_dir] + sys.path
logger.debug(
f"Loading plugin module {module_name!r} with sys.path {sys.path!r}"
)
try:
module = importlib.import_module(module_name)
finally:
sys.path.pop(0)

return module


def _get_local_plugin_class(*, plugin_name: str, local_plugins_dir: str):
with contextlib.suppress(ImportError):
module = _load_local(plugin_name, local_plugins_dir)
logger.info(f"Loaded local plugin for {plugin_name}")
def _get_local_plugin_class(*, plugin_name: str, local_plugins_dir: Path):
module = _load_local(plugin_name, local_plugins_dir)
if not module:
return
logger.info(f"Loaded local plugin for {plugin_name}")

# v2 requires plugin implementation to be named "PluginImpl".
if hasattr(module, "PluginImpl") and issubclass(
module.PluginImpl, plugins.v2.PluginV2
):
return module.PluginImpl
# v2 requires plugin implementation to be named "PluginImpl".
if hasattr(module, "PluginImpl") and issubclass(
module.PluginImpl, plugins.v2.PluginV2
):
return module.PluginImpl

raise errors.PluginError(f"unknown plugin: {plugin_name!r}")
raise errors.PluginError(f"unknown plugin: {plugin_name!r}")


def _validate_pull_and_build_properties(
Expand Down
23 changes: 19 additions & 4 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,37 @@ suites:
tests/spread/core24-suites/environment/:
summary: core24 environment tests
systems:
- ubuntu-24.04*
- ubuntu-22.04*
environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

tests/spread/core24-suites/scriptlets/:
summary: core24 scriptlet tests
systems:
- ubuntu-24.04*
- ubuntu-22.04*
environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

tests/spread/core24-suites/manifest/:
summary: core24 manifest tests
systems:
- ubuntu-24.04*
- ubuntu-22.04*
environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

tests/spread/core24-suites/patchelf/:
summary: core24 patchelf tests
systems:
- ubuntu-24.04*
- ubuntu-22.04*
environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

tests/spread/core24-suites/plugins/:
summary: core24 plugin tests
systems:
- ubuntu-22.04*
environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

# General, core suite
tests/spread/general/:
Expand Down
10 changes: 2 additions & 8 deletions tests/spread/core24-suites/environment/paths/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ environment:
SNAP/paths_user_defined: paths-user-defined
SNAP/staged_common_library: staged-common-library

prepare: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
# set_base "../snaps/$SNAP/snap/snapcraft.yaml"
systems:
- ubuntu-24.04*

restore: |
cd "../snaps/$SNAP"
snapcraft clean
rm -f ./*.snap
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
restore_yaml "snap/snapcraft.yaml"
execute: |
cd "../snaps/$SNAP"
Expand Down
14 changes: 3 additions & 11 deletions tests/spread/core24-suites/environment/test-variables/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@ systems:
environment:
SNAP/test_variables: test-variables
SNAPCRAFT_PARALLEL_BUILD_COUNT: 5

prepare: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
# set_base "../snaps/$SNAP/snap/snapcraft.yaml"
SNAPCRAFT_BUILD_ENVIRONMENT: host

restore: |
cd "../snaps/$SNAP"
rm -f ./*.snap
rm -Rf work
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
restore_yaml "snap/snapcraft.yaml"
snapcraft clean
execute: |
cd "../snaps/$SNAP"
Expand Down Expand Up @@ -62,7 +54,7 @@ execute: |
grep -q "$exp" < "$file"
done
}
# exercise lifecycle commands with and without `--platform` and `--build-for`
snapcraft pull --platform s390x
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
summary: Test manifest file creation

systems:
- ubuntu-24.04*

environment:
CMD/envvars: env SNAPCRAFT_BUILD_INFO=y snapcraft --destructive-mode

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
summary: Test manifest file creation

systems:
- ubuntu-24.04*

prepare: |
snap install review-tools
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ipython3

print('hello world')

Loading

0 comments on commit de523b7

Please sign in to comment.