File: first_use

package info (click to toggle)
playonlinux 4.1.1-1
  • links: PTS, VCS
  • area: contrib
  • in suites: wheezy
  • size: 11,208 kB
  • sloc: python: 6,173; sh: 5,358; ansic: 72; makefile: 8
file content (334 lines) | stat: -rwxr-xr-x 12,396 bytes parent folder | download
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/bin/bash

# Copyright (C) 2007-2010 PlayOnLinux Team
# Copyright (C) 2007-2011 Pâris Quentin

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 

# This is the first use script
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources" 

export XQUARTZ_VERSION="2.7.1"

fonts_install () # Debian tweak to avoid downloading Microsoft Fonts
{
	if [ ! -e "$REPERTOIRE/configurations/msfonts_installed" ] && [ ! -e "$REPERTOIRE/configurations/msfonts_deb_installed" ]
	then
		FONTS_WARNING="Microsoft fonts aren't installed.\n\n\
 If you encounter any fonts trouble, you should think about installing\
 the debian package\nttf-mscorefonts-installer (see README.Debian)."
		POL_SetupWindow_message "$FONTS_WARNING" "Microsoft fonts"
		POL_SetupWindow_Close
 	fi
}

install_fonts () # Install Microsoft Fonts
{
	if [ ! -e "$REPERTOIRE/configurations/msfonts_installed" ]
	then
		
	#	POL_SetupWindow_Init "$PLAYONLINUX/etc/setups/fonts/top.png" "$PLAYONLINUX/etc/setups/fonts/left.jpg"
		POL_SetupWindow_message "$(eval_gettext "Microsoft fonts aren't installed; I'll install them for you.")$(eval_gettext "\nPlease make sure you are connected to the Internet.")" "$(eval_gettext 'Microsoft fonts')" 
		echo -e "---$(eval_gettext " Licence translated into your language ")---
$(eval_gettext "These fonts were provided by Microsoft\n\"in the interest of cross-platform compatibility\".")
$(eval_gettext "This is no longer the case, but they are still available from third parties.")

$(eval_gettext "You are free to download these fonts and use them for your own use,\nbut you may not redistribute them in modified form,\nincluding changes to the file name or packaging format.")\n" > "$REPERTOIRE/tmp/licence"
		echo "---$(eval_gettext " Original licence ")---
These fonts were provided by Microsoft \"in the interest of
cross-platform compatibility\".
This is no longer the case, but they are still available from
third parties.

You are free to download these fonts and use them for your own use,
but you may not redistribute them in modified form, including changes
to the file name or packaging format." >> "$REPERTOIRE/tmp/licence"
		cat "$REPERTOIRE/tmp/licence"

		POL_SetupWindow_licence "$(eval_gettext 'Please read and accept the following:')" "$(eval_gettext 'Microsoft fonts')" "$REPERTOIRE/tmp/licence"
		WebVersion=$($POL_WGET $SITE/check.txt -O-)
		if [ "$WebVersion" == "" ]
		then
			POL_SetupWindow_message "$(eval_gettext 'The PlayOnLinux website is unavailable.')$(eval_gettext "\nPlease make sure you are connected to the Internet.")" "$(eval_gettext 'Microsoft fonts')"
			POL_SetupWindow_Close
		else
			rm -r "$REPERTOIRE/fonts/" 2> /dev/null
			rm "$REPERTOIRE/fonts" 2> /dev/null
			rm "$REPERTOIRE/configurations/fonts_installed" 2> /dev/null
			FONTDIR="$REPERTOIRE/fonts/"
			mkdir -p "$FONTDIR"
			FONTS_INSTALLER="andale32.exe arialb32.exe arial32.exe comic32.exe courie32.exe georgi32.exe impact32.exe times32.exe trebuc32.exe verdan32.exe webdin32.exe"
			cd "$FONTDIR"
			PULSE=1
			POL_SetupWindow_pulsebar "$(eval_gettext 'Downloading fonts')" "$(eval_gettext 'Microsoft fonts')"

			for font in $FONTS_INSTALLER
			do
			 sleep 0.1
			 POL_SetupWindow_set_text "$(eval_gettext 'Downloading: ')$font..."
			 echo "$(eval_gettext 'Downloading: ')$font..."
			 $POL_WGET "http://heanet.dl.sourceforge.net/sourceforge/corefonts/$font"
			 PULSE=$(( PULSE + 8 ))
			 POL_SetupWindow_pulse $PULSE
			done

			echo "$(eval_gettext 'Downloading: ')tahoma32.exe"
			POL_SetupWindow_set_text "$(eval_gettext 'Downloading: ')tahoma32.exe"
			$POL_WGET http://download.microsoft.com/download/office97pro/fonts/1/w95/en-us/tahoma32.exe
			POL_SetupWindow_pulse 100
			sleep 1
			PULSE=1
			POL_SetupWindow_pulsebar "$(eval_gettext 'Installing fonts')" "$(eval_gettext 'Microsoft fonts')"

			for font in $FONTS_INSTALLER
			do
			 sleep 0.1
			 POL_SetupWindow_set_text "$(eval_gettext 'Installing: ')$font..."
			 echo "$(eval_gettext 'Installing: ')$font..."
			 cabextract "$font" > /dev/null
			 PULSE=$(( PULSE + 8 ))
			 POL_SetupWindow_pulse $PULSE
			 sleep 0.1
			done

			POL_SetupWindow_set_text "$(eval_gettext 'Installing: ')tahoma32.exe"
			echo "$(eval_gettext 'Installing: ')tahoma32.exe"
			cabextract tahoma32.exe > /dev/null
			POL_SetupWindow_pulse 100
			sleep 1
			rm *.exe
			rm *.done
			rm *.dll
			rm *.inf
			rm *.txt
			touch "$REPERTOIRE/configurations/msfonts_installed"
			POL_SetupWindow_message "$(eval_gettext 'Microsoft fonts have been installed successfully.')" "$(eval_gettext 'Microsoft fonts')"
		#	POL_SetupWindow_Close

		fi
	fi
}


