Last active
November 9, 2020 17:35
-
-
Save brimston3/076161bf2d0edf111458466b563b3166 to your computer and use it in GitHub Desktop.
debian buster steam chroot install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright 2017-07-21 Andrew Domaszek | |
# BSD-New license | |
# https://wiki.debian.org/chroot | |
# https://superuser.com/questions/616922/schroot-dont-share-home-directory | |
# install prereqs: | |
# apt-get install debootstrap schroot | |
# call as: | |
# sudo steam_chroot.sh | |
# Use result as: | |
# schroot -c steam64 | |
## | |
# May desire to unbind pulseaudio from the alsa device to allow | |
# simultaneous audio with the chroot. | |
# host:/etc/pulse/default.pa | |
# Comment out: | |
# load-module module-udev-detect | |
# load-module module-detect | |
# Add: | |
# load-module module-alsa-sink device=dmix | |
# load-module module-alsa-source device=dsnoop | |
# apt proxy is autodetected if http_proxy is unset, change this to set it manually. | |
#export http_proxy=http://192.168.0.3:3142/ | |
CHROOTBASE=/srv/schroot/steam64 | |
USERNAME=$SUDO_USER | |
if [ "x$(which apt-config)" != "x" ]; then | |
APT_PROXY_CFG=$(apt-config dump Acquire::http::Proxy) | |
fi | |
if [ "x$APT_PROXY_CFG" != "x" -a "x$http_proxy" = "x" ]; then | |
export http_proxy=$(echo $APT_PROXY_CFG | awk 'NR==1{print $2}' | tr -d '";') | |
fi | |
mkdir -p "$CHROOTBASE" | |
debootstrap --arch=amd64 --variant=minbase buster "$CHROOTBASE" | |
if [ "x$http_proxy" != "x" ]; then | |
echo "Acquire::http::Proxy \"$http_proxy\";" > "$CHROOTBASE"/etc/apt/apt.conf.d/01proxy | |
fi | |
cp /etc/resolv.conf /etc/hosts "$CHROOTBASE"/etc | |
basename "$CHROOTBASE" > "$CHROOTBASE"/etc/debian_chroot | |
cat > "$CHROOTBASE"/etc/apt/sources.list <<EOF | |
deb http://deb.debian.org/debian buster main contrib non-free | |
deb http://security.debian.org/debian-security buster/updates main contrib non-free | |
deb http://ftp.us.debian.org/debian/ buster-updates main contrib non-free | |
deb http://deb.debian.org/debian/ buster-updates main contrib non-free | |
deb http://ftp.us.debian.org/debian/ buster-backports main contrib non-free | |
EOF | |
cat > "$CHROOTBASE"/root/chroot_cmds.sh <<"EOF2" | |
cat > usr/sbin/policy-rc.d <<EOF | |
#!/bin/sh | |
exit 101 | |
EOF | |
dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot | |
ln -s /bin/true /usr/bin/ischroot | |
dpkg --add-architecture i386 | |
apt-get update | |
apt-get install -y sudo busybox-static zsh less ca-certificates fontconfig | |
apt-get install -y libgl1-mesa-glx libgl1-mesa-glx:i386 libegl1-mesa libegl1-mesa:i386 nvidia-driver-libs nvidia-driver-libs-i386 | |
apt-get install -y steam | |
# This is a hack, but steam wants libdb5.1.so (or did at the time of this writing) | |
set -x | |
for each in libdb5.1_5.1.29-5_i386.deb libdb5.1_5.1.29-5_amd64.deb ; do | |
busybox wget http://ftp.us.debian.org/debian/pool/main/d/db/$each -O /tmp/$each | |
dpkg -i /tmp/$each | |
done | |
set +x | |
EOF2 | |
chroot "$CHROOTBASE" /bin/sh /root/chroot_cmds.sh | |
cd "$CHROOTBASE" | |
cp -a etc/skel home/$USERNAME | |
for dotfile in .zshrc .bashrc ; do | |
cp /home/$USERNAME/$dotfile home/$USERNAME/ | |
done | |
chown -R $USERNAME:$USERNAME home/$USERNAME | |
if [ ! -d /etc/schroot/nohome ]; then | |
cp -a /etc/schroot/default /etc/schroot/nohome | |
sed -i -e '/^\/home/d' /etc/schroot/nohome/fstab | |
echo "none /dev/shm tmpfs rw,nosuid,noexec,nodev,relatime 0 0" >> /etc/schroot/nohome/fstab | |
fi | |
CHROOTSHORTBASE=$(basename "$CHROOTBASE") | |
cat >/etc/schroot/chroot.d/$CHROOTSHORTBASE<<EOF | |
[$CHROOTSHORTBASE] | |
description=Valve Steam | |
type=directory | |
directory=$CHROOTBASE | |
users=$USERNAME | |
root-groups=root | |
profile=desktop | |
personality=linux | |
preserve-environment=true | |
setup.fstab=nohome/fstab | |
EOF |
I've found I can get pulse working in the schroot with a couple extra lines in /etc/schroot/nohome/fstab:
/home/MYUSER/.config/pulse /home/MYUSER/.config/pulse none rw,bind 0 0
/var/lib/dbus /var/lib/dbus none ro,bind 0 0
/run/user/MYUSER_ID_NUM/pulse /run/user/MYUSER_ID_NUM/pulse none rw,bind 0 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug: does not detect if SUDO_USER/USERNAME is empty.
Bug: does not use user's primary group.
Bug: presumes nvidia graphics.