support NVIDIA and the Generic OpenGL drivers detection
This commit is contained in:
parent
ae7100b6c0
commit
21f59f24d0
30
Dockerfile
30
Dockerfile
@ -26,6 +26,7 @@ RUN echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d && \
|
||||
chmod +x /usr/sbin/policy-rc.d
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# 1. Keep the image updated
|
||||
# 2. Install the dependencies
|
||||
# 3. Install the latest version of Steam
|
||||
@ -36,10 +37,34 @@ RUN echo "deb [arch=amd64,i386] http://repo.steampowered.com/steam/ precise stea
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y dist-upgrade && \
|
||||
apt-get -fy install && \
|
||||
apt-get -y install pciutils pulseaudio nvidia-340 mesa-utils steam && \
|
||||
apt-get -y install binutils pciutils pulseaudio mesa-utils steam && \
|
||||
rm -f /etc/apt/sources.list.d/tmp-steam.list && \
|
||||
rm -rf /var/lib/apt/lists
|
||||
|
||||
# COPY [ "nvidia-340-mini", "/usr/lib/nvidia-340" ]
|
||||
|
||||
# Install NVIDIA Drivers.
|
||||
# Currently supported versions: 304, 340, 361
|
||||
ADD http://archive.ubuntu.com/ubuntu/pool/restricted/n/nvidia-graphics-drivers-304/nvidia-304_304.131-0ubuntu3_i386.deb /tmp/nvidia-304.deb
|
||||
ADD http://archive.ubuntu.com/ubuntu/pool/restricted/n/nvidia-graphics-drivers-340/nvidia-340_340.96-0ubuntu3_i386.deb /tmp/nvidia-340.deb
|
||||
ADD http://archive.ubuntu.com/ubuntu/pool/restricted/n/nvidia-graphics-drivers-361/nvidia-361_361.42-0ubuntu2_i386.deb /tmp/nvidia-361.deb
|
||||
|
||||
RUN cd /tmp && \
|
||||
ar xv nvidia-304.deb data.tar.xz && \
|
||||
tar xf data.tar.xz -C / && \
|
||||
rm -f data.tar.xz nvidia-304.deb
|
||||
|
||||
RUN cd /tmp && \
|
||||
ar xv nvidia-340.deb data.tar.xz && \
|
||||
tar xf data.tar.xz -C / && \
|
||||
rm -f data.tar.xz nvidia-340.deb
|
||||
|
||||
RUN cd /tmp && \
|
||||
ar xv nvidia-361.deb data.tar.xz && \
|
||||
tar xf data.tar.xz -C / && \
|
||||
rm -f data.tar.xz nvidia-361.deb
|
||||
|
||||
|
||||
# Set the locale to en_US.UTF-8
|
||||
RUN locale-gen en_US.UTF-8 && \
|
||||
update-locale
|
||||
@ -58,9 +83,6 @@ ENV GROUPS audio,video
|
||||
ENV HOME /home/$USER
|
||||
RUN useradd -m -d $HOME -u $UID -G $GROUPS $USER
|
||||
|
||||
# Tools which might be helpful in troubleshooting
|
||||
# RUN apt-get -y install alsa-utils mesa-utils vim less gdb strace binutils
|
||||
|
||||
USER $USER
|
||||
WORKDIR $HOME
|
||||
COPY ./launch /launch
|
||||
|
81
launch
81
launch
@ -1,7 +1,76 @@
|
||||
#!/bin/sh
|
||||
set -x
|
||||
#!/bin/bash
|
||||
# This script will attempt to load one of the NVIDIA driver version which
|
||||
# present in this script, otherwise it will try to fallback to the Generic
|
||||
# OpenGL driver (libgl1-mesa-glx)
|
||||
|
||||
# Test whether NVIDIA's libGL.so.1 is working and if it doesn't work,
|
||||
# fallback to free implementation of the OpenGL API (libgl1-mesa-glx)
|
||||
glxinfo >/dev/null 2>&1 || export LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/mesa
|
||||
steam $@
|
||||
# The list of Nvidia Supported Driver Version which present in this container
|
||||
NSDV="361 340 304"
|
||||
|
||||
# Try to load the Generic OpenGL driver (libgl1-mesa-glx)
|
||||
# Return 0 on success
|
||||
function testGeneric {
|
||||
export LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/mesa
|
||||
glxinfo >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
# Try to load the NVIDIA driver
|
||||
# Return 0 on success
|
||||
function testNvidiaVer {
|
||||
export LD_LIBRARY_PATH=/usr/lib/nvidia-$1
|
||||
[ -e "$LD_LIBRARY_PATH/libGL.so.1" ] && glxinfo >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
#
|
||||
# Go through all available in this container versions of the NVIDIA drivers and
|
||||
# return the version which worked.
|
||||
# If none of the NVIDIA drivers worked, then try to load the Generic OpenGL
|
||||
# driver.
|
||||
#
|
||||
# Return 0 on success
|
||||
# Return 1 if none of the graphic drivers worked, including the Generic OpenGL
|
||||
#
|
||||
function detectNvidiaDriver {
|
||||
echo "Attempting to load one of the supported NVIDIA drivers: "
|
||||
for ver in $NSDV; do
|
||||
echo -n " Trying to load NVIDIA driver version: $ver ... "
|
||||
testNvidiaVer $ver
|
||||
RC=$?
|
||||
if [ $RC -eq 0 ]; then
|
||||
echo "SUCCESS"
|
||||
return $ver
|
||||
else
|
||||
echo "FAILURE"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Attempting to load the Generic OpenGL driver ..."
|
||||
testGeneric
|
||||
RC=$?
|
||||
return $RC
|
||||
}
|
||||
|
||||
#
|
||||
# START
|
||||
#
|
||||
detectNvidiaDriver
|
||||
RC=$?
|
||||
if [ $RC -eq 0 ]; then
|
||||
echo "NVIDIA drivers could not be loaded."
|
||||
echo "Generic OpenGL driver will be used"
|
||||
elif [ $RC -eq 1 ]; then
|
||||
echo "None of the supported NVIDIA drivers worked :/"
|
||||
echo "Please try installing one of the supported NVIDIA drivers"
|
||||
echo "Supported NVIDIA driver version are: $NSDV"
|
||||
fi
|
||||
|
||||
export LD_LIBRARY_PATH
|
||||
echo "LD_LIBRARY_PATH is set to: $LD_LIBRARY_PATH"
|
||||
|
||||
# This script understands the "glxdebug" argument
|
||||
if [ "$1" == "glxdebug" ]; then
|
||||
linux32 glxgears -info
|
||||
else
|
||||
linux32 steam $@
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user