[kernel-snaps-u24.04][pc] components: add support for nvidia-550 kernel components

Portia Stephens portia.stephens at canonical.com
Thu Oct 3 05:42:11 UTC 2024


This adds the kernel component for nvidia 550 kernel drivers to be published
alongside the pc-kernel snap. There exist two hooks, assemble.sh which
is run when the component is installed and provides the linking of the
ko files and remove.sh which removes the ko files when the component is
uninstalled.

Signed-off-by: Portia Stephens <portia.stephens at canonical.com>
Signed-off-by: Aaron Jauregui <aaron.jauregui at canonical.com>
---
 files/meta/kernel.yaml      |  1 +
 nvidia-ko-hooks/assemble.sh | 18 ++++++++++++++++++
 nvidia-ko-hooks/remove.sh   |  6 ++++++
 snapcraft.yaml              | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+)
 create mode 100644 files/meta/kernel.yaml
 create mode 100644 nvidia-ko-hooks/assemble.sh
 create mode 100644 nvidia-ko-hooks/remove.sh

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/nvidia-ko-hooks/assemble.sh b/nvidia-ko-hooks/assemble.sh
new file mode 100644
index 0000000..e1c0834
--- /dev/null
+++ b/nvidia-ko-hooks/assemble.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -eux
+
+mkdir $SNAP_COMMON/nvidia-ko
+cp -r $SNAP_COMPONENT/bits $SNAP_COMMON/nvidia-ko/bits
+
+cd $SNAP_COMMON/nvidia-ko/bits
+
+sed -i "s|/usr/bin/ld.bfd|$SNAP_COMPONENT/bin/ld.bfd|" BUILD
+sed -i "s|make|$SNAP_COMPONENT/bin/make|" BUILD
+
+# TODO rewrite lib path for more generic
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP_COMPONENT/lib/x86_64-linux-gnu sh BUILD
+
+mkdir -p $SNAP_DATA/modules/$(uname -r)
+
+mv ../*.ko $SNAP_DATA/modules/$(uname -r)/
diff --git a/nvidia-ko-hooks/remove.sh b/nvidia-ko-hooks/remove.sh
new file mode 100644
index 0000000..b0547cc
--- /dev/null
+++ b/nvidia-ko-hooks/remove.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -eux
+
+rm -rf $SNAP_COMMON/nvidia-ko
+rm -rf $SNAP_DATA/modules/$(uname -r)
diff --git a/snapcraft.yaml b/snapcraft.yaml
index c08095e..64a6a84 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -14,6 +14,13 @@ platforms:
   amd64:
   arm64:
 
+components:
+  nvidia-550-ko:
+    type: test
+    summary: nvidia 550 kernel objects
+    description: nvidia 550 kernel objects
+    version: "0.1"
+
 parts:
   kernel:
     source: https://git.launchpad.net/canonical-kernel-snaps
@@ -78,3 +85,28 @@ parts:
       mkdir "$CRAFT_PART_INSTALL"/firmware/updates
 
       craftctl default
+
+  nvidia-550-ko-comp:
+    source: ./nvidia-ko-hooks
+    plugin: nil
+
+    stage-packages:
+      - binutils
+      - make
+
+    override-build: |
+      craftctl default
+      #clean up unnecessary libs
+      rm -f -- $CRAFT_PART_INSTALL/usr/lib/x86_64-linux-gnu/libc.so.6
+      apt-get download linux-objects-nvidia-550-server-6.8.0-41-generic
+      dpkg-deb -x *.deb nvidia-objects
+      mv nvidia-objects/lib/modules/*/kernel/nvidia-550srv/bits $CRAFT_PART_INSTALL/
+      mv assemble.sh $CRAFT_PART_INSTALL/assemble.sh
+      mv remove.sh $CRAFT_PART_INSTALL/remove.sh
+
+    organize:
+      bits/: (component/nvidia-550-ko)/bits
+      usr/bin: (component/nvidia-550-ko)/bin
+      usr/lib: (component/nvidia-550-ko)/lib
+      assemble.sh: (component/nvidia-550-ko)/snap/hooks/install
+      remove.sh: (component/nvidia-550-ko)/snap/hooks/remove
-- 
2.43.0




More information about the kernel-team mailing list