Skip to content

Commit

Permalink
Support nested .run drivers
Browse files Browse the repository at this point in the history
The `NVIDIA-Linux-x86_64-545.23.08.run` driver is currently exclusively
available with CUDA 12.3.1.

It can only be downloaded separately as a `.deb`/`.rpm` from
https://developer.download.nvidia.com/compute/cuda/repos.

If we want a `.run` file, it can only be located within the
`./builds/NVIDIA-Linux-x86_64-545.23.08.run` folder of the
`cuda_12.3.1_545.23.08_linux.run` file.

Luckily, it's pretty easy to handle, we just need to repeat the
`main()` function again if we spot a
`./builds/NVIDIA-Linux-x86_64-545.23.08.run` file, although it does
mean we need to download the entire CUDA package just for a driver.
  • Loading branch information
aloisklink authored and TingPing committed Jan 13, 2024
1 parent 9471e1f commit aa6ecee
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ for VER in $DRIVER_VERSIONS; do
-e "s/@@NVIDIA_VERSION@@/${NVIDIA_VERSION}/g" \
-e "s=@@EXTRA_DATA@@=${EXTRA_DATA}=g" \
-e "s=@@NVIDIA_URL@@=${NVIDIA_URL}=g" \
-e "s=@@ARCH@@=${ARCH}=g" \
org.freedesktop.Platform.GL.nvidia.json.in > org.freedesktop.Platform.GL.nvidia-$NVIDIA_VERSION.json

flatpak-builder -v --force-clean --ccache --sandbox --delete-build-dirs \
Expand Down
2 changes: 1 addition & 1 deletion nvidia-Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all:
gcc -o apply_extra -Wall -static -DNVIDIA_VERSION='"'$(subst -,.,${NVIDIA_VERSION})'"' -DNVIDIA_BASENAME='"'$(notdir ${NVIDIA_URL})'"' nvidia-apply-extra.c $(CFLAGS) ${LDFLAGS} -larchive -lz -llzma -lzstd
gcc -o apply_extra -Wall -static -DNVIDIA_VERSION='"'$(subst -,.,${NVIDIA_VERSION})'"' -DNVIDIA_BASENAME='"'$(notdir ${NVIDIA_URL})'"' -DARCH='"'${ARCH}'"' nvidia-apply-extra.c $(CFLAGS) ${LDFLAGS} -larchive -lz -llzma -lzstd

install:
mkdir -p ${FLATPAK_DEST}/bin
Expand Down
11 changes: 11 additions & 0 deletions nvidia-apply-extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ should_extract (struct archive_entry *entry)
return 1;
}

/* this tar is only a container that stores the actual driver .run file */
if (strcmp (path, "builds/NVIDIA-Linux-" ARCH "-" NVIDIA_VERSION ".run") == 0) {
return 1;
}

return 0;
}

Expand Down Expand Up @@ -449,6 +454,12 @@ main (int argc, char *argv[])

unlink (NVIDIA_BASENAME);

/* check if this container is just a wrapper over the real driver container */
if (rename ("./builds/NVIDIA-Linux-" ARCH "-" NVIDIA_VERSION ".run", NVIDIA_BASENAME) == 0)
return main (argc, argv);
else if (errno != ENOENT)
die_with_error ("rename ./builds/NVIDIA-Linux-" ARCH "-" NVIDIA_VERSION ".run failed");

char *ldconfig_argv[] = {"ldconfig", "-n", ".", NULL};
if (subprocess (ldconfig_argv))
die ("running ldconfig failed");
Expand Down
2 changes: 1 addition & 1 deletion org.freedesktop.Platform.GL.nvidia.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
{
"name": "nvidia",
"make-args": [ "NVIDIA_VERSION=@@NVIDIA_VERSION@@", "NVIDIA_URL=@@NVIDIA_URL@@" ],
"make-args": [ "NVIDIA_VERSION=@@NVIDIA_VERSION@@", "NVIDIA_URL=@@NVIDIA_URL@@", "ARCH=@@ARCH@@" ],
"no-autogen": true,
"sources": [
{
Expand Down

0 comments on commit aa6ecee

Please sign in to comment.