Authors: Mike McCormack <mike@codeweavers.com>, Aric Stewart <aric@codeweavers.com...
[wine/multimedia.git] / tools / wineinstall
blob97753f0c6e667919a4117fcca5c00d7bf24fe2cd
1 #!/bin/bash
2 # WINE Installation script
3 # Can do almost everything from compiling to configuring...
5 # Copyright 1999 Ove Kåven
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #--- defaults (change these if you are a packager)
23 CONFARGS="" # configure args, e.g. --prefix=/usr --sysconfdir=/etc
24 prefix=/usr/local # installation prefix
25 sysconfdir=$prefix/etc # where wine.conf and the global registry are supposed to be
26 bindir=$prefix/bin # where winelib apps will be (or are) installed
27 libdir=$prefix/lib # where libwine.so will be (or is) installed
28 exdir=documentation/samples # where the sample system.ini resides
29 LCONF=~/.wine/config # default path of the local config file
30 BINDIST=no # whether called from a binary package config script
31 DOLOCALCONF=auto # whether to autogenerate localconf
32 DOWCHK=auto # whether to autoconfigure existing-windows installation
33 DOWINE=auto # whether to autoconfigure no-windows installation
34 DOREG=auto # whether to install default registry
35 DOAPP=auto # whether to install applications, distributed with Wine
36 SYSREG=yes # whether to make root's registry global (system-default)
38 # this is only for existing-windows installs
39 WINECONF=tools/wineconf # path to the wineconf perl script
41 # this is only for no-windows installs
42 WINEINI=$exdir/config # path to the default wine config file (also used by wineconf)
43 # CROOT=/var/wine # path of the fake Drive C (asks user if not set)
44 #--- end of defaults
46 # temporary files used by the installer
47 TMPCONF=/tmp/wineinstall.conf
49 # functions
51 function std_sleep {
52 sleep 1
55 function conf_question {
56 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
57 # the first two parameters can be used by e.g. debconf in debian packages
58 # but here we just print the message
59 shift 2
60 echo
61 local LINE="$1"
62 while shift
63 do {
64 echo "$LINE"
65 LINE="$1"
67 done
70 function conf_reset_question {
71 # parameters: $1 = question-id
72 # this is used to flush any cached answers and "already-displayed" flags
73 shift # dummy command
76 function conf_yesno_answer {
77 unset ANSWER
78 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
79 do {
80 echo -n "$1"
81 read ANSWER
83 done
86 function conf_string_answer {
87 echo -n "$1"
88 read ANSWER
91 # startup...
93 echo "WINE Installer v0.74"
94 echo
96 if [ "$BINDIST" = 'no' ]
97 then {
99 if ! [ -f configure ]
100 then {
101 if [ -f ../configure ]
102 then {
103 pushd ..
105 else {
106 echo "You're running this from the wrong directory."
107 echo "Change to the Wine source's main directory and try again."
108 exit 1
114 if [ `whoami` = 'root' ]
115 then {
116 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
117 echo "Aborting."
118 exit 1
122 if [ ! -w . ]
123 then {
124 echo "The source directory is not writable. You probably extracted the sources as root."
125 echo "You should remove the source tree and extract it again as a normal user."
126 exit 1
130 # check whether RPM installed, and if it is, remove any old wine rpm.
131 hash rpm &>/dev/null
132 RET=$?
133 if [ $RET -eq 0 ]; then
134 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
135 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
136 conf_yesno_answer "(yes/no) "
137 if [ "$ANSWER" = 'yes' ]; then
138 echo "We need to remove the rpm as root, please enter your root password"
139 echo
140 echo Starting wine rpm removal...
141 su -c "rpm -e wine; RET=$?"
142 if [ $RET -eq 0 ]; then
143 echo Done.
144 else
145 echo "FAILED. Probably you aren't installing as root."
146 echo "Expect problems (library conflicts with existing install etc.)."
148 else
149 echo "Sorry, I won't install Wine when an rpm version is still installed."
150 echo "(Wine support suffered from way too many conflicts between RPM"
151 echo "and source installs)"
152 echo "Have a nice day !"
153 exit 1
158 # check whether wine binary still available
159 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
160 echo "Warning !! wine binary (still) found, which may indicate"
161 echo "a (conflicting) previous installation."
162 echo "You might want to abort and uninstall Wine first."
163 std_sleep
166 # run the configure script, if necessary
168 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
169 then {
170 echo
171 echo "I see that WINE has already been configured, so I'll skip that."
172 std_sleep
173 # load configure results
174 . ./config.cache
176 else {
177 echo "Running configure..."
178 echo
179 if ! ./configure -C $CONFARGS --prefix=$prefix
180 then {
181 echo
182 echo "Configure failed, aborting install."
183 rm -f config.cache
184 exit 1
187 # load configure results
188 . ./config.cache
189 # make sure X was found
190 eval "$ac_cv_have_x"
191 if [ "$have_x" != "yes" ]
192 then {
193 echo "Install the X development headers and try again."
194 rm -f config.cache
195 exit 1
201 # now do the compilation and install, we need to always do this because we
202 # don't want the 'make install' command we might run to run 'make' as root
203 if [ `whoami` != 'root' ]
204 then {
205 # ask the user if they want to build and install wine
206 echo
207 echo "We need to install wine as root user, do you want us to build wine,"
208 echo "'su root' and install Wine? Enter 'no' to continue without installing"
209 conf_yesno_answer "(yes/no) "
210 ROOTINSTALL="$ANSWER"
212 if [ "$ROOTINSTALL" = "yes" ]
213 then {
214 # start out with the basic command
215 sucommand="make install"
217 # if the user doesn't have $libdir in their ld.so.conf add this
218 # to our sucommand string
219 if [ -f /etc/ld.so.conf ]
220 then
221 if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
222 then {
223 echo
224 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
225 echo "when we perform the install..."
226 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
229 # run ldconfig always just in case some updated files don't get linked
230 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
233 fi # [ "$ROOTINSTALL" = "yes" ]
235 echo
237 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
238 echo "in the meantime..."
239 echo
240 std_sleep
242 # try to just make wine, if this fails 'make depend' and try to remake
243 if ! { make; }
244 then {
245 if ! { make depend && make; }
246 then {
247 echo
248 echo "Compilation failed, aborting install."
249 exit 1
255 if [ "$ROOTINSTALL" = "yes" ]
256 then {
257 echo
259 echo "Performing 'make install' as root to install binaries, enter root password"
261 std_sleep
263 if ! su root -c "$sucommand"
264 then {
265 if ! su root -c "$sucommand"
266 then {
267 echo
268 echo "Either you entered an incorrect password or we failed to"
269 echo "run '$sucommand' correctly."
270 echo "If you didn't enter an incorrect password then please"
271 echo "report this error and any steps to possibly reproduce it to"
272 echo "http://bugs.winehq.org/"
273 echo
274 echo "Installation failed, aborting."
275 exit 1
281 echo
283 # see if wine is installed on the users system, if not prompt them
284 # and then exit
285 if [ ! `which wine` ]
286 then
287 echo "Could not find wine on your system. Run wineinstall as root to install wine"
288 echo "before re-running wineinstall as a user."
289 echo
290 echo "Exiting wineinstall"
291 exit 1;
294 WINEINSTALLED=yes
296 else {
297 WINEINSTALLED=no
299 fi # [ "$ROOTINSTALL" = "yes" ]
301 fi # [ `whoami` != 'root' ]
304 fi # BINDIST
306 # now check whether we should generate wine.conf
307 if [ "$DOLOCALCONF" = 'auto' ]
308 then {
309 # see if the user is root, if so, explicitly ask them if they want a
310 # local config file
311 if [ `whoami` = 'root' ]
312 then
313 echo "You are running as root. Do you want a local config file,"
314 echo "file, ~/.wine/config, created?"
315 conf_yesno_answer "(yes/no) "
316 DOLOCALCONF="$ANSWER"
317 else
318 # if the user has an existing config file ask them if they want us to
319 # overwrite it, otherwise just ask them if they want to create one
320 if [ -f "$LCONF" ]
321 then
322 echo "Found existing $LCONF, do you want to overwrite this"
323 echo "existing Wine configuration file?"
324 conf_yesno_answer "(yes/no) "
325 DOLOCALCONF="$ANSWER"
326 echo
327 if [ "$ANSWER" = "yes" ]
328 then
330 echo "Would you like to make a backup of this old config file?"
331 conf_yesno_answer "(yes/no) "
332 echo
333 if [ "$ANSWER" = "yes" ]
334 then
336 echo "Renaming $LCONF to $LCONF.old"
337 mv -f "$LCONF" "$LCONF.old"
338 echo
343 else
345 echo "Create local config file ~/.wine/config?"
346 conf_yesno_answer "(yes/no) "
347 DOLOCALCONF="$ANSWER"
348 echo
349 if [ "$ANSWER" = 'no' ]
350 then
351 conf_question high need_root \
352 "Aborting install. Try again as root to generate a system wine.conf."
353 exit 1
361 # generate $TMPCONF from existing windows install, if any
362 if [ "$DOLOCALCONF" = 'yes' ]
363 then {
364 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
365 then {
366 echo -n "Searching for an existing Windows installation..."
367 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
368 then {
369 rm -f $TMPCONF > /dev/null
371 echo " not found. (no matching /etc/fstab mount entry found)"
372 conf_question low do_without_windows \
373 "Windows was not found on your system, so I assume you want" \
374 "a Wine-only installation. Am I correct?"
375 conf_yesno_answer "(yes/no) "
376 if [ "$ANSWER" = 'no' ]
377 then {
378 conf_question high windows_not_found \
379 "Aborting install. Make sure your Windows partition is mounted and try again," \
380 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
381 exit 1
384 DOWINE=yes
386 else {
387 echo " found."
389 conf_question low do_without_windows \
390 "Windows was found on your system, and so we can use the Windows" \
391 "Drive as our Wine drive. You may, however, wish to create a clean" \
392 "Wine install anyways."
393 conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
394 if [ "$ANSWER" = 'yes' ]
395 then {
396 conf_reset_question windows_found
397 conf_question low windows_found \
398 "Created $LCONF using your existing Windows installation." \
399 "You probably want to review the file, though."
400 DOWINE=no
402 else {
403 DOWINE=yes
409 elif [ "$DOWINE" = 'auto' ]
410 then DOWINE=yes
413 elif [ "$DOWINE" = 'auto' ]
414 then
415 DOWINE=no
418 # setup a no-windows installation, if necessary
419 if [ "$DOWINE" = 'yes' ]
420 then {
421 # set an appropriate DCROOT
422 if [ `whoami` != 'root' ]
423 then DCROOT=~/.wine/drive_c
424 else DCROOT=/c
427 conf_question low drivec_path \
428 "Configuring Wine without Windows." \
429 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
430 "start menu entries, and other things your applications may need to install." \
431 "Where would you like your fake C drive to be placed?"
432 while [ -z "$CROOT" ]
433 do {
434 conf_string_answer "(default is $DCROOT) "
435 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
436 if ! [ -d "$ANSWER" ]
437 then {
438 if mkdir -p "$ANSWER"
439 then CROOT="$ANSWER"
440 else
441 echo "Directory $ANSWER can't be created !"
442 conf_reset_question drivec_path
445 else CROOT="$ANSWER"
448 done
449 echo "Configuring Wine for a no-windows install in $CROOT..."
451 if [ ! -d ~/.wine/dosdevices ]
452 then
453 [ -d ~/.wine ] || mkdir ~/.wine
454 mkdir ~/.wine/dosdevices
455 ln -s /mnt/fd0 ~/.wine/dosdevices/a:
456 ln -s $CROOT ~/.wine/dosdevices/c:
457 ln -s /cdrom ~/.wine/dosdevices/d:
458 ln -s /tmp ~/.wine/dosdevices/e:
459 ln -s ~ ~/.wine/dosdevices/f:
460 ln -s / ~/.wine/dosdevices/z:
463 if [ "$WINEINSTALLED" = 'no' ]
464 then
465 tools/wineprefixcreate --update --use-wine-tree .
466 else
467 wineprefixcreate --update
470 # create $LCONF using the default config file $WINEINI
471 if [ "$DOLOCALCONF" = 'yes' ]
472 then {
473 cp $WINEINI $TMPCONF
474 conf_reset_question default_config
475 conf_question low default_config \
476 "Created $LCONF using default Wine configuration." \
477 "You probably want to review the file, though."
481 # now we really should install the registry
482 if [ "$DOREG" = 'auto' ]
483 then DOREG=yes
487 echo
489 #install the local config file $LCONF
490 if [ "$DOLOCALCONF" = 'yes' ]
491 then
492 if [ ! -w ~/.wine ]
493 then
494 mkdir ~/.wine
496 cp $TMPCONF $LCONF > /dev/null
497 else
498 DOREG=no
501 # make root's registry global, if desired
502 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
503 then {
504 [ -d ~/.wine ] || mkdir ~/.wine
505 if ! [ -f $sysconfdir/wine.userreg ]
506 then {
507 echo "Linking root's user registry hive to the global registry..."
508 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
509 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
512 if ! [ -f $sysconfdir/wine.systemreg ]
513 then {
514 echo "Linking root's system registry hive to the global registry..."
515 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
516 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
522 # cleanup any temporary files that may remain
523 if [ -f $TMPCONF ]
524 then rm -f $TMPCONF
528 # it's a wrap
529 echo
530 echo "Installation complete for now. Good luck (this is still alpha software)."
531 echo "If you have problems with WINE, please read the documentation first,"
532 echo "as many kinds of potential problems are explained there."
534 exit 0