Package: steam
Version: 1.0.0.56-1
Severity: important
Tags: patch

According to Valve developers, the Steam client is meant to support
multiple parallel installations, with $XDG_DATA_HOME/Steam as the path
that is normally used. On Linux, ~/.steam/steam is meant to be a symbolic
link to the most recently run installation root for production versions
of the Steam client (there can also be a parallel ~/.steam/steambeta
for internal beta-test versions, which you can see referenced in the
bin_steam.sh script), which allows the Steam client and the Steamworks API
to find the Steam installation root even if the XDG_DATA_HOME environment
variable has changed since installation. Users can also switch between
multiple parallel installations by running /path/to/installation/steam.sh,
which will update the symbolic links.

The steam package in Debian has traditionally unpacked the Steam
bootstrapper directly into ~/.steam, which gives that directory a dual
role: the installation root, and also the symlink farm.  Unfortunately,
a bootstrapped installation root will contain a ./steam directory,
which collides with the ~/.steam/steam symbolic link, preventing its
creation. Components of the Steam client end up unpredictably installed
into either ~/.steam or ~/.steam/steam, depending on the exact path
they open (writes via ~/.steam/steam end up in the subdirectory,
but writes via ~/.steam/root do not, even though in Valve's Steam client
package, both are normally meant to be symlinks to ~/.local/share/Steam).

For example, my ~/.steam directory on one Debian machine has most games
and mods in ~/.steam/steam/SteamApps, but one mod in ~/.steam/steamapps
instead. (I suspect that single mod might actually not work at all.)

We can't easily disentangle this for existing installations, but for
new installations we can reduce confusion by behaving the way
upstream intended.

The attached patches also make the shell script more robust by quoting
variables more defensively.

I've tested this against an existing Debian Steam installation in ~/.steam
(layout is unchanged) and in a new installation (the client ends up
installed in ~/.local/share/Steam as intended, with symlinks in ~/.steam).

    smcv
>From 97b72883bbb9785af1533c5c076ae4e7d6a1167f Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Tue, 13 Nov 2018 12:54:11 +0000
Subject: [PATCH 3/7] d/scripts/steam: Quote variables defensively

Signed-off-by: Simon McVittie <s...@collabora.com>
---
 debian/scripts/steam | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/debian/scripts/steam b/debian/scripts/steam
index 9b3ef31..9467f40 100644
--- a/debian/scripts/steam
+++ b/debian/scripts/steam
@@ -2,10 +2,10 @@
 # Copyright (C) 2013-2017 Michael Gilbert <mgilb...@debian.org>
 # License: MIT
 
-config=$HOME/.steam
-ubuntu32=$config/ubuntu12_32
-steam=$ubuntu32/steam
-runtime=$ubuntu32/steam-runtime
+config="$HOME/.steam"
+ubuntu32="$config/ubuntu12_32"
+steam="$ubuntu32/steam"
+runtime="$ubuntu32/steam-runtime"
 
 real=/usr/lib/games/steam/steam
 
@@ -23,22 +23,22 @@ if ! grep -q sse2 /proc/cpuinfo; then
 fi
 
 # do an initial update when expected pieces are missing
-test ! -d $config && rm -rf $config && mkdir -p $config || true
-test ! -x $config/steam.sh && rm -rf $config/package $steam || true
-test ! -d $ubuntu32 && rm -rf $ubuntu32 && mkdir -p $ubuntu32 || true
-test ! -x $steam && rm -rf $steam && cp $real $steam && $steam || true
-test ! -e $runtime.tar.xz && cat $runtime.tar.xz.part* > $runtime.tar.xz || true
-test ! -d $runtime && cd $ubuntu32 && tar xf steam-runtime.tar.xz && \
+test ! -d "$config" && rm -rf "$config" && mkdir -p "$config" || true
+test ! -x "$config/steam.sh" && rm -rf "$config/package" "$steam" || true
+test ! -d "$ubuntu32" && rm -rf "$ubuntu32" && mkdir -p "$ubuntu32" || true
+test ! -x "$steam" && rm -rf "$steam" && cp "$real" "$steam" && "$steam" || true
+test ! -e "$runtime.tar.xz" && cat "$runtime.tar.xz.part"* > "$runtime.tar.xz" || true
+test ! -d "$runtime" && cd "$ubuntu32" && tar xf steam-runtime.tar.xz && \
     md5sum steam-runtime.tar.xz > steam-runtime/checksum || \
     rm -f steam-runtime.tar.xz*
 
 # remove steam-runtime libraries that are incompatible with newer mesa drivers
 # (https://bugs.freedesktop.org/78242)
-find $runtime \( -name libxcb.so\* \
-              -o -name libgcc_s.so\* \
-              -o -name libstdc++.so\* \
-              -o -name libgpg-error.so\* \
-              \) -delete
+find "$runtime" \( -name libxcb.so\* \
+                -o -name libgcc_s.so\* \
+                -o -name libstdc++.so\* \
+                -o -name libgpg-error.so\* \
+                \) -delete
 
 # Steam bundles a version of SDL that uses the libdbus API wrong, causing
 # assertion failures which are now fatal by default