POL_Internal_XQuartz_Warning()
{
		cat << EOF_X > "$REPERTOIRE/tmp/xquartz"
$(eval_gettext "Please read this carefully")

$(eval_gettext 'XQuartz $XQUARTZ_VERSION has been installed on your computer.')
$(eval_gettext "However, it won't be activated until you reboot your computer.")

$(eval_gettext 'Please reboot your computer now, and run PlayOnMac')

EOF_X
		POL_SetupWindow_licence "$(eval_gettext "Pleaase read this carefully.")" "$STEP_TITLE" "$REPERTOIRE/tmp/xquartz"
		POL_SetupWindow_Close
		killall playonmac.real
		touch /tmp/playonmac_needs_reboot
}

install_x11()
{
	if [ "$OSX_VERSION" = "9" ]
	then
		XQuartzUrl="http://xquartz.macosforge.org/downloads/Leopard/X11-$XQUARTZ_VERSION.dmg"
		FilePrefix="X11"
	else
		XQuartzUrl="http://xquartz.macosforge.org/downloads/SL/XQuartz-$XQUARTZ_VERSION.dmg"
		FilePrefix="XQuartz"
	fi
	STEP_TITLE="XQuartz"
	if [ "$OSX_VERSION" = "10" ]
	then
		XQuartz_Message="$(eval_gettext "To ensure that your games will be compatible, PlayOnMac must install XQuartz")"
	else
		XQuartz_Message="$(eval_gettext "PlayOnMac needs to install XQuartz to work")"
	fi
	POL_SetupWindow_menu_num "$XQuartz_Message" "$STEP_TITLE" "$(eval_gettext "Please download XQuartz for me")~$(eval_gettext "I've downloaded the file by myself") ($FilePrefix-$XQUARTZ_VERSION.dmg)~$(eval_gettext "Don't install XQuartz for the moment")" "~"
	if [ "$APP_ANSWER" = "0" ]
	then
		POL_SetupWindow_download "$(eval_gettext "Downloading XQuartz")" "$STEP_TITLE" "$XQuartzUrl"
		got_xquartz="true"
	fi
	if [ "$APP_ANSWER" = "1" ]
	then
		POL_SetupWindow_browse "$(eval_gettext "Where is") $FilePrefix-$XQUARTZ_VERSION.dmg ?" "$STEP_TITLE"
		cd "$(dirname "$APP_ANSWER")"
		got_xquartz="true"
	fi
	
	if [ "$got_xquartz" = "true" ]
	then
		POL_SetupWindow_wait_next_signal "$(eval_gettext "Installing XQuartz...")" "$STEP_TITLE"
		open $FilePrefix-$XQUARTZ_VERSION.dmg
		while [ ! -d "/Volumes/$FilePrefix-$XQUARTZ_VERSION" ]
		do
			sleep 1
		done
		/System/Library/CoreServices/Installer.app/Contents/MacOS/Installer /Volumes/$FilePrefix-$XQUARTZ_VERSION/$FilePrefix.pkg
		umount /Volumes/$FilePrefix-$XQUARTZ_VERSION
		POL_Internal_RunXQuartz
		POL_Internal_XQuartz_Warning
		POL_SetupWindow_message "$(eval_gettext "XQuartz has been installed.")" "$STEP_TITLE"
	fi
	

	if [ ! -e "/Applications/Utilities/XQuartz.app" ] && [ ! "$OSX_VERSION" = "11" ]
	then
		POL_SetupWindow_message "$(eval_gettext "Unable to install XQuartz! You must install it to improve games compatibility.")" "$STEP_TITLE"
	fi
	#POL_Internal_XQuartz_Warning

}

