summaryrefslogtreecommitdiff
blob: b3c0cf267e7193ba5179023b42215fe100a46c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
--- usr/bin/steam_orig
+++ usr/bin/steam
@@ -1,10 +1,11 @@
-#!/bin/bash
+#!/bin/sh
 #
 # This is the Steam script that typically resides in /usr/bin
 # It will create the Steam bootstrap if necessary and then launch steam.
 
 # Get the full name of this script
-export STEAMSCRIPT="$(cd "${0%/*}" && echo "$PWD")/${0##*/}"
+STEAMSCRIPT="$(cd "${0%/*}" && echo "$PWD")/${0##*/}"
+export STEAMSCRIPT
 
 # This version number is incremented when there is a critical fix that
 # end users need to pick up immediately.
@@ -15,44 +16,61 @@
 # steamrepo@list.valvesoftware.com
 # You can subscribe to this list at:
 # 	https://list.valvesoftware.com/mailman/listinfo/steamrepo
-export STEAMSCRIPT_VERSION=0
+STEAMSCRIPT_VERSION=0
+export STEAMSCRIPT_VERSION
 
 # Set up domain for script localization
-export TEXTDOMAIN=steam
+TEXTDOMAIN=steam
+export TEXTDOMAIN
 
-function show_message()
+if command -v gettext.sh >/dev/null; then
+	GETTEXT_FOUND=1
+	. gettext.sh
+fi
+
+_gettextecho()
+{
+	if [ $GETTEXT_FOUND = 1 ] ; then
+		echo "$(eval_gettext "$1")"
+	else
+		echo "$1"
+	fi
+}
+
+
+show_message()
 {
 	style=$1
 	shift
 	if ! zenity "$style" --text="$*" 2>/dev/null; then
 		case "$style" in
 		--error)
-			title=$"Error"
+			title="$(_gettextecho "Error")"
 			;;
 		--warning)
-			title=$"Warning"
+			title="$(_gettextecho "Warning")"
 			;;
 		*)
-			title=$"Note"
+			title="$(_gettextecho "Note")"
 			;;
 		esac
 
 		# Save the prompt in a temporary file because it can have newlines in it
 		tmpfile="$(mktemp || echo "/tmp/steam_message.txt")"
-		echo -e "$*" >"$tmpfile"
-		xterm -T "$title" -e "cat $tmpfile; echo -n 'Press enter to continue: '; read input"
+		printf "%b$*" >"$tmpfile"
+		xterm -T "$title" -e "cat $tmpfile; printf 'Press enter to continue: '; read input"
 		rm -f "$tmpfile"
 	fi
 }
 
-function detect_platform()
+detect_platform()
 {
 	# Maybe be smarter someday
 	# Right now this is the only platform we have a bootstrap for, so hard-code it.
 	echo ubuntu12_32
 }
 
-function setup_variables()
+setup_variables()
 {
 	STEAMPACKAGE="${0##*/}"
 	STEAMCONFIG=~/.steam
@@ -60,7 +78,8 @@
 	STEAMBOOTSTRAP=steam.sh
 	LAUNCHSTEAMDIR="$(readlink -e -q "$STEAMDATALINK")"
 	LAUNCHSTEAMPLATFORM="$(detect_platform)"
-	LAUNCHSTEAMBOOTSTRAPFILE="/usr/lib/$STEAMPACKAGE/bootstraplinux_$LAUNCHSTEAMPLATFORM.tar.xz"
+	[ -z $LAUNCHSTEAMBOOTSTRAPFILE ] && LAUNCHSTEAMBOOTSTRAPFILE="/usr/lib/$STEAMPACKAGE/bootstraplinux_$LAUNCHSTEAMPLATFORM.tar.xz"
+	[ -z $DESKTOPFILE ] && DESKTOPFILE="/usr/share/applications/$STEAMPACKAGE.desktop"
 
 	# Get the default data path
 	STEAM_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
@@ -74,18 +93,18 @@
 			DEFAULTSTEAMDIR="$STEAM_DATA_HOME/SteamBeta"
 			;;
 		*)
-			echo $"Unknown Steam package '$STEAMPACKAGE'"
+			_gettextecho "Unknown Steam package '$STEAMPACKAGE'"
 			exit 1
 			;;
 	esac
 
 	# Create the config directory if needed
-	if [[ ! -d "$STEAMCONFIG" ]]; then
+	if [ ! -d "$STEAMCONFIG" ]; then
 		mkdir "$STEAMCONFIG"
 	fi
 }
 
