From df5476bd0f62e87e969861e35cf24be0d3c5dee0 Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Fri, 16 Jun 2023 10:15:51 -0700 Subject: [PATCH 01/10] extension: remove extra kde-neon build envvars (#4193) remove extra build environment variables that are causing build failures. --- snapcraft/extensions/kde_neon.py | 30 ------------ tests/unit/extensions/test_kde_neon.py | 67 -------------------------- 2 files changed, 97 deletions(-) diff --git a/snapcraft/extensions/kde_neon.py b/snapcraft/extensions/kde_neon.py index 442e897472..7daf72537f 100644 --- a/snapcraft/extensions/kde_neon.py +++ b/snapcraft/extensions/kde_neon.py @@ -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", diff --git a/tests/unit/extensions/test_kde_neon.py b/tests/unit/extensions/test_kde_neon.py index 969d6e5311..6af25e556f 100644 --- a/tests/unit/extensions/test_kde_neon.py +++ b/tests/unit/extensions/test_kde_neon.py @@ -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=" @@ -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=" From 421fd64ab0a5a78763c37dca7f5e675f725ca077 Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Mon, 19 Jun 2023 10:05:48 -0300 Subject: [PATCH 02/10] dependencies: update craft-cli to 2.0.0 (#4215) Version 2.0.0 has the streaming output in brief mode. --- requirements-devel.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-devel.txt b/requirements-devel.txt index 8dd467cd7d..1d7b1b5642 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -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 diff --git a/requirements.txt b/requirements.txt index 9e7e808ad3..690bb572d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 From 64c8f1e870f36045b042f7c36437ef5e6e60af59 Mon Sep 17 00:00:00 2001 From: Callahan Date: Mon, 19 Jun 2023 17:39:11 -0500 Subject: [PATCH 03/10] ros: make linter tests more flexible (#4223) Signed-off-by: Callahan Kovacs --- .../expected_linter_output.txt | 7 ------- .../linters/linter-ros2-humble-mixed/task.yaml | 14 +++++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt b/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt index 2442be15bb..e5aff790af 100644 --- a/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt +++ b/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt @@ -6,39 +6,32 @@ Lint warnings: - library: libexpat.so.1: unused library 'lib/x86_64-linux-gnu/libexpat.so.1.8.7'. (https://snapcraft.io/docs/linters-library) - library: libtirpc.so.3: unused library 'lib/x86_64-linux-gnu/libtirpc.so.3.0.0'. (https://snapcraft.io/docs/linters-library) - library: libz.so.1: unused library 'lib/x86_64-linux-gnu/libz.so.1.2.11'. (https://snapcraft.io/docs/linters-library) -- library: libaction_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: libbuiltin_interfaces__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/libbuiltin_interfaces__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: libbuiltin_interfaces__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: liblifecycle_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: librcl_interfaces__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: librmw_dds_common__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librmw_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: librosgraph_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: libunique_identifier_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/libunique_identifier_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: libunique_identifier_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/libunique_identifier_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: libatomic.so.1: unused library 'usr/lib/x86_64-linux-gnu/libatomic.so.1.2.0'. (https://snapcraft.io/docs/linters-library) - library: libicuio.so.70: unused library 'usr/lib/x86_64-linux-gnu/libicuio.so.70.1'. (https://snapcraft.io/docs/linters-library) diff --git a/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml b/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml index 9076af8790..7db84e9943 100644 --- a/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml +++ b/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml @@ -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 From 9b6e58337e0175692f442844646c4d151d6e10e9 Mon Sep 17 00:00:00 2001 From: Callahan Date: Mon, 19 Jun 2023 19:26:34 -0500 Subject: [PATCH 04/10] meta: omit LD_LIBRARY_PATH and PATH in classic confinement (#4216) Signed-off-by: Callahan Kovacs --- snapcraft/meta/snap_yaml.py | 47 +++++++++++++++----------- tests/unit/meta/test_snap_yaml.py | 56 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 20 deletions(-) diff --git a/snapcraft/meta/snap_yaml.py b/snapcraft/meta/snap_yaml.py index c1915f4915..9e15fba5fc 100644 --- a/snapcraft/meta/snap_yaml.py +++ b/snapcraft/meta/snap_yaml.py @@ -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 @@ -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 diff --git a/tests/unit/meta/test_snap_yaml.py b/tests/unit/meta/test_snap_yaml.py index d04a8cd408..5c70600c15 100644 --- a/tests/unit/meta/test_snap_yaml.py +++ b/tests/unit/meta/test_snap_yaml.py @@ -593,6 +593,62 @@ def test_project_environment_ld_library_path_null(simple_project, new_dir): ) +@pytest.mark.parametrize( + "ld_library_path", + [{}, {"LD_LIBRARY_PATH": None}, {"LD_LIBRARY_PATH": "test-ld-library-path"}], +) +@pytest.mark.parametrize("path", [{}, {"PATH": None}, {"PATH": "test-path"}]) +@pytest.mark.parametrize( + "other_var", [{}, {"OTHER_VAR": None}, {"OTHER_VAR": "test-foo"}] +) +def test_project_environment_classic_confinement( + ld_library_path, path, other_var, simple_project, new_dir +): + """Verify environment when confinement is classic.""" + # create expected environment in meta/snap.yaml + environment = ld_library_path.update(path) + if environment: + expected_environment = "environment\n" + if ld_library_path: + expected_environment += f" LD_LIBRARY_PATH: {ld_library_path}" + if path: + expected_environment += f" PATH: {path}" + if other_var: + expected_environment += f" OTHER_VAR: {other_var}" + else: + expected_environment = "" + + snap_yaml.write( + simple_project(environment=environment, confinement="classic"), + prime_dir=Path(new_dir), + arch="amd64", + ) + yaml_file = Path("meta/snap.yaml") + assert yaml_file.is_file() + + content = yaml_file.read_text() + assert ( + content + == textwrap.dedent( + """\ + name: mytest + version: 1.29.3 + summary: Single-line elevator pitch for your amazing snap + description: test-description + architectures: + - amd64 + base: core22 + apps: + app1: + command: bin/mytest + confinement: classic + grade: stable + """ + ) + + expected_environment + ) + + def test_version_git(simple_project, new_dir, mocker): """Version in projects with ``version:git`` must be correctly handled.""" mocker.patch( From ba7d74c99f0fc4119b019875e4539e22082f5942 Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Tue, 20 Jun 2023 08:43:27 -0400 Subject: [PATCH 05/10] plugins: kernel doc cleanup (#4218) Signed-off-by: Robert P. J. Day --- snapcraft/parts/plugins/kernel_plugin.py | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/snapcraft/parts/plugins/kernel_plugin.py b/snapcraft/parts/plugins/kernel_plugin.py index 514657ec52..0b75402e3a 100644 --- a/snapcraft/parts/plugins/kernel_plugin.py +++ b/snapcraft/parts/plugins/kernel_plugin.py @@ -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: @@ -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) @@ -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) @@ -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) @@ -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 @@ -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 @@ -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): From 0ad49f3acc113bd76b10661f734b6056f6ae205d Mon Sep 17 00:00:00 2001 From: Callahan Date: Tue, 20 Jun 2023 12:03:27 -0500 Subject: [PATCH 06/10] ci: do not check coverage of tests dir (#4222) Signed-off-by: Callahan Kovacs --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 613d7c5e93..6cb398df58 100644 --- a/tox.ini +++ b/tox.ini @@ -53,14 +53,14 @@ base = testenv, test description = Run unit tests with pytest labels = py38, py310, py311: tests, unit-tests -commands = pytest {tty:--color=yes} --cov --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml {posargs:tests/unit} +commands = pytest {tty:--color=yes} --cov=snapcraft --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml {posargs:tests/unit} [testenv:test-legacy-{py38,py39,py310,py311,py312}] base = testenv, test description = Run legacy tests with pytest labels = py38, py310, py311: tests, integration-tests -commands = pytest {tty:--color=yes} --cov --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml {posargs:tests/legacy} +commands = pytest {tty:--color=yes} --cov=snapcraft_legacy --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml {posargs:tests/legacy} [testenv:test-noreq] base = testenv @@ -71,7 +71,7 @@ extras = dev allowlist_externals = mkdir commands_pre = mkdir -p results commands = - pytest {tty:--color=yes} --cov --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/unit {posargs} + pytest {tty:--color=yes} --cov=snapcraft --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/unit {posargs} pytest {tty:--color=yes} --junit-xml=results/legacy-test-results-{env_name}.xml tests/legacy {posargs} [lint] # Standard linting configuration From 696e4647ac548a64b0af4a8808f82a49ac8012b9 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Tue, 27 Jun 2023 11:38:34 -0400 Subject: [PATCH 07/10] type: workaround for pyright bug https://github.com/microsoft/pyright/issues/5394 --- snapcraft/commands/names.py | 3 ++- snapcraft/commands/status.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/snapcraft/commands/names.py b/snapcraft/commands/names.py index 2d477d7728..ea4374a5b3 100644 --- a/snapcraft/commands/names.py +++ b/snapcraft/commands/names.py @@ -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", ) diff --git a/snapcraft/commands/status.py b/snapcraft/commands/status.py index b1e8b6a7ff..d317645380 100644 --- a/snapcraft/commands/status.py +++ b/snapcraft/commands/status.py @@ -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", ) From 4b20c8435c88dc37ed90a7d1f44ac2dcf524aa3e Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Wed, 28 Jun 2023 16:10:35 -0400 Subject: [PATCH 08/10] spread: improve resilience of lxd-type-base test This test often times out on `lxc stop` on Google runners. --- tests/spread/providers/lxd-type-base/task.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/spread/providers/lxd-type-base/task.yaml b/tests/spread/providers/lxd-type-base/task.yaml index 614b7f9381..214506a89d 100644 --- a/tests/spread/providers/lxd-type-base/task.yaml +++ b/tests/spread/providers/lxd-type-base/task.yaml @@ -24,4 +24,14 @@ 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 i in {1..5}; do + /snap/bin/lxc stop --timeout 60 snapcraft-core20 && break || sleep 5 + done + + # If the last stop failed, include the LXC logs in the output to establish why. + if [[ $? != 0 ]]; then + lxc info --show-log snapcraft-core20 + exit 1 + fi From d5edb7e2859775f05e2ae6d8c5109eb46d9399f1 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Wed, 28 Jun 2023 19:39:19 -0400 Subject: [PATCH 09/10] linting --- tests/spread/providers/lxd-type-base/task.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/spread/providers/lxd-type-base/task.yaml b/tests/spread/providers/lxd-type-base/task.yaml index 214506a89d..060380f4c7 100644 --- a/tests/spread/providers/lxd-type-base/task.yaml +++ b/tests/spread/providers/lxd-type-base/task.yaml @@ -26,12 +26,11 @@ execute: | /snap/bin/lxc exec snapcraft-core20 cat /etc/os-release | MATCH "VERSION_CODENAME=focal" # Retry stopping, as on the Google runners this sometimes times out due to system load. - for i in {1..5}; do - /snap/bin/lxc stop --timeout 60 snapcraft-core20 && break || sleep 5 - done - - # If the last stop failed, include the LXC logs in the output to establish why. - if [[ $? != 0 ]]; then + 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 - fi + ) From ae966fcc3e9b20ede94d6578b06d7b0944bbd566 Mon Sep 17 00:00:00 2001 From: Aristo Chen Date: Sat, 1 Jul 2023 15:40:49 +0000 Subject: [PATCH 10/10] plugins: add riscv into kernel plugin for build dtbs Signed-off-by: Aristo Chen --- snapcraft/parts/plugins/kernel_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft/parts/plugins/kernel_plugin.py b/snapcraft/parts/plugins/kernel_plugin.py index 0b75402e3a..a751c890b1 100644 --- a/snapcraft/parts/plugins/kernel_plugin.py +++ b/snapcraft/parts/plugins/kernel_plugin.py @@ -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"]