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

Juerg Haefliger juerg.haefliger at canonical.com
Tue Jan 7 07:39:45 UTC 2025


On Tue,  7 Jan 2025 14:14:30 +1100
Aaron Jauregui <aaron.jauregui at canonical.com> wrote:

> 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

Nit: single '=' is sufficient for POSIX test.


> +          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

This only seems to check versions but not actual presence of firmware blobs
which I think is what we should do. I.e., verify that the following files are
present in the staging area:

$ strings -d "$modpath" | sed -n 's/^firmware=//p'
nvidia/535.183.01/gsp_tu10x.bin
nvidia/535.183.01/gsp_ga10x.bin


Something like (untested):

modpath="$SNAPCRAFT_STAGE/modules/*/kernel/nvidia-*/bits/nvidia/nv.o"
while IFS= read -r fw ; do
  test -e "$SNAPCRAFT_STAGE/firmware/$fw"
done < <(strings -d "$modpath" | sed -n 's/^firmware=//p')

...Juerg


>        fi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20250107/379c1be4/attachment.sig>


More information about the kernel-team mailing list