diff mbox series

[1/1] snapcraft.yaml: Add check for nvidia firmware files

Message ID 20250113231913.924785-2-aaron.jauregui@canonical.com
State New
Headers show
Series add build-time check for nvidia firmware | expand

Commit Message

Aaron Jauregui Jan. 13, 2025, 11:18 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2089509

Prevent builds with missing nvidia firmware files that may be
trimmed due to version mismatches from succeeding.

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

Comments

Juerg Haefliger Jan. 16, 2025, 9:32 a.m. UTC | #1
On Tue, 14 Jan 2025 10:18:46 +1100
Aaron Jauregui <aaron.jauregui@canonical.com> wrote:

> BugLink: https://bugs.launchpad.net/bugs/2089509
> 
> Prevent builds with missing nvidia firmware files that may be
> trimmed due to version mismatches from succeeding.
> 
> Signed-off-by: Aaron Jauregui <aaron.jauregui@canonical.com>
> ---
>  snapcraft.yaml | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/snapcraft.yaml b/snapcraft.yaml
> index 9e5ec26..c57dd33 100644
> --- a/snapcraft.yaml
> +++ b/snapcraft.yaml
> @@ -96,4 +96,9 @@ 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 blobs are present
> +        modpath="$(find $SNAPCRAFT_STAGE/modules/*/kernel/nvidia-* -name nv.o)"
> +        while IFS= read -r fw ; do
> +          test -e "$SNAPCRAFT_STAGE/firmware/$fw"
> +        done < <(strings -d "$modpath" | sed -n 's/^firmware=//p')
>        fi

Look good. Thanks for the patience and the iterations!

Acked-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Stefan Bader Jan. 16, 2025, 9:40 a.m. UTC | #2
On 14.01.25 00:18, Aaron Jauregui wrote:
> BugLink: https://bugs.launchpad.net/bugs/2089509
> 
> Prevent builds with missing nvidia firmware files that may be
> trimmed due to version mismatches from succeeding.
> 
> Signed-off-by: Aaron Jauregui <aaron.jauregui@canonical.com>
> ---
>   snapcraft.yaml | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/snapcraft.yaml b/snapcraft.yaml
> index 9e5ec26..c57dd33 100644
> --- a/snapcraft.yaml
> +++ b/snapcraft.yaml
> @@ -96,4 +96,9 @@ 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 blobs are present
> +        modpath="$(find $SNAPCRAFT_STAGE/modules/*/kernel/nvidia-* -name nv.o)"
> +        while IFS= read -r fw ; do
> +          test -e "$SNAPCRAFT_STAGE/firmware/$fw"

I guess this fails the build because of bailing on any RC != 0. I would 
prefer having a proper "if" case maybe even with an echo that states 
which blob is missing. If the bailing could be moved to after the loop 
one might even get a list of MISSes. I might overcomplicate it but I am 
thinking of a case where only one additional blob misses.
But at least having a message about why things failed would help 
tracking issues.

> +        done < <(strings -d "$modpath" | sed -n 's/^firmware=//p')
>         fi
Juerg Haefliger Jan. 16, 2025, 9:54 a.m. UTC | #3
On Thu, 16 Jan 2025 10:40:25 +0100
Stefan Bader <stefan.bader@canonical.com> wrote:

> On 14.01.25 00:18, Aaron Jauregui wrote:
> > BugLink: https://bugs.launchpad.net/bugs/2089509
> > 
> > Prevent builds with missing nvidia firmware files that may be
> > trimmed due to version mismatches from succeeding.
> > 
> > Signed-off-by: Aaron Jauregui <aaron.jauregui@canonical.com>
> > ---
> >   snapcraft.yaml | 5 +++++
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/snapcraft.yaml b/snapcraft.yaml
> > index 9e5ec26..c57dd33 100644
> > --- a/snapcraft.yaml
> > +++ b/snapcraft.yaml
> > @@ -96,4 +96,9 @@ 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 blobs are present
> > +        modpath="$(find $SNAPCRAFT_STAGE/modules/*/kernel/nvidia-* -name nv.o)"
> > +        while IFS= read -r fw ; do
> > +          test -e "$SNAPCRAFT_STAGE/firmware/$fw"  
> 
> I guess this fails the build because of bailing on any RC != 0. I would 
> prefer having a proper "if" case maybe even with an echo that states 
> which blob is missing. If the bailing could be moved to after the loop 
> one might even get a list of MISSes. I might overcomplicate it but I am 
> thinking of a case where only one additional blob misses.
> But at least having a message about why things failed would help 
> tracking issues.

IMO additional info doesn't add much value. It's generally bad if we fail
here and there's an nvidia package mismatch. We either have all fws or none.
Also, the build log shows the fws being copied and snapcraft uses `set -x` so
we see all the shell commands.

...Juerg


> 
> > +        done < <(strings -d "$modpath" | sed -n 's/^firmware=//p')
> >         fi  
> 
>
Stefan Bader Jan. 16, 2025, 1:48 p.m. UTC | #4
On 14.01.25 00:18, Aaron Jauregui wrote:
> BugLink: https://bugs.launchpad.net/bugs/2089509
> 
> Prevent builds with missing nvidia firmware files that may be
> trimmed due to version mismatches from succeeding.
> 
> Signed-off-by: Aaron Jauregui <aaron.jauregui@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---

since it does not seem to matter
>   snapcraft.yaml | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/snapcraft.yaml b/snapcraft.yaml
> index 9e5ec26..c57dd33 100644
> --- a/snapcraft.yaml
> +++ b/snapcraft.yaml
> @@ -96,4 +96,9 @@ 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 blobs are present
> +        modpath="$(find $SNAPCRAFT_STAGE/modules/*/kernel/nvidia-* -name nv.o)"
> +        while IFS= read -r fw ; do
> +          test -e "$SNAPCRAFT_STAGE/firmware/$fw"
> +        done < <(strings -d "$modpath" | sed -n 's/^firmware=//p')
>         fi
diff mbox series

Patch

diff --git a/snapcraft.yaml b/snapcraft.yaml
index 9e5ec26..c57dd33 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -96,4 +96,9 @@  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 blobs are present
+        modpath="$(find $SNAPCRAFT_STAGE/modules/*/kernel/nvidia-* -name nv.o)"
+        while IFS= read -r fw ; do
+          test -e "$SNAPCRAFT_STAGE/firmware/$fw"
+        done < <(strings -d "$modpath" | sed -n 's/^firmware=//p')
       fi