Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hotfix/7.4-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiusens committed Jul 3, 2023
2 parents 31f9ee3 + ae966fc commit 89c1d50
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 144 deletions.
2 changes: 1 addition & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ codespell==2.2.4
colorama==0.4.6
coverage==7.2.5
craft-archives==1.0.0
craft-cli==1.2.0
craft-cli==2.0.0
craft-grammar==1.1.1
craft-parts==1.21.1
craft-providers==1.13.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ chardet==5.1.0
charset-normalizer==3.1.0
click==8.1.3
craft-archives==1.0.0
craft-cli==1.2.0
craft-cli==2.0.0
craft-grammar==1.1.1
craft-parts==1.21.1
craft-providers==1.13.0
Expand Down
3 changes: 2 additions & 1 deletion snapcraft/commands/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ class StoreNamesCommand(BaseCommand):
def run(self, parsed_args):
store_client = store.StoreClientCLI()
snaps = store_client.get_names()
snaps.sort(key=operator.itemgetter(0))

if not snaps:
emit.message("No registered snaps")
else:
tabulated_snaps = tabulate(
sorted(snaps, key=operator.itemgetter(0)),
snaps,
headers=["Name", "Since", "Visibility", "Notes"],
tablefmt="plain",
)
Expand Down
4 changes: 2 additions & 2 deletions snapcraft/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ def run(self, parsed_args):
]
for track in snap_channel_map.snap.tracks
]
track_table.sort(key=operator.itemgetter(2)) # Sort by "creation-date".

