Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Keep CUDA driver stubs out of AppImages

Bitti96ba49681b08
diff --git a/scripts/linux/appimage-permissions.test.sh b/scripts/linux/appimage-permissions.test.sh
index a056527..875d296 100644
--- a/scripts/linux/appimage-permissions.test.sh
+++ b/scripts/linux/appimage-permissions.test.sh
@@ -9,6 +9,10 @@ fixture=$(mktemp -d /tmp/slopus-appimage-permissions.XXXXXXXX)
trap 'rm -rf -- "$fixture"' EXIT
appdir="$fixture/Test AppDir"
mkdir -p "$appdir/usr/bin" "$appdir/usr/share" "$fixture/bin" "$fixture/plugins" "$fixture/helpers"
+mkdir -p "$appdir/usr/lib"
+# Container builds resolve libcuda through a toolkit stub. Neither the stub
+# nor cuBLAS may escape into the shipped AppImage.
+touch "$appdir/usr/lib/libcuda.so.1" "$appdir/usr/lib/libcublas.so.13" "$appdir/usr/lib/libcublasLt.so.13"
chmod 0755 "$fixture"
printf 'readable resource\n' > "$appdir/usr/share/message"
cat > "$appdir/usr/bin/slopus" <<'EOF'
@@ -50,6 +54,7 @@ chmod 0755 "$fixture/bin/"*
PATH="$fixture/bin:$PATH" LINUXDEPLOY="$fixture/bin/linuxdeploy" \
GSTREAMER_PLUGINS_DIR="$fixture/plugins" GSTREAMER_HELPERS_DIR="$fixture/helpers" \
bash "$root/scripts/linux/linuxdeploy-plugin-gstreamer.sh" --appdir "$appdir" > "$fixture/plugin.log"
+[[ ! -e $appdir/usr/lib/libcuda.so.1 && ! -e $appdir/usr/lib/libcublas.so.13 && ! -e $appdir/usr/lib/libcublasLt.so.13 ]]
bad=$(find "$appdir" \( \( -type d ! -perm -0005 \) -o \( -type f \( ! -perm -0004 -o \( -perm /0111 ! -perm -0001 \) \) \) \) -print)
[[ -z $bad ]] || { printf 'Inaccessible files: %s\n' "$bad" >&2; exit 1; }
for launcher in AppRun AppRun.wrapped usr/bin/slopus; do
diff --git a/scripts/linux/build.Dockerfile b/scripts/linux/build.Dockerfile
index 51232d7..a1cdfaf 100644
--- a/scripts/linux/build.Dockerfile
+++ b/scripts/linux/build.Dockerfile
@@ -10,4 +10,9 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh
&& sh /tmp/rustup.sh -y --profile minimal --default-toolchain 1.99.0 \
&& rm /tmp/rustup.sh
ENV PATH="/root/.cargo/bin:${PATH}"
+# Let linuxdeploy resolve the generation library without a physical GPU.
+# The deployment plugin removes the driver stub and toolkit libraries.
+RUN mkdir -p /opt/cuda-stubs \
+ && ln -s /usr/local/cuda/lib64/stubs/libcuda.so /opt/cuda-stubs/libcuda.so.1
+ENV LD_LIBRARY_PATH="/opt/cuda-stubs:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
WORKDIR /src
diff --git a/scripts/linux/linuxdeploy-plugin-gstreamer.sh b/scripts/linux/linuxdeploy-plugin-gstreamer.sh
index f86e21e..3cb5efa 100644
--- a/scripts/linux/linuxdeploy-plugin-gstreamer.sh
+++ b/scripts/linux/linuxdeploy-plugin-gstreamer.sh
@@ -36,7 +36,7 @@ ALLOWED_PLUGINS=(
)
# linuxdeploy finds these through libslopfab.so; the user's CUDA provides them.
-EXCLUDED_LIBRARIES=(libcublas.so* libcublasLt.so*)
+EXCLUDED_LIBRARIES=(libcuda.so* libcublas.so* libcublasLt.so*)
appdir=""
while (($#)); do
diff --git a/scripts/package-linux-app.sh b/scripts/package-linux-app.sh
index 18819a2..7f963bd 100644
--- a/scripts/package-linux-app.sh
+++ b/scripts/package-linux-app.sh
@@ -129,7 +129,7 @@ python3 "$root/scripts/linux/check_glibc.py" "$appimage" "$extract/squashfs-root
forbidden=$(find "$extract/squashfs-root" -type f \( -name 'libavcodec.so*' -o -name 'libavformat.so*' \
-o -name 'libavutil.so*' -o -name 'libavfilter.so*' -o -name 'libavdevice.so*' -o -name 'libswscale.so*' \
-o -name 'libswresample.so*' -o -name 'libpostproc.so*' -o -name 'libx264*.so*' -o -name 'libx265*.so*' -o -name 'libgstlibav.so' \
- -o -name 'libcublas*.so*' \) -printf '%f\n')
+ -o -name 'libcuda.so*' -o -name 'libcublas*.so*' \) -printf '%f\n')
[[ -z $forbidden ]] || fail "the AppImage bundles libraries it must not ship: $(echo $forbidden)"
[[ -f $extract/squashfs-root/usr/lib/Slopus/libslopfab.so ]] || fail 'the AppImage is missing libslopfab.so.'
# Check mode bits rather than test -r/-x: packaging may run as the file owner