[SRU][kernel-snaps-uc24.04/pc][PATCH v5 1/1] snapcraft.yaml: Add nvidia-550 and nouveau component support
Aaron Jauregui
aaron.jauregui at canonical.com
Thu Jan 30 01:05:34 UTC 2025
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 | 131 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 130 insertions(+), 2 deletions(-)
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..9acefeb 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 driver kernel objects for the Ubuntu generic kernel snap
+
+ nvidia-550-user:
+ type: standard
+ summary: Nvidia 550 userspace libraries
+ description: Userspace libraries required by the Nvidia 550 driver for the Ubuntu generic kernel snap
+
+ nouveau-ko:
+ type: kernel-modules
+ summary: Nouveau kernel module
+ description: The Nouveau kernel module for the Ubuntu generic kernel snap
+
parts:
kernel:
source: https://git.launchpad.net/canonical-kernel-snaps
@@ -25,9 +41,11 @@ parts:
- kmod
stage-packages:
- - linux-image-uc-generic
+ - linux-image-uc-generic=6.8.0-52.53
override-build: |
+ craftctl default
+
echo BULID
# Determine version and 'uname -r'
@@ -40,7 +58,22 @@ parts:
# Update depmod
/usr/sbin/depmod -b "$CRAFT_PART_INSTALL" "$unamer"
- craftctl default
+ # Move nouveau out of the file tree
+ find "$CRAFT_PART_INSTALL" -name nouveau.ko.zst -exec mv '{}' "$CRAFT_PART_INSTALL" \;
+
+ # Move hooks to staging area so they can be picked up by organize
+ mv hooks/module/* "$CRAFT_PART_INSTALL"
+ mv hooks/pc-kernel/* "$CRAFT_PART_INSTALL"
+
+ organize:
+ # Organize nouveau into a dedicated component
+ nouveau.ko.zst: (component/nouveau-ko)/
+ install.module: (component/nouveau-ko)/snap/hooks/install
+ post-refresh.module: (component/nouveau-ko)/snap/hooks/post-refresh
+ remove.module: (component/nouveau-ko)/snap/hooks/remove
+
+ install.pc-kernel: snap/hooks/install
+ post-refresh.pc-kernel: snap/hooks/post-refresh
override-stage: |
echo STAGE
@@ -78,3 +111,97 @@ parts:
mkdir "$CRAFT_PART_INSTALL"/firmware/updates
craftctl default
+
+ # Kernel object component support requires a kernel.yaml file
+ # configured with dynamic-modules: $SNAP_DATA
+ files:
+ plugin: dump
+ source: files
+
+ nvidia-550-ko-comp:
+ source: https://git.launchpad.net/canonical-kernel-snaps
+ source-type: git
+ source-branch: main
+ plugin: nil
+
+ stage-packages:
+ - binutils
+ - make
+
+ override-build: |
+ craftctl default
+ version="$(craftctl get version)"
+
+ # Duplicate libc causing conflicts, deleting to use system's libc
+ rm -f -- "$CRAFT_PART_INSTALL/usr/lib/$(uname -m)-linux-gnu/libc.so.6"
+ apt-get download linux-objects-nvidia-550-server-"${version%.*}"-generic="$version" \
+ linux-signatures-nvidia-"${version%.*}"-generic="$version"
+ for i in *.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
+ # Move hooks
+ mv hooks/nvidia-ko/* "$CRAFT_PART_INSTALL"
+
+ 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: https://git.launchpad.net/canonical-kernel-snaps
+ source-type: git
+ source-branch: main
+ plugin: nil
+
+ override-build: |
+ craftctl default
+
+ # Move hooks
+ mv hooks/nvidia-user/* "$CRAFT_PART_INSTALL"
+
+ stage-packages:
+ - libnvidia-egl-wayland1=1:1.1.13-1build1
+ - libnvidia-cfg1-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-common-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-compute-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-decode-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-encode-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-extra-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-gl-550-server=550.127.08-0ubuntu0.24.04.1
+ - libnvidia-fbc1-550-server=550.127.08-0ubuntu0.24.04.1
+ - nvidia-utils-550-server=550.127.08-0ubuntu0.24.04.1
+ - xserver-xorg-video-nvidia-550=550.120-0ubuntu0.24.04.1
+ - libnvidia-extra-550=550.120-0ubuntu0.24.04.1
+
+
+ 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
+
+ # Prune nvidia-550-user to prevent shipping duplicate mesa libraries
+ nvidia-550-user-cleanup:
+ after: [nvidia-550-user-comp]
+ source: https://github.com/canonical/gpu-snap.git
+ plugin: dump
+ override-prime: |
+ craftctl default
+ CRAFT_PRIME="$CRAFT_COMPONENT_NVIDIA_550_USER_PRIME" \
+ "$CRAFT_PART_SRC"/bin/gpu-2404-cleanup mesa-2404
+
+
+
+slots:
+ kernel-gpu-2404:
+ interface: content
+ read:
+ - $SNAP_COMMON/kernel-gpu-2404
--
2.43.0
More information about the kernel-team
mailing list