new file mode 100644
@@ -0,0 +1 @@
+dynamic-modules: $SNAP_DATA
@@ -14,9 +14,25 @@ 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:
+ 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
+ source: https://git.launchpad.net/~aaronjauregui/canonical-kernel-snaps
source-type: git
source-branch: main
plugin: nil
@@ -42,6 +58,25 @@ parts:
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)/
+ 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
+
+
+
override-stage: |
echo STAGE
@@ -78,3 +113,86 @@ 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/~aaronjauregui/canonical-kernel-snaps
+ source-type: git
+ source-branch: main
+ 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 *.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/~aaronjauregui/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
+ - 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
+
+ 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
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@canonical.com> --- files/meta/kernel.yaml | 1 + snapcraft.yaml | 120 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 files/meta/kernel.yaml