-function install_bootstrap()
+install_bootstrap()
 {
 	STEAMDIR="$1"
 
@@ -93,11 +112,12 @@
 	omask="$(umask)"
 	umask 0077
 
-	echo $"Setting up Steam content in $STEAMDIR"
+	_gettextecho "Setting up Steam content in $STEAMDIR"
+
 	mkdir -p "$STEAMDIR"
 	cd "$STEAMDIR"
 	if ! tar xJf "$LAUNCHSTEAMBOOTSTRAPFILE" ; then
-		echo $"Failed to extract $LAUNCHSTEAMBOOTSTRAPFILE, aborting installation."
+		_gettextecho "Failed to extract $LAUNCHSTEAMBOOTSTRAPFILE, aborting installation."
 		exit 1
 	fi
 	rm -f "$STEAMDATALINK" && ln -s "$STEAMDIR" "$STEAMDATALINK"
@@ -106,25 +126,27 @@
 	# put the Steam icon on the user's desktop
 	# try to read ~/.config/user-dirs.dirs to get the current desktop configuration
 	# http://www.freedesktop.org/wiki/Software/xdg-user-dirs
-	test -f "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs" && source "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs"
+	if test -f "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs" ; then
+		. "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs"
+	fi
 	DESKTOP_DIR="${XDG_DESKTOP_DIR:-$HOME/Desktop}"
 
-	cp "/usr/share/applications/$STEAMPACKAGE.desktop" "$DESKTOP_DIR"
+	cp "${DESKTOPFILE}" "$DESKTOP_DIR"
 	chmod +x "$DESKTOP_DIR/$STEAMPACKAGE.desktop"
 
 	# Restore the umask
 	umask "$omask"
 }
 
-function repair_bootstrap()
+repair_bootstrap()
 {
 	rm -f "$STEAMDATALINK" && ln -s "$1" "$STEAMDATALINK"
 	setup_variables
 }
 
-function check_bootstrap()
+check_bootstrap()
 {
-	if [[ -n "$1" && -x "$1/$STEAMBOOTSTRAP" ]]; then
+	if [ -n "$1" ] && [ -x "$1/$STEAMBOOTSTRAP" ]; then
 		# Looks good...
 		return 0
 	else
@@ -138,23 +160,23 @@
 if ! check_bootstrap "$LAUNCHSTEAMDIR"; then
 	# See if we just need to recreate the data link
 	if check_bootstrap "$DEFAULTSTEAMDIR"; then
-		echo $"Repairing installation, linking $STEAMDATALINK to $DEFAULTSTEAMDIR"
+		_gettextecho "Repairing installation, linking $STEAMDATALINK to $DEFAULTSTEAMDIR"
 		repair_bootstrap "$DEFAULTSTEAMDIR"
 	elif check_bootstrap "$CLASSICSTEAMDIR"; then
-		echo $"Repairing installation, linking $STEAMDATALINK to $CLASSICSTEAMDIR"
+		_gettextecho "Repairing installation, linking $STEAMDATALINK to $CLASSICSTEAMDIR"
 		repair_bootstrap "$CLASSICSTEAMDIR"
 	fi
 fi
 
-if [[ ! -L "$STEAMDATALINK" ]]; then
+if [ ! -L "$STEAMDATALINK" ]; then
 	# We don't have the data link and we couldn't find an existing bootstrap, so just install the bootstrap
 	install_bootstrap "$DEFAULTSTEAMDIR"
 elif ! check_bootstrap "$LAUNCHSTEAMDIR"; then
 	# We have the data link but we can't find the data, prompt the user
-	if zenity --question --text=$"Couldn't find Steam content, did you move it?" --ok-label=$"Search" --cancel-label=$"Reinstall"; then
+	if zenity --question --text="$(_gettextecho "Could not find Steam content, did you move it?")" --ok-label="$(_gettextecho "Search")" --cancel-label="$(_gettextecho "Reinstall")"; then
 		while true; do
 			STEAMDIR="`zenity --file-selection --directory`"
-			if [[ -z "$STEAMDIR" ]]; then
+			if [ -z "$STEAMDIR" ]; then
 				# User canceled
 				exit 0
 			fi
@@ -162,7 +184,7 @@
 				repair_bootstrap "$STEAMDIR"
 				break;
 			else
-				show_message --error $"Please pick a valid Steam content directory"
+				show_message --error "$(_gettextecho "Please pick a valid Steam content directory")"
 			fi
 		done
 	else
@@ -171,7 +193,7 @@
 fi
 
 if ! check_bootstrap "$LAUNCHSTEAMDIR"; then
-	show_message --error $"Couldn't set up Steam data - please contact technical support"
+	show_message --error "$(_gettextecho "Could not set up Steam data - please contact technical support")"
 	exit 1
 fi