Control: block 916303 by -1
Control: tags -1 + patch pending

On Wed, 16 Jan 2019 at 10:46:37 +0000, Simon McVittie wrote:
> I think we can solve this by using a variation of the patch I attached
> to #916303.

See attached. I'll upload this in the next version of steam if there are
no objections.

This is basically my earlier patch from #916303, except that the default
is swapped: it will continue to use ~/.steam as the $STEAMDIR for new
installations, and only use ~/.local/share/Steam (or any other $STEAMDIR)
if that was already set up. This reduces the solution to #916303 to
"swap the default".

    smcv
>From 08ebbab3cea08b6ddaf1741a77e218789f07a395 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Tue, 13 Nov 2018 13:42:35 +0000
Subject: [PATCH] d/scripts/steam: Cope with different installation directories

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
as the equivalent of C:\Program Files\Steam (referred to as $STEAMDIR
in Valve's scripts). On Linux, ~/.steam/steam ($STEAMCONFIG/steam)
is 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.

The steam package in Debian has traditionally unpacked the Steam
bootstrapper directly into ~/.steam, which gives that directory a
dual role: the installation root $STEAMDIR, and also the symlink farm
$STEAMCONFIG. Whether to change the default in new installations to
match Valve's is under discussion in #916303.

However, even if we don't want to switch the default, not respecting the
~/.steam/steam and ~/.steam/root symbolic links causes data loss if the
Debian steam package is used as a replacement for Valve's steam-launcher
package: our launcher script would detect that ~/.steam/steam.sh doesn't
exist, and consider that to be a corrupted installation.

Signed-off-by: Simon McVittie <s...@collabora.com>
Closes: #919467
---
 debian/scripts/steam | 47 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)

diff --git a/debian/scripts/steam b/debian/scripts/steam
index 9467f40..f2ae580 100644
--- a/debian/scripts/steam
+++ b/debian/scripts/steam
@@ -2,8 +2,42 @@
 # Copyright (C) 2013-2017 Michael Gilbert <mgilb...@debian.org>
 # License: MIT
 
-config="$HOME/.steam"
-ubuntu32="$config/ubuntu12_32"
+# According to Valve, ~/.steam is intended to be a control directory containing
+# 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.
+#
+# The shell variable name STEAMCONFIG matches what's used in Valve's
+# /usr/bin/steam (available at $STEAMDIR/bin_steam.sh in a Steam
+# installation).
+STEAMCONFIG="$HOME/.steam"
+
+: "${XDG_DATA_HOME:="$HOME/.local/share"}"
+
+# STEAMDIR points to the actual installation root: the equivalent of
+# C:\Program Files\Steam in the Windows Steam client. In Valve's setup
+# this is distinct from ~/.steam, usually ~/.local/share/Steam.
+#
+# The historical Debian behaviour has been to use ~/.steam as the installation
+# directory in addition to using it as the control directory, in an attempt
+# to reduce clutter in the home directory.
+#
+# The shell variable name STEAMDIR matches what's used in Valve's
+# /usr/bin/steam.
+if [ -L "$STEAMCONFIG/steam" ]; then
+    STEAMDIR="$(readlink -e -q "$STEAMCONFIG/steam")"
+elif [ -L "$STEAMCONFIG/root" ]; then
+    STEAMDIR="$(readlink -e -q "$STEAMCONFIG/root")"
+elif [ -d "$STEAMCONFIG/steam" ] && ! [ -L "$STEAMCONFIG/steam" ]; then
+    STEAMDIR="$HOME/.steam"
+else
+    # This is a new installation. We could either use $HOME/.steam or
+    # $XDG_DATA_HOME/Steam; see #916303 for discussion. For now behave
+    # as we historically did.
+    STEAMDIR="$HOME/.steam"
+fi
+
+ubuntu32="$STEAMDIR/ubuntu12_32"
 steam="$ubuntu32/steam"
 runtime="$ubuntu32/steam-runtime"
 
@@ -23,8 +57,9 @@ 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 "$STEAMCONFIG" && rm -rf "$STEAMCONFIG" && mkdir -p "$STEAMCONFIG" || true
+test ! -d "$STEAMDIR" && rm -rf "$STEAMDIR" && mkdir -p "$STEAMDIR" || true
+test ! -x "$STEAMDIR/steam.sh" && rm -rf "$STEAMDIR/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 +82,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 "$STEAMDIR/steam.sh" && "$STEAMDIR/steam.sh" -nominidumps -nobreakpad "$@" \
+    2>"$STEAMDIR/error.log"
-- 
2.20.1

Reply via email to