[kernel-snaps-uc22][PATCH v2 1/1] snapcraft.yaml: Prevent nvidia version mismatch

Aaron Jauregui aaron.jauregui at canonical.com
Tue Jan 7 03:14:30 UTC 2025


BugLink: https://bugs.launchpad.net/bugs/2089509

Prevent builds with mismatched nvidia firmware and module versions
from succeeding by testing version numbers during stage.

Signed-off-by: Aaron Jauregui <aaron.jauregui at canonical.com>
---
 snapcraft.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/snapcraft.yaml b/snapcraft.yaml
index 9e5ec26..22d816a 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -96,4 +96,12 @@ parts:
       # Check that only one nvidia series got shipped
       if [ "$SNAPCRAFT_TARGET_ARCH" != "armhf" ]; then
         [ $(ls "$SNAPCRAFT_STAGE"/modules/*/kernel/nvidia-*/bits/SHA256SUMS | wc -l) -eq 1 ]
+        # Make sure firmware and module versions match
+        if [ "$SNAPCRAFT_TARGET_ARCH" == "amd64" ]; then
+          modpath="$SNAPCRAFT_STAGE/modules/*/kernel/nvidia-*/bits/nvidia/nv.o"
+          fwpath="$(find $SNAPCRAFT_STAGE/firmware/nvidia/ -mindepth 1 -type f -print -quit)"
+          mod_ver="$(grep -ao 'firmware=nvidia/.*\.bin' $modpath | cut -d / -f2)"
+          fw_ver="$(grep -Eao "Driver Version: [0-9]+\.[0-9]+\.[0-9]+" $fwpath | cut -d ' ' -f3)"
+          [ "$mod_ver" = "$fw_ver" ]
+        fi
       fi
-- 
2.43.0




More information about the kernel-team mailing list