emit.message(
tabulate(
# Sort by "creation-date".
sorted(track_table, key=operator.itemgetter(2)),
track_table,
headers=["Name", "Status", "Creation-Date", "Version-Pattern"],
tablefmt="plain",
)
Expand Down
30 changes: 0 additions & 30 deletions snapcraft/extensions/kde_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,36 +177,6 @@ def get_part_snippet(self) -> 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/usr/lib",
f"/snap/{sdk_snap}/current/usr/lib/vala-current",
f"/snap/{sdk_snap}/current/usr/lib/$CRAFT_ARCH_TRIPLET/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/pkgconfig",
f"/snap/{sdk_snap}/current/usr/share/pkgconfig",
],
),
},
{
"ACLOCAL_PATH": prepend_to_env(
"ACLOCAL_PATH",
[
f"/snap/{sdk_snap}/current/usr/share/aclocal",
],
),
},
{
"SNAPCRAFT_CMAKE_ARGS": prepend_to_env(
"SNAPCRAFT_CMAKE_ARGS",
Expand Down
47 changes: 27 additions & 20 deletions snapcraft/meta/snap_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,9 @@ def write(project: Project, prime_dir: Path, *, arch: str):
# if arch is "all", do not include architecture-specific paths in the environment
arch_triplet = None if arch == "all" else project.get_build_for_arch_triplet()

environment = _populate_environment(project.environment, prime_dir, arch_triplet)
environment = _populate_environment(
project.environment, prime_dir, arch_triplet, project.confinement
)
version = process_version(project.version)

# project provided assumes and computed assumes
Expand Down Expand Up @@ -454,39 +456,44 @@ def _populate_environment(
environment: Optional[Dict[str, Optional[str]]],
prime_dir: Path,
arch_triplet: Optional[str],
):
"""Populate default app environmental variables.
confinement: str,
) -> Optional[Dict[str, Optional[str]]]:
"""Populate default app environment variables, LD_LIBRARY_PATH and PATH.
Three cases for LD_LIBRARY_PATH and PATH variables:
- If LD_LIBRARY_PATH or PATH are defined, keep user-defined values.
- If LD_LIBRARY_PATH or PATH are not defined, set to default values.
- If LD_LIBRARY_PATH or PATH are null, do not use default values.
Three cases for environment variables:
- If defined, keep user-defined value.
- If not defined, set to default value.
- If null, do not use default value.
:param environment: Dictionary of environment variables from the project.
:param prime_dir: The directory containing the content to be snapped.
:param arch_triplet: Architecture triplet of the target arch. If None, the
environment will not contain architecture-specific paths.
:param confinement: If classically confined, then no default values will be used.
:returns: Dictionary of environment variables or None if all envvars are null or
confinement is classic.
"""
if environment is None:
if confinement == "classic":
return None
return {
"LD_LIBRARY_PATH": get_ld_library_paths(prime_dir, arch_triplet),
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
}

try:
if not environment["LD_LIBRARY_PATH"]:
environment.pop("LD_LIBRARY_PATH")
except KeyError:
# if LD_LIBRARY_PATH is not defined, use default value when not classic
if "LD_LIBRARY_PATH" not in environment and confinement != "classic":
environment["LD_LIBRARY_PATH"] = get_ld_library_paths(prime_dir, arch_triplet)
# else if null, then remove from environment
elif "LD_LIBRARY_PATH" in environment and not environment["LD_LIBRARY_PATH"]:
del environment["LD_LIBRARY_PATH"]

try:
if not environment["PATH"]:
environment.pop("PATH")
except KeyError:
# if PATH is not defined, use default value when not classic
if "PATH" not in environment and confinement != "classic":
environment["PATH"] = "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH"
# else if null, then remove from environment
elif "PATH" in environment and not environment["PATH"]:
del environment["PATH"]

if len(environment):
return environment

# if the environment only contained a null LD_LIBRARY_PATH and a null PATH, return None
return None
return environment if environment else None
34 changes: 17 additions & 17 deletions snapcraft/parts/plugins/kernel_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- kernel-kconfigfile:
(filepath; default: none)
path to file to use as base configuration. If provided this option wins
path to file to use as base configuration; if provided, this option wins
over everything else. default: None
- kernel-kconfigflavour:
Expand All @@ -36,10 +36,10 @@
- kernel-kconfigs:
(list of strings; default: none)
explicit list of configs to force; this will override the configs that
were set as base through kernel-kdefconfig and kernel-kconfigfile and dependent configs
will be fixed using the defaults encoded in the kbuild config
definitions. If you don't want default for one or more implicit configs
coming out of these, just add them to this list as well.
were set as base through kernel-kdefconfig and kernel-kconfigfile;
dependent configs will be fixed using the defaults encoded in the kbuild
config definitions. If you don't want default for one or more implicit
configs coming out of these, just add them to this list as well.
- kernel-image-target:
(yaml object, string or null for default target)
Expand Down Expand Up @@ -89,9 +89,10 @@
- kernel-initrd-modules:
(array of string; default: none)
list of modules to include in initrd.
Note that kernel snaps do not provide the core boot logic which comes from snappy
Ubuntu Core OS snap. Include all modules you need for mounting rootfs here.
If installed module(s) have any dependencies, those are automatically installed.
Note that kernel snaps do not provide the core boot logic which
comes from the Ubuntu Core base snap. Include all modules you need
for mounting the rootfs here. If installed module(s) have any
dependencies, they are automatically installed.
- kernel-initrd-configured-modules:
(array of string; default: none)
Expand All @@ -105,8 +106,8 @@
(boolean; default: False)
When building initrd, required firmware is automatically added based
on the included kernel modules. By default required firmware is searched
in the install directory of the current part. This flag allows used of firmware
from stage directory instead.
in the install directory of the current part. This flag allows use of
firmware from the stage directory instead.
- kernel-initrd-firmware:
(array of string; default: none)
Expand Down Expand Up @@ -147,8 +148,7 @@
specific hook needs to be added to the initrd.
Values are relative path from stage directory, so related part(s)
need to be built before kernel part.
During build it will be expanded to
${CRAFT_STAGE}/{initrd-addon}
During build it will be expanded to ${CRAFT_STAGE}/{initrd-addon}.
Default: none
- kernel-add-ppa
Expand All @@ -160,9 +160,9 @@
Use the LLVM substitutes for the GNU binutils utilities. Set this to a
string (e.g. "-12") to use a specific version of the LLVM utilities.
This plugin support cross compilation, for which plugin expects
the build-environment is comfigured accordingly and has foreign architectures
setup accordingly.
This plugin supports cross compilation, for which plugin expects
the build-environment is configured accordingly and has foreign
architectures set up accordingly.
"""

import logging
Expand Down Expand Up @@ -224,7 +224,7 @@ class KernelPluginProperties(plugins.PluginProperties, plugins.PluginModel):
@root_validator
@classmethod
def validate_pluging_options(cls, values):
"""If kernel-image-target is defined, it has to be string of dictionary."""
"""If kernel-image-target is defined, it has to be string or dictionary."""
if values.get("kernel_image_target"):
if not isinstance(values.get("kernel_image_target"), str):
if not isinstance(values.get("kernel_image_target"), dict):
Expand Down Expand Up @@ -343,7 +343,7 @@ def _set_kernel_targets(self) -> None:
self.dtbs = [f"{i}.dtb" for i in self.options.kernel_device_trees]
if self.dtbs:
self._make_targets.extend(self.dtbs)
elif self._kernel_arch in ("arm", "arm64", "riscv64"):
elif self._kernel_arch in ("arm", "arm64", "riscv", "riscv64"):
self._make_targets.append("dtbs")
self._make_install_targets.extend(
["dtbs_install", "INSTALL_DTBS_PATH=${CRAFT_PART_INSTALL}/dtbs"]
Expand Down
14 changes: 13 additions & 1 deletion tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@ execute: |
test -f linter-ros2-humble-mixed_1.0_*.snap
sed -n '/^Running linters/,/^Creating snap/p' < output.txt > linter_output.txt
diff -u linter_output.txt expected_linter_output.txt
# diff everything except the list of libraries
diff --ignore-matching-lines "^- library: lib" expected_linter_output.txt linter_output.txt
# `|| true` is used because grep will error if there is no output from the `diff` call
NUM_DIFFERENCES=$(diff expected_linter_output.txt linter_output.txt | grep --count "[<>]" || true)
# the list of unused libraries may change from time to time, so check the output is similar but not identical
if [[ $NUM_DIFFERENCES -gt 10 ]]; then
echo "Error: linter warnings are significantly different:"
diff --unified expected_linter_output.txt linter_output.txt
exit 1
fi
11 changes: 10 additions & 1 deletion tests/spread/providers/lxd-type-base/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ execute: |
/snap/bin/lxc start snapcraft-core20
/snap/bin/lxc exec snapcraft-core20 cat /etc/os-release | MATCH "VERSION_CODENAME=focal"
/snap/bin/lxc stop snapcraft-core20
# Retry stopping, as on the Google runners this sometimes times out due to system load.
for _ in {1..4}; do
sleep 5
/snap/bin/lxc stop --timeout 60 snapcraft-core20 && break
done || (
# If the last stop failed, include the LXC logs in the output to establish why.
lxc info --show-log snapcraft-core20
exit 1
)
67 changes: 0 additions & 67 deletions tests/unit/extensions/test_kde_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,40 +181,6 @@ def assert_get_part_snippet(kde_neon_instance):
"/current/usr/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
)
},
{
"LD_LIBRARY_PATH": ":".join(
[
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"lib/$CRAFT_ARCH_TRIPLET",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/$CRAFT_ARCH_TRIPLET",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/usr/lib",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/vala-current",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/$CRAFT_ARCH_TRIPLET/pulseaudio",
]
)
+ "${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
},
{
"PKG_CONFIG_PATH": (
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/$CRAFT_ARCH_TRIPLET/pkgconfig:"
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/pkgconfig:"
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/share/pkgconfig"
)
+ "${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
},
{
"ACLOCAL_PATH": (
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/share/aclocal"
)
+ "${ACLOCAL_PATH:+:$ACLOCAL_PATH}"
},
{
"SNAPCRAFT_CMAKE_ARGS": (
"-DCMAKE_FIND_ROOT_PATH="
Expand All @@ -241,39 +207,6 @@ def test_get_part_snippet_with_external_sdk(kde_neon_extension_with_build_snap):
"/current/usr/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
)
},
{
"LD_LIBRARY_PATH": ":".join(
[
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"lib/$CRAFT_ARCH_TRIPLET",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/$CRAFT_ARCH_TRIPLET",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/usr/lib",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/vala-current",
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/$CRAFT_ARCH_TRIPLET/pulseaudio",
]
)
+ "${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
},
{
"PKG_CONFIG_PATH": (
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/$CRAFT_ARCH_TRIPLET/pkgconfig:"
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/lib/pkgconfig:"
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/"
"usr/share/pkgconfig"
)
+ "${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
},
{
"ACLOCAL_PATH": (
"/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/" "usr/share/aclocal"
)
+ "${ACLOCAL_PATH:+:$ACLOCAL_PATH}"
},
{
"SNAPCRAFT_CMAKE_ARGS": (
"-DCMAKE_FIND_ROOT_PATH="
Expand Down

0 comments on commit 89c1d50

Please sign in to comment.