Skip to content

Commit

Permalink
init: fix nvidia integration, improve search of nvidia files, Fix #1500
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Oct 12, 2024
1 parent faa7e0b commit c3f30eb
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -1867,16 +1867,18 @@ if [ "${nvidia}" -eq 1 ]; then
# First we find all non-lib files we need, this includes
# - binaries
# - confs
# - egl files
# - icd files
# Excluding here the libs, we will threat them later specifically
NVIDIA_FILES="$(find /run/host/etc/ /run/host/usr/ \
-path "/run/host/usr/lib/i386-linux-gnu/*" -prune -o \
-path "/run/host/usr/lib/x86_64-linux-gnu/*" -prune -o \
-path "/run/host/usr/lib32/*" -prune -o \
-path "/run/host/usr/lib64/*" -prune -o \
-path "/run/host/usr/lib/*" -prune -o \
-path "/run/host/usr/include/boost/*" -prune -o \
-path "/run/host/usr/share/*" -prune -o \
-path "/run/host/usr/src/*" -prune -o \
-path "/run/host/usr/include/*" -prune -o \
-path "*.png" -prune -o \
-path "*.svg" -prune -o \
-path "*.repo" -prune -o \
-iname "*nvidia*" -not -type d -print 2> /dev/null || :)"
for nvidia_file in ${NVIDIA_FILES}; do
Expand All @@ -1888,6 +1890,27 @@ if [ "${nvidia}" -eq 1 ]; then
mount_bind "${nvidia_file}" "${dest_file}" ro"${locked_flags:+,${locked_flags}}"
done

# First we find all non-lib files we need, this includes
# - egl files
# - icd files
# - doc files
# - src files
# Excluding here the libs, we will threat them later specifically
NVIDIA_FILES="$(find \
/run/host/usr/share/*nvidia* \
/run/host/usr/share/*vulkan* \
/run/host/usr/share/doc/*nvidia* \
/run/host/usr/src/*nvidia* \
-not -type d -print 2> /dev/null || :)"
for nvidia_file in ${NVIDIA_FILES}; do
dest_file="$(printf "%s" "${nvidia_file}" | sed 's|/run/host||g')"

# Mounting read-only in a user namespace will trigger a check to see if certain
# "locked" flags (line noexec,nodev,nosuid) are changed. This ensures we explicitly reuse those flags.
locked_flags="$(get_locked_mount_flags "${nvidia_file}")"
mount_bind "${nvidia_file}" "${dest_file}" ro"${locked_flags:+,${locked_flags}}"
done

# Then we find all directories with nvidia in the name and just mount them
NVIDIA_DIRS="$(find /run/host/etc /run/host/usr -iname "*nvidia*" -type d 2> /dev/null || :)"
for nvidia_dir in ${NVIDIA_DIRS}; do
Expand Down

0 comments on commit c3f30eb

Please sign in to comment.