[kernel-snaps-u24.04][pc][RFC PATCH 1/1] snapcraft.yaml: Add nvidia-550 and nouveau component support
Portia Stephens
portia.stephens at canonical.com
Wed Nov 27 21:54:50 UTC 2024
On Wed, Nov 20, 2024 at 10:02 AM Aaron Jauregui
<aaron.jauregui at canonical.com> wrote:
>
> BugLink: https://bugs.launchpad.net/bugs/2088970
>
> We use components here with the aim of providing a way for nvidia
> drivers to be selected for the pc-kernel without having to rebuild,
> targetting the nvidia-550 driver as a starting point with the aim of
> supporting more driver versions in the future. Since nouveau, currently
> included in the pc-kernel, conflicts with nvidia, we replace the nouveau
> .ko with a component compatible with the nvidia component scheme.
>
> Nvidia components are mostly self-contained, but a few changes to the pc-kernel
> snap were required. files/meta/kernel.yaml is required to enable kernel
> module support in snapd. The kernel-gpu-2404 content interface is
> declared for exposing nvidia userspace libraries, and is not intended to
> be accessed directly by users.
>
> Signed-off-by: Aaron Jauregui <aaron.jauregui at canonical.com>
> ---
> files/meta/kernel.yaml | 1 +
> snapcraft.yaml | 121 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 122 insertions(+)
> create mode 100644 files/meta/kernel.yaml
>
> diff --git a/files/meta/kernel.yaml b/files/meta/kernel.yaml
> new file mode 100644
> index 0000000..aa09f00
> --- /dev/null
> +++ b/files/meta/kernel.yaml
> @@ -0,0 +1 @@
> +dynamic-modules: $SNAP_DATA
> diff --git a/snapcraft.yaml b/snapcraft.yaml
> index c08095e..5f4de72 100644
> --- a/snapcraft.yaml
> +++ b/snapcraft.yaml
> @@ -14,6 +14,22 @@ platforms:
> amd64:
> arm64:
>
> +components:
> + nvidia-550-ko:
> + type: kernel-modules
> + summary: nvidia 550 kernel objects
> + description: nvidia 550 kernel objects
> +
> + nvidia-550-user:
> + type: test
This needs to be updated to type: standard now that the store supports it.
> + summary: nvidia 550 userspace libraries
> + description: nvidia 550 userspace libraries
> +
> + nouveau:
> + type: kernel-modules
> + summary: nouveau kernel module
> + description: nouveau kernel module
> +
> parts:
> kernel:
> source: https://git.launchpad.net/canonical-kernel-snaps
> @@ -42,6 +58,13 @@ parts:
>
> craftctl default
>
> + # Move nouveau out of the file tree
> + find "$CRAFT_PART_INSTALL" -name nouveau.ko.zst -exec mv '{}' "$CRAFT_PART_INSTALL" \;
> +
> + # Move nouveau into a dedicated component
> + organize:
> + nouveau.ko.zst: (component/nouveau)/
> +
> override-stage: |
> echo STAGE
>
> @@ -78,3 +101,101 @@ parts:
> mkdir "$CRAFT_PART_INSTALL"/firmware/updates
>
> craftctl default
> +
> + #TODO temporary workaround for nouveau hooks not being in canonical-kernel-snaps repo
> + nouveau-scripts:
> + source: ./hooks
> + plugin: nil
> + override-build: |
> + craftctl default
> + cp install.pc-kernel install.module remove.module $CRAFT_PART_INSTALL/
> +
> + # duplicate install.module as a post refres hook
> + cp install.module $CRAFT_PART_INSTALL/post-refresh.module
> + cp install.pc-kernel $CRAFT_PART_INSTALL/post-refresh.pc-kernel
> + organize:
> + install.module: (component/nouveau)/snap/hooks/install
> + post-refresh.module: (component/nouveau)/snap/hooks/post-refresh
> + remove.module: (component/nouveau)/snap/hooks/remove
> + install.pc-kernel: snap/hooks/install
> + post-refresh.pc-kernel: snap/hooks/post-refresh
> +
> +
> + files:
> + plugin: dump
> + source: files
> +
> + nvidia-550-ko-comp:
> + source: ./hooks
> + plugin: nil
> +
> + stage-packages:
> + - binutils
> + - make
> +
> + override-build: |
> + craftctl default
> + version="$(craftctl get version)"
> +
> + #clean up unnecessary libs
> + rm -f -- $CRAFT_PART_INSTALL/usr/lib/$(uname -m)-linux-gnu/libc.so.6
> + apt-get download linux-objects-nvidia-550-server-${version%.*}-generic \
> + linux-signatures-nvidia-${version%.*}-generic
> + for i in `find . -name '*.deb'` ; do dpkg-deb -x $i nvidia-objects ; done
> +
> + mkdir -p $CRAFT_PART_INSTALL/bits
> + mv nvidia-objects/lib/modules/*/kernel/nvidia-550srv/bits/* $CRAFT_PART_INSTALL/bits
> + # Reuse the install hook as the post-refresh hook
> + cp install.nvidia-ko remove.nvidia-ko $CRAFT_PART_INSTALL/
> + cp install.nvidia-ko $CRAFT_PART_INSTALL/post-refresh.nvidia
> + cp kernel-gpu-2404-provider-mangler $CRAFT_PART_INSTALL/kernel-gpu-2404-provider-mangler
> +
> + organize:
> + bits/: (component/nvidia-550-ko)/bits
> + usr/bin: (component/nvidia-550-ko)/bin
> + usr/lib: (component/nvidia-550-ko)/lib
> + install.nvidia-ko: (component/nvidia-550-ko)/snap/hooks/install
> + post-refresh.nvidia-ko: (component/nvidia-550-ko)/snap/hooks/post-refresh
> + remove.nvidia-ko: (component/nvidia-550-ko)/snap/hooks/remove
> +
> + nvidia-550-user-comp:
> + source: ./hooks
> + plugin: nil
> +
> + stage-packages:
> + - libnvidia-egl-wayland1
> + - libnvidia-cfg1-550-server
> + - libnvidia-common-550-server
> + - libnvidia-compute-550-server
> + - libnvidia-decode-550-server
> + - libnvidia-encode-550-server
> + - libnvidia-extra-550-server
> + - libnvidia-gl-550-server
> + - libnvidia-fbc1-550-server
> + - nvidia-utils-550-server
> + - xserver-xorg-video-nvidia-550
> + - libnvidia-extra-550
> +
> + override-build: |
> + craftctl default
> + cp install.nvidia-user $CRAFT_PART_INSTALL/
> + cp install.nvidia-user $CRAFT_PART_INSTALL/
> + cp remove.nvidia-user $CRAFT_PART_INSTALL/
> + cp kernel-gpu-2404-provider-mangler $CRAFT_PART_INSTALL/
> +
> + organize:
> + usr/share: (component/nvidia-550-user)/usr/share
> + usr/lib: (component/nvidia-550-user)/usr/lib
> + usr/bin/nvidia-smi: (component/nvidia-550-user)/usr/bin/nvidia-smi
> + kernel-gpu-2404-provider-mangler: (component/nvidia-550-user)/kernel-gpu-2404-provider-mangler
> + install.nvidia-user: (component/nvidia-550-user)/snap/hooks/install
> + post-refresh.nvidia-user: (component/nvidia-550-user)/snap/hooks/post-refresh
> + remove.nvidia-user: (component/nvidia-550-user)/snap/hooks/remove
> +
> +
> +
> +slots:
> + kernel-gpu-2404:
> + interface: content
> + read:
> + - $SNAP_COMMON/kernel-gpu-2404
> --
> 2.43.0
>
>
> --
> kernel-team mailing list
> kernel-team at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
More information about the kernel-team
mailing list