install_prefix()
{
	if [ ! -e "$POL_USER_ROOT/wineprefix/default" ]
	then
		STEP_TITLE="$(eval_gettext "Default virtual drive configuration")"
		POL_SetupWindow_wait_next_signal "$(eval_gettext '$APPLICATION_TITLE is making a virtual windows hard drive')" "$STEP_TITLE" 
		POL_Wine_SelectPrefix "default"
		POL_Wine_PrefixCreate
	fi
}
POL_Shortcut_GetOLDPrefix()
{
	[ "$1" = "" ] && POL_Debug_Error "No shortcut specified"
	fichier="$REPERTOIRE/configurations/installed/$1"
	#fichier=${fichier//"\""/""}
	#fichier=${fichier//"//"/"/"}
	if [ -e "$fichier" ]
	then
		fichier="$(cat "$fichier" | grep WINEPREFIX | tail -n 1 | sed s/'\/\//\/'/)"
		fichier="${fichier/"$POL_USER_ROOT"/""}"
		fichier="$(printf "$fichier" | cut -d "/" -f2)"
	fi
	printf "$fichier" | tr -d \"
}
POL_Shortcut_GetOLDVersion()
{
	[ "$1" = "" ] && POL_Debug_Error "No shortcut specified"
	fichier="$REPERTOIRE/configurations/installed/$1"
	#fichier=${fichier//"\""/""}
	#fichier=${fichier//"//"/"/"}
	if [ -e "$fichier" ]
	then
		fichier="$(cat "$fichier" | grep PATH | tail -n 1 | sed s/'\/\//\/'/)"
		fichier="${fichier/"$POL_USER_ROOT"/""}"
		fichier="$(printf "$fichier" | cut -d "/" -f2)"
	fi
	printf "$fichier" | tr -d \"
}
migrate_oldpol()
{
	rmdir "$POL_USER_ROOT/configurations/installed" 2> /dev/null
	if [ -e "$POL_USER_ROOT/configurations/installed" ]
	then
		# On commence par les raccourcis
		POL_Debug_Message "Upgrading shortcuts"
		
		cd "$POL_USER_ROOT/configurations/installed"
		for shortcut in *
		do
			POL_Debug_Message "Updating shortcut : $shortcut"
			sVERSION="$(POL_Shortcut_GetOLDVersion "$shortcut")"
			sPREFIX="$(POL_Shortcut_GetOLDPrefix "$shortcut")"
			sTITLE="$shortcut"
			sWINE="$(cat "$shortcut" | grep '^wine')"
			sWINE="${sWINE/wine/POL_Wine}"
			sWINEPREFIX="$(cat "$shortcut" | grep '^export WINEPREFIX')"
			sCD="$(cat "$shortcut" | grep '^cd')"
		
			cat <<EOF > "$POL_USER_ROOT/shortcuts/$shortcut"
#!/bin/bash
[ "\$PLAYONLINUX" = "" ] && exit 0
source "\$PLAYONLINUX/lib/sources"
$sWINEPREFIX
export WINEDEBUG="-all"
$sCD
$sWINE
EOF
			chmod +x  "$POL_USER_ROOT/shortcuts/$shortcut"
			if [ ! "$sVERSION" = "" ]
			then
				POL_Debug_Message "Setting shortcut $sTITLE, prefix $sPREFIX to version $sVERSION"
				export WINEPREFIX="$POL_USER_ROOT/wineprefix/$sPREFIX"
				POL_Wine_SetVersionPrefix "$sVERSION"
			fi
		done
		
		
		POL_Debug_Message "Upgrading virtual drives"
		cd "$POL_USER_ROOT/wineprefix"
		for prefix in *
		do
			POL_Debug_Message "Updating $prefix"
			export WINEPREFIX="$POL_USER_ROOT/wineprefix/$prefix"
			[ "$(POL_Config_PrefixRead ARCH)" = "" ] && POL_Config_PrefixWrite "ARCH" "x86"
		done
	
		if [ -e "$POL_USER_ROOT/WineVersions" ]
		then
		
		POL_Debug_Message "Upgrading wine versions"
		cd "$POL_USER_ROOT/WineVersions"
		[ "$POL_OS" = "Mac" ] && vprefix="darwin-"
		[ "$POL_OS" = "Linux" ] && vprefix="linux-"
		new_vroot="$POL_USER_ROOT/wine/${vprefix}x86"
		mkdir -p "$new_vroot"
		for version in *
		do
			POL_Debug_Message "Updating $version"
			mv "$POL_USER_ROOT/WineVersions/$version" "$new_vroot/"
		done
		rmdir "$POL_USER_ROOT/WineVersions"
		
		if [ "$POL_OS" = "Linux" ]
		then
			cd "$new_vroot"
			for version in *
			do
				POL_Debug_Message "Removing /usr in path $version"
				cd "$new_vroot/$version"
				mv usr/* ./
				rmdir usr
			done
		fi
	fi
	mv "$POL_USER_ROOT/configurations/installed" "$POL_USER_ROOT/configurations/installed.backup" 
	fi
	export POL_WINEVERSION=""
}
migrate_oldpol
POL_SetupWindow_Init --protect
if [ "$(POL_Config_Read FIRST_FIRST_USE)" = "TRUE" ]
then
	POL_SetupWindow_free_presentation "$(eval_gettext '$APPLICATION_TITLE first use')" "$(eval_gettext '$APPLICATION_TITLE is going to finish its preparation')\n$(eval_gettext "Please ensure you are connected to the internet.")"
else
	POL_Config_Write FIRST_FIRST_USE TRUE
	POL_SetupWindow_free_presentation "$(eval_gettext '$APPLICATION_TITLE first use')" "$(eval_gettext 'It appears it is the first time you are using 	$APPLICATION_TITLE.')\n$(eval_gettext 'This wizard will help you prepare $APPLICATION_TITLE environement')\n$(eval_gettext "Please ensure you are connected to the internet.")"
fi

[ "$POL_OS" == "Mac" ] && [ ! -e "/Applications/Utilities/XQuartz.app" ] && [ ! "$OSX_VERSION" = "11" ] &&  install_x11

[ "$POL_OS" == "Mac" ] && [ "$OSX_VERSION" = "9" ] &&  install_x11

fonts_install
install_prefix
POL_SetupWindow_message "$(eval_gettext 'Thank you for using $APPLICATION_TITLE')" "$(eval_gettext '$APPLICATION_TITLE first use')"
POL_SetupWindow_Close
POL_Config_Write FIRST_USE TRUE
POL_Config_Write GECKO_INSTALLED TRUE