Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge main into feature/craft-application #4585

Merged
merged 16 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/.jira_sync_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
settings:
components:
- Snapcraft
labels:
- Bug
- Enhancement
- Spike
- Epic
# Adds a comment with the JIRA ID
add_gh_comment: true
# Reflect changes on JIRA
sync_description: true
# Comments are synced from Github to JIRA
# Nothing goes from JIRA to Github
sync_comments: true
# epic_key: "MTC-296"
jira_project_key: "CRAFT"
status_mapping:
opened: Untriaged
closed: done
label_mapping:
Enhancement: Story
Bug: Bug
Spike: Spike
Epic: Epic
17 changes: 0 additions & 17 deletions .github/workflows/issues.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ click==8.1.7
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.1.1
craft-parts==1.26.0
craft-parts==1.26.2
craft-providers==1.22.0
craft-store==2.5.0
Deprecated==1.2.14
Expand Down
2 changes: 1 addition & 1 deletion extensions/desktop/common/init
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export SNAP_LAUNCHER_ARCH_TRIPLET="$ARCH"
if ! grep -qs "^\s*confinement:\s*classic\s*" "$SNAP/meta/snap.yaml"; then
if [ -f "$SNAP/lib/$ARCH/bindtextdomain.so" ]; then
export LD_PRELOAD="$LD_PRELOAD:$SNAP/\$LIB/bindtextdomain.so"
elif [ -f "$SNAP/gnome-platform/lib/$ARCH/bindtextdomain.so" ]; then
elif [ -f "$SNAP/gnome-platform/lib/$ARCH/bindtextdomain.so" ] && ! grep -qs "^\s*default-provider:\s*wine-platform-runtime*" "$SNAP/meta/snap.yaml"; then
export LD_PRELOAD="$LD_PRELOAD:$SNAP/gnome-platform/\$LIB/bindtextdomain.so"
fi
fi
7 changes: 6 additions & 1 deletion snapcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ def run(): # noqa: C901 (complex-structure)
emit.error(craft_cli.errors.CraftError(f"linter error: {err}"))
retcode = err.exit_code
except RemoteBuildError as err:
emit.error(craft_cli.errors.CraftError(f"remote-build error: {err}"))
emit.error(
craft_cli.errors.CraftError(
message=f"remote-build error: {err}",
docs_url="https://snapcraft.io/docs/remote-build",
)
)
retcode = 1
except errors.SnapcraftError as err:
_emit_error(err)
Expand Down
29 changes: 21 additions & 8 deletions snapcraft/commands/remote.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright 2022-2023 Canonical Ltd.
# Copyright 2022-2024 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
Expand Down Expand Up @@ -91,18 +91,17 @@ def fill_parser(self, parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"--status", action="store_true", help="display remote build status"
)
parser_target = parser.add_mutually_exclusive_group()
parser_target.add_argument(
parser.add_argument(
"--build-on",
type=lambda arg: [arch.strip() for arch in arg.split(",")],
metavar="arch",
nargs="+",
help=HIDDEN,
)
parser_target.add_argument(
parser.add_argument(
"--build-for",
type=lambda arg: [arch.strip() for arch in arg.split(",")],
metavar="arch",
nargs="+",
help="architecture to build for",
help="comma-separated list of architectures to build for",
)
parser.add_argument(
"--build-id", metavar="build-id", help="specific build id to retrieve"
Expand Down Expand Up @@ -141,7 +140,6 @@ def run(self, parsed_args: argparse.Namespace) -> None:

if parsed_args.build_on:
emit.message("Use --build-for instead of --build-on")
parsed_args.build_for = parsed_args.build_on

if not parsed_args.launchpad_accept_public_upload and not confirm_with_user(
_CONFIRMATION_PROMPT
Expand Down Expand Up @@ -381,11 +379,24 @@ def _determine_architectures(self) -> List[str]:
The build architectures can be set via the `--build-on` parameter or determined
from the build-on architectures listed in the project's snapcraft.yaml.

To retain backwards compatibility, `--build-for` can also be used to
set the architectures.

:returns: A list of architectures.

:raises SnapcraftError: If `--build-on` was provided and architectures are
defined in the project's snapcraft.yaml.
:raises SnapcraftError: If `--build-on` and `--build-for` are both provided.
"""
# argparse's `add_mutually_exclusive_group()` cannot be used because
# ArgumentParsingErrors executes the legacy remote-builder before this module
# can decide if the project is allowed to use the legacy remote-builder
if self._parsed_args.build_on and self._parsed_args.build_for:
raise SnapcraftError(
# use the same error as argparse produces for consistency
"Error: argument --build-for: not allowed with argument --build-on"
)

project_architectures = self._get_project_build_on_architectures()
if project_architectures and self._parsed_args.build_for:
raise SnapcraftError(
Expand All @@ -395,6 +406,8 @@ def _determine_architectures(self) -> List[str]:

if project_architectures:
archs = project_architectures
elif self._parsed_args.build_on:
archs = self._parsed_args.build_on
elif self._parsed_args.build_for:
archs = self._parsed_args.build_for
else:
Expand Down
43 changes: 35 additions & 8 deletions snapcraft/extensions/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,17 @@ def get_root_snippet(self) -> Dict[str, Any]:
}
},
"layout": {
"/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0": {
"bind": "$SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0"
"/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/webkit2gtk-4.0": {
"bind": (
"$SNAP/gnome-platform/usr/lib/"
"$CRAFT_ARCH_TRIPLET_BUILD_FOR/webkit2gtk-4.0"
)
},
"/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/webkit2gtk-4.1": {
"bind": (
"$SNAP/gnome-platform/usr/lib/"
"$CRAFT_ARCH_TRIPLET_BUILD_FOR/webkit2gtk-4.1"
)
},
"/usr/share/xml/iso-codes": {
"bind": "$SNAP/gnome-platform/usr/share/xml/iso-codes"
Expand Down Expand Up @@ -189,19 +198,25 @@ def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]:
"LD_LIBRARY_PATH": prepend_to_env(
"LD_LIBRARY_PATH",
[
f"/snap/{sdk_snap}/current/lib/$CRAFT_ARCH_TRIPLET",
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET",
f"/snap/{sdk_snap}/current/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR",
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR",
f"/snap/{sdk_snap}/current/usr/lib",
f"/snap/{sdk_snap}/current/usr/lib/vala-current",
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET/pulseaudio",
(
f"/snap/{sdk_snap}/current/usr/lib/"
"$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio"
),
],
),
},
{
"PKG_CONFIG_PATH": prepend_to_env(
"PKG_CONFIG_PATH",
[
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET/pkgconfig",
(
f"/snap/{sdk_snap}/current/usr/lib/"
"$CRAFT_ARCH_TRIPLET_BUILD_FOR/pkgconfig"
),
f"/snap/{sdk_snap}/current/usr/lib/pkgconfig",
f"/snap/{sdk_snap}/current/usr/share/pkgconfig",
],
Expand All @@ -217,7 +232,7 @@ def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]:
},
{
"GDK_PIXBUF_MODULE_FILE": (
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET"
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR"
"/gdk-pixbuf-current/loaders.cache"
),
},
Expand All @@ -235,11 +250,23 @@ def get_part_snippet(self, *, plugin_name: str) -> Dict[str, Any]:
[
f"/snap/{sdk_snap}/current/usr/lib/python3.10",
f"/snap/{sdk_snap}/current/usr/lib/python3/dist-packages",
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET"
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR"
"/gobject-introspection",
],
),
},
{
"GI_TYPELIB_PATH": prepend_to_env(
"GI_TYPELIB_PATH",
[
f"/snap/{sdk_snap}/current/usr/lib/girepository-1.0",
(
f"/snap/{sdk_snap}/usr/lib/"
"$CRAFT_ARCH_TRIPLET_BUILD_FOR/girepository-1.0"
),
],
)
},
],
}

Expand Down
13 changes: 13 additions & 0 deletions snapcraft/parts/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ def _run_command( # noqa PLR0913 # pylint: disable=too-many-branches, too-many-
lifecycle.clean(part_names=part_names)
return

# patchelf relies on known file list to work properly, but override-prime
# parts don't have the list yet, and we can't track changes in the prime.
for _part in getattr(project, "parts", {}).values():
if "enable-patchelf" in _part.get("build-attributes", []) and _part.get(
"override-prime", None
):
emit.progress(
"Warning: 'enable-patchelf' feature will not apply to files primed "
"by parts that use the 'override-prime' keyword. It's not possible "
"to track file changes in the prime directory.",
permanent=True,
)

try:
_run_lifecycle_and_pack(
lifecycle,
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"core18": bases.BuilddBaseAlias.BIONIC,
"core20": bases.BuilddBaseAlias.FOCAL,
"core22": bases.BuilddBaseAlias.JAMMY,
"core24": bases.BuilddBaseAlias.DEVEL,
"core24": bases.BuilddBaseAlias.NOBLE,
"devel": bases.BuilddBaseAlias.DEVEL,
}

Expand Down
2 changes: 0 additions & 2 deletions snapcraft/remote/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def __init__(self) -> None:
class RemoteBuildFailedError(RemoteBuildError):
"""Remote build failed.

:param brief: Brief description of error.
:param details: Detailed information.
"""

Expand All @@ -120,7 +119,6 @@ def __init__(self, details: str) -> None:
class RemoteBuildInvalidGitRepoError(RemoteBuildError):
"""The Git repository is invalid for remote build.

:param brief: Brief description of error.
:param details: Detailed information.
"""

Expand Down
6 changes: 4 additions & 2 deletions snapcraft/remote/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ def check_git_repo_for_remote_build(path: Path) -> None:

if git_type == GitType.INVALID:
raise RemoteBuildInvalidGitRepoError(
f"Could not find a git repository in {str(path)!r}"
f"Could not find a git repository in {str(path.absolute())!r}. "
"The project must be in the top-level of a git repository."
)

if git_type == GitType.SHALLOW:
raise RemoteBuildInvalidGitRepoError(
"Remote build for shallow cloned git repos are no longer supported"
"Remote builds are not supported for projects in shallowly cloned "
"git repositories."
)


Expand Down
33 changes: 14 additions & 19 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ backends:
multipass:
type: adhoc
allocate: |
multipass_count=$(flock -x .spread_multipass -c 'COUNT=$(cat .spread_multipass); echo $(($COUNT + 1)) | tee .spread_multipass')
if [ "$SPREAD_SYSTEM" = "ubuntu-24.04-64" ]; then
image="daily:devel"
instance_name=spread-devel
instance_name="spread-devel-${multipass_count}"
else
# SPREAD_SYSTEM has the following format here 'ubuntu-XX.YY-64' and gets
# translated to an image XX.YY.
image=$(echo $SPREAD_SYSTEM | sed -e 's/ubuntu-\(.*\)-64/\1/')
spread_name=$(echo ${image} | sed -e 's/\.//g')
instance_name="spread-${spread_name}"
instance_name="spread-${spread_name}-${multipass_count}"
fi

if [ -z "${image}" ]; then
Expand All @@ -88,28 +89,22 @@ backends:
sudo sh -c "echo root:ubuntu | sudo chpasswd"
multipass exec "$instance_name" -- \
sudo sh -c \
"sed -i /etc/ssh/sshd_config -e 's/^PasswordAuthentication.*/PasswordAuthentication yes/' -e 's/^#PermitRootLogin.*/PermitRootLogin yes/'"
"if [ -d /etc/ssh/sshd_config.d/ ]
then
echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config.d/10-custom.conf
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config.d/10-custom.conf
else
sed -i /etc/ssh/sshd_config -E -e 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/' -e 's/^#?PermitRootLogin.*/PermitRootLogin yes/'
fi"
multipass exec "$instance_name" -- \
sudo systemctl restart ssh

ADDRESS "$ip:22"
ADDRESS "$ip"
discard: |
if [ "$SPREAD_SYSTEM" = "ubuntu-24.04-64" ]; then
image="daily:devel"
instance_name=spread-devel
else
# SPREAD_SYSTEM has the following format here 'ubuntu-XX.YY-64' and gets
# translated to an image XX.YY.
image=$(echo $SPREAD_SYSTEM | sed -e 's/ubuntu-\(.*\)-64/\1/')
spread_name=$(echo ${image} | sed -e 's/\.//g')
instance_name="spread-${spread_name}"
fi

if [ -z "${image}" ]; then
FATAL "$SPREAD_SYSTEM is not supported!"
instance_name=$(multipass list --format csv | grep ",${SPREAD_SYSTEM_ADDRESS}," | cut -f1 -d\,)
if [[ ! -z "$instance_name" ]]; then
multipass delete --purge "${instance_name}"
fi

multipass delete --purge "$instance_name"
systems:
- ubuntu-20.04-64:
workers: 1
Expand Down
13 changes: 6 additions & 7 deletions tests/spread/general/store/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ summary: Test the store workflow
manual: true

environment:
SNAP: dump-hello
SNAP: "/snapcraft/tests/spread/plugins/v2/snaps/autotools-hello"
SNAPCRAFT_STORE_CREDENTIALS/ubuntu_one: "$(HOST: echo ${SNAPCRAFT_STORE_CREDENTIALS_STAGING})"
SNAPCRAFT_STORE_CREDENTIALS/legacy: "$(HOST: echo ${SNAPCRAFT_STORE_CREDENTIALS_STAGING_LEGACY})"
SNAPCRAFT_STORE_CREDENTIALS/candid: "$(HOST: echo ${SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID})"
Expand All @@ -30,16 +30,15 @@ prepare: |
# notify the store team if you need to use a different value when
# working with the production store.
name="test-snapcraft-$(shuf -i 1-1000000000 -n 1)"
set_base "../snaps/$SNAP/snap/snapcraft.yaml"
set_name "../snaps/$SNAP/snap/snapcraft.yaml" "${name}"
set_grade "../snaps/$SNAP/snap/snapcraft.yaml" stable
set_name "$SNAP/snap/snapcraft.yaml" "${name}"
set_grade "$SNAP/snap/snapcraft.yaml" stable

# Build what we have and verify the snap runs as expected.
cd "../snaps/$SNAP"
cd "$SNAP"
snapcraft

restore: |
cd "../snaps/$SNAP"
cd "$SNAP"
snapcraft clean
rm -f ./*.snap

Expand All @@ -49,7 +48,7 @@ restore: |

execute: |
# Get information about our snap.
cd "../snaps/$SNAP"
cd "$SNAP"
snap_file=$(ls ./*.snap)
snap_name=$(grep "name: " snap/snapcraft.yaml | sed -e "s/name: \(.*$\)/\1/")

Expand Down
Loading
Loading