@@ -47,5 +47,5 @@ find $runtime \( -name libxcb.so\* \
 export DBUS_FATAL_WARNINGS=0
 
 # launch the Valve run script
-test -x $config/steam.sh && $config/steam.sh -nominidumps -nobreakpad "$@" \
-    2>$config/error.log
+test -x "$config/steam.sh" && "$config/steam.sh" -nominidumps -nobreakpad "$@" \
+    2>"$config/error.log"
-- 
2.20.0

>From c9babaf3a2f92f5f909f90d660160098a994fa95 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Tue, 13 Nov 2018 13:42:35 +0000
Subject: [PATCH 4/7] d/scripts/steam: Install to the same directory upstream
 use

According to Valve, the Steam client is meant to support multiple
parallel installations, with $XDG_DATA_HOME/Steam as the path that is
normally used. On Linux, ~/.steam/steam is meant to be a symbolic link
to the most recently run installation root for production versions of
the Steam client (there can also be a parallel ~/.steam/steambeta
for internal beta-test versions), which allows the Steam client and
the Steamworks API to find the Steam installation root even if the
XDG_DATA_HOME environment variable has changed since installation.
Users can also switch between installations by running
/path/to/installation/steam.sh, which will update the symbolic links.

The steam package in Debian has traditionally unpacked the Steam
bootstrapper directly into ~/.steam, which gives that directory a
dual role: the installation root, and also the symlink farm.
Unfortunately, a bootstrapped installation root will contain a ./steam
directory, which collides with the ~/.steam/steam symbolic link,
preventing its creation. Components of the Steam client end up
unpredictably installed into either ~/.steam or ~/.steam/steam.

We can't easily disentangle this for existing installations, but for
new installations we can reduce confusion by behaving the way
upstream intended.

Signed-off-by: Simon McVittie <s...@collabora.com>
---
 debian/scripts/steam | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/debian/scripts/steam b/debian/scripts/steam
index 9467f40..70d9951 100644
--- a/debian/scripts/steam
+++ b/debian/scripts/steam
@@ -2,8 +2,36 @@
 # Copyright (C) 2013-2017 Michael Gilbert <mgilb...@debian.org>
 # License: MIT
 
+# According to Valve, ~/.steam is intended to contain symbolic links
+# pointing to the currently-running or most-recently-run Steam
+# installation, so that users can swap between multiple installations
+# of the Steam client by running /path/to/steam.sh.
 config="$HOME/.steam"
-ubuntu32="$config/ubuntu12_32"
+
+: "${XDG_DATA_HOME:="$HOME/.local/share"}"
+
+# Detect the active or most recently used Steam installation
+if [ -L "$config/steam" ]; then
+    # Usually ~/.steam/steam -> ~/.local/share/Steam
+    root="$(readlink -e -q "$config/steam")"
+elif [ -L "$config/root" ]; then
+    # Usually ~/.steam/root -> ~/.local/share/Steam, but perhaps
+    # ~/.steam/root -> ~/.steam in existing installations (see below)
+    root="$(readlink -e -q "$config/root")"
+elif [ -d "$config/steam" ] && ! [ -L "$config/steam" ]; then
+    # Historical Debian behaviour: use ~/.steam as the installation
+    # directory in addition to using it as the symlink farm (upstream
+    # do not like this because it breaks their mechanism for managing
+    # multiple parallel installations, due to the Steam installation
+    # containing a ./steam directory that collides with the ./steam
+    # symbolic link)
+    root="$config"
+else
+    # No installation found: use upstream's default installation path
+    root="$XDG_DATA_HOME/Steam"
+fi
+
+ubuntu32="$root/ubuntu12_32"
 steam="$ubuntu32/steam"
 runtime="$ubuntu32/steam-runtime"
 
@@ -24,7 +52,8 @@ fi
 
 # do an initial update when expected pieces are missing
 test ! -d "$config" && rm -rf "$config" && mkdir -p "$config" || true
-test ! -x "$config/steam.sh" && rm -rf "$config/package" "$steam" || true
+test ! -d "$root" && rm -rf "$root" && mkdir -p "$root" || true
+test ! -x "$root/steam.sh" && rm -rf "$root/package" "$steam" || true
 test ! -d "$ubuntu32" && rm -rf "$ubuntu32" && mkdir -p "$ubuntu32" || true
 test ! -x "$steam" && rm -rf "$steam" && cp "$real" "$steam" && "$steam" || true
 test ! -e "$runtime.tar.xz" && cat "$runtime.tar.xz.part"* > "$runtime.tar.xz" || true
@@ -47,5 +76,5 @@ find "$runtime" \( -name libxcb.so\* \
 export DBUS_FATAL_WARNINGS=0
 
 # launch the Valve run script
-test -x "$config/steam.sh" && "$config/steam.sh" -nominidumps -nobreakpad "$@" \
-    2>"$config/error.log"
+test -x "$root/steam.sh" && "$root/steam.sh" -nominidumps -nobreakpad "$@" \
+    2>"$root/error.log"
-- 
2.20.0

Reply via email to