Implement GetGlyphIndices. Tweak GetCharacterPlacement to use it.
[wine/testsucceed.git] / tools / wineinstall
blobd7f73c058ea40d698553d3deca729ae41709c87d
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
21 # History:
22 # Mar 31 1999 - Ove Kåven
23 # First version
24 # Dec 9 1999 - Ove Kåven
25 # require Xpm
26 # Feb 25 2000 - Ove Kåven
27 # auto-add /usr/local/lib to /etc/ld.so.conf
28 # Mar 2 2000 - Ove Kåven
29 # source rather than grep config.cache
30 # use sourced config.cache to start ldconfig
31 # reconfigure if config.cache doesn't exist
32 # Mar 30 2000 - Ove Kåven
33 # autoconfigure no-windows installs
34 # do not install registry on real-windows installs
35 # some support for binary package installs
36 # set and tell user about LD_LIBRARY_PATH if necessary
37 # set EXTRA_LD_LIBRARY_PATH in wine.conf
38 # Apr 9 2000 - Ove Kåven
39 # make root's registry global (system-default)
40 # May 9 2000 - Ove Kåven
41 # use ttydrv when running regapi, so we don't have to run from X
42 # change debugger path in registry
43 # Oct 29 2000 - Ove Kåven
44 # added --enable-opengl to default confargs
45 # added conf_question, conf_yesno_answer, and conf_string_answer functions
46 # added DEFCAT variable
47 # (later that day...)
48 # added conf_reset_question function
49 # added file existence checks to the registry copying
50 # fixed problem with no-windows directory creation
51 # some text reformatting from Eric Maryniak
52 # Jan 5 2000 - Chris Morgan
53 # use default config file in /documentation/samples/config
54 # replace .winerc with ~/.wine/config in printed text
55 # added user question to convert .winerc file(if exists) or use the default
56 # config file
57 # add conf_question to allow root to install a local config file and
58 # registry
59 # Jan 12 2000 - Chris Morgan
60 # distinguish between creating local and global config files
61 # display a message about the status of global config files
62 # misc cleanups and reordering of questions
63 # added check to see if wine is installed when we are running as a normal
64 # user and print a message if wine cannot be found
65 # Feb 16 2002 - Adam D. Moss
66 # Use config.status instead of config.cache to check whether we're
67 # configured/compiled and to recreate the configuration
68 # Feb 20 2002 - Adam D. Moss
69 # Partially revert previous changes, force configure to write an
70 # old-style config.cache
71 # Mar 27 2002 - Chris Morgan
72 # prevent the user from running wineinstall as root
73 # add script commands so we su root for 'make install' and other commands
74 # that require root access
75 # add text to tell the user we need to run stuff as root so they don't
76 # think we are trying to pull something funny
78 #--- defaults (change these if you are a packager)
79 CONFARGS="--enable-opengl" # configure args, e.g. --prefix=/usr --sysconfdir=/etc
80 prefix=/usr/local # installation prefix
81 sysconfdir=$prefix/etc # where wine.conf and global registry is supposed to be
82 bindir=$prefix/bin # where winelib apps will be (or is) installed
83 libdir=$prefix/lib # where libwine.so will be (or is) installed
84 exdir=documentation/samples # where the example system.ini resides
85 GCONF=$sysconfdir/wine.conf # default path of the wine.conf global config file
86 LCONF=~/.wine/config # default path of the local config file
87 BINDIST=no # whether called from a binary package config script
88 DOGLOBALCONF=auto # whether to autogenerate wine.conf
89 DOLOCALCONF=auto # whether to autogenerate localconf
90 DOWCHK=auto # whether to autoconfigure existing-windows installation
91 DOWINE=auto # whether to autoconfigure no-windows installation
92 DOREG=auto # whether to install default registry
93 SYSREG=yes # whether to make root's registry global (system-default)
94 CONVCONF=no # whether we are converting an existing .winerc or not
96 # "make install" still installs the dlls into $libdir, but this may change in the future
97 # (DLLPATH should point to them if/when they are not in standard ld.so paths)
98 DLLPATH=$libdir/wine # default path of the dll .so files (except libwine.so)
100 # having the Wine debugger launched automatically will be a plus for us
101 DEBUGGER=$bindir/winedbg # the (installed) path of winedbg
102 HDEBUGGER=debugger/winedbg # the (non-installed) path of winedbg
104 # this is only for existing-windows installs
105 WINECONF=tools/wineconf # the path of wineconf perl script
107 # this is only for no-windows installs
108 WINEINI=$exdir/config # the path of default wine config file (also used by wineconf)
109 WININI=/dev/null # the path of default win.ini
110 SYSTEMINI=$exdir/system.ini # the path of default system.ini
111 REGAPI=programs/regapi/regapi # the path of regapi winelib application
112 DEFREG=winedefault.reg # the path of the registry file to be fed to regapi
113 # CROOT=/var/wine # the path of the fake Drive C (asks user if not set)
114 DEFCAT=cat # program to cat $DEFREG with (some packages need zcat)
115 #--- end of defaults
117 # temporary files used by the installer
118 TMPCONF=/tmp/wineinstall.conf
119 TMPREG=/tmp/wineinstall.reg
121 # functions
123 function std_sleep {
124 sleep 1
127 function conf_question {
128 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
129 # the first two parameters can be used by e.g. debconf in debian packages
130 # but here we just print the message
131 shift 2
132 echo
133 local LINE="$1"
134 while shift
135 do {
136 echo "$LINE"
137 LINE="$1"
139 done
142 function conf_reset_question {
143 # parameters: $1 = question-id
144 # this is used to flush any cached answers and "already-displayed" flags
145 shift # dummy command
148 function conf_yesno_answer {
149 unset ANSWER
150 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
151 do {
152 echo -n "$1"
153 read ANSWER
155 done
158 function conf_string_answer {
159 echo -n "$1"
160 read ANSWER
163 function create_windows_directories {
164 for tdir in "$CROOT/windows" "$CROOT/windows/system" \
165 "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
166 "$CROOT/Common Files" "$CROOT/Program Files" \
167 "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator"
168 do [ -d "$tdir" ] || mkdir "$tdir"
169 done
170 [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
171 [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
174 # startup...
176 echo "WINE Installer v0.72"
177 echo
179 if [ "$BINDIST" = 'no' ]
180 then {
182 if ! [ -f configure ]
183 then {
184 echo "You're running this from the wrong directory."
185 echo "Change to the Wine source's main directory and try again."
186 exit 1
190 if [ `whoami` == 'root' ]
191 then {
192 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
193 echo "Aborting."
194 exit 1
198 # check whether RPM installed, and if it is, remove any old wine rpm.
199 hash rpm &>/dev/null
200 RET=$?
201 if [ $RET -eq 0 ]; then
202 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
203 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
204 conf_yesno_answer "(yes/no) "
205 if [ "$ANSWER" = 'yes' ]; then
206 echo "We need to remove the rpm as root, please enter your root password"
207 echo
208 echo Starting wine rpm removal...
209 su -c "rpm -e wine; RET=$?"
210 if [ $RET -eq 0 ]; then
211 echo Done.
212 else
213 echo "FAILED. Probably you aren't installing as root."
214 echo "Expect problems (library conflicts with existing install etc.)."
216 else
217 echo "Sorry, I won't install Wine when an rpm version is still installed."
218 echo "(Wine support suffered from way too many conflicts between RPM"
219 echo "and source installs)"
220 echo "Have a nice day !"
221 exit 1
226 # check whether wine binary still available
227 if [ -n "`which wine`" ]; then
228 echo "Warning !! wine binary (still) found, which may indicate"
229 echo "a (conflicting) previous installation."
230 echo "You might want to abort and uninstall Wine first."
231 std_sleep
234 # run the configure script, if necessary
236 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
237 then {
238 echo
239 echo "I see that WINE has already been configured, so I'll skip that."
240 std_sleep
241 # load configure results
242 . ./config.cache
244 else {
245 echo "Running configure..."
246 echo
247 if ! ./configure -C $CONFARGS
248 then {
249 echo
250 echo "Configure failed, aborting install."
251 rm -f config.cache
252 exit 1
255 # load configure results
256 . ./config.cache
257 # make sure X was found
258 eval "$ac_cv_have_x"
259 if [ "$have_x" != "yes" ]
260 then {
261 echo "Install the X development headers and try again."
262 rm -f config.cache
263 exit 1
269 # now do the compilation and install, we need to always do this because we
270 # don't want the 'make install' command we might run to run 'make' as root
271 if [ `whoami` != 'root' ]
272 then {
273 # ask the user if they want to build and install wine
274 echo
275 echo "We need to install wine as root user, do you want us to build wine,"
276 echo "'su root' and install Wine? Enter 'no' to continue without installing"
277 conf_yesno_answer "(yes/no) "
279 if [ "$ANSWER" = "yes" ]
280 then {
281 # start out with the basic command
282 sucommand="make install"
284 # if the user doesn't have $libdir in their ld.so.conf add this
285 # to our sucommand string
286 if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
287 then {
288 echo
289 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
290 echo "when we perform the install..."
291 sucommand="echo $libdir>>/etc/ld.so.conf;ldconfig;$sucommand"
295 echo
297 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
298 echo "in the meantime..."
299 echo
300 std_sleep
302 # try to just make wine, if this fails 'make depend' and try to remake
303 if ! { make; }
304 then {
305 if ! { make depend && make; }
306 then {
307 echo
308 echo "Compilation failed, aborting install."
309 exit 1
314 echo
316 echo "Performing 'make install' as root to install binaries, enter root password"
318 std_sleep
320 if ! su root -c"$sucommand"
321 then {
322 echo
323 echo "Either you entered an incorrect password or we failed to run"
324 echo "'$sucommand' correctly."
325 echo "If you didn't enter an incorrect password then please report this"
326 echo "error to wine-devel@winehq.com."
327 echo
328 echo "Installation failed, aborting."
329 exit 1
333 echo
335 # see if wine is installed on the users system, if not prompt them
336 # and then exit
337 if [ ! `which wine` ]
338 then
339 echo "Could not find wine on your system. Run wineinstall as root to install wine"
340 echo "before re-running wineinstall as a user."
341 echo
342 echo "Exiting wineinstall"
343 exit 1;
346 else {
347 # user didn't want to install wine so tell them about running from the
348 # current directory and set some stuff up for them
350 # setup to run from current directory
351 DLLPATH="$PWD/dlls"
352 if [ -z "$LD_LIBRARY_PATH" ]
353 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
354 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
356 export LD_LIBRARY_PATH
357 DEBUGGER="$PWD/$HDEBUGGER"
358 echo
359 echo "NOTE! To run Wine without installing, you must set the environment variable"
360 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
361 echo "in your logon scripts."
362 echo
366 else {
367 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
368 echo "Aborting."
369 exit 1
371 fi # [ `whoami` != 'root' ]
374 fi # BINDIST
376 # now check whether we should generate wine.conf
377 if [ -z "$DOGLOBALCONF" ]
378 then
379 DOGLOBALCONF=auto
382 if [ "$DOGLOBALCONF" = 'auto' ]
383 then {
384 # see if we already have a system wine.conf
385 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
386 then
387 DOGLOBALCONF=no
388 echo "Creation of a global config file is not supported in wineinstall at this"
389 echo "time. When the configuration architecture is cleaned up this functionality"
390 echo "will be restored to wineinstall."
391 echo
396 if [ "$DOLOCALCONF" = 'auto' ]
397 then {
398 # see if the user is root, if so, explicitly ask them if they want a
399 # local config file
400 if [ `whoami` = 'root' ]
401 then
402 echo "You are running as root. Do you want a local config file,"
403 echo "file, ~/.wine/config, created?"
404 conf_yesno_answer "(yes/no) "
405 DOLOCALCONF="$ANSWER"
406 else
407 # if the user has an existing config file ask them if they want us to
408 # overwrite it, otherwise just ask them if they want to create one
409 if [ -f "$LCONF" ]
410 then
411 echo "Found existing $LCONF, do you want to overwrite this"
412 echo "existing Wine configuration file?"
413 conf_yesno_answer "(yes/no) "
414 DOLOCALCONF="$ANSWER"
415 echo
416 else {
417 echo "Create local config file ~/.wine/config?"
418 conf_yesno_answer "(yes/no) "
419 DOLOCALCONF="$ANSWER"
420 echo
421 if [ "$ANSWER" = 'no' ]
422 then
423 conf_question high need_root \
424 "Aborting install. Try again as root to generate a system wine.conf."
425 exit 1
433 # generate $TMPCONF from existing windows install, if any
434 if [ "$DOLOCALCONF" = 'yes' ]
435 then {
436 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
437 then {
438 echo -n "Searching for an existing Windows installation..."
439 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
440 then {
441 rm -f $TMPCONF $TMPREG > /dev/null
443 echo " not found. (no matching /etc/fstab mount entry found)"
444 conf_question low do_without_windows \
445 "Windows was not found on your system, so I assume you want" \
446 "a Wine-only installation. Am I correct?"
447 conf_yesno_answer "(yes/no) "
448 if [ "$ANSWER" = 'no' ]
449 then {
450 conf_question high windows_not_found \
451 "Aborting install. Make sure your Windows partition is mounted and try again," \
452 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
453 exit 1
456 DOWINE=yes
458 else {
459 echo " found."
461 conf_reset_question windows_found
462 conf_question low windows_found \
463 "Created $LCONF using your existing Windows installation." \
464 "You probably want to review the file, though."
465 DOWINE=no
469 elif [ "$DOWINE" = 'auto' ]
470 then DOWINE=yes
473 elif [ "$DOWINE" = 'auto' ]
474 then
475 DOWINE=no
478 # setup a no-windows installation, if necessary
479 if [ "$DOWINE" = 'yes' ]
480 then {
481 # set an appropriate DCROOT
482 if [ `whoami` != 'root' ]
483 then DCROOT=~/c
484 else DCROOT=/c
487 if [ -f ~/.winerc ]
488 then {
489 conf_question medium convert_config \
490 "I found the old version Wine config file, .winerc, in your " \
491 "home directory. I can convert this to the new format or use the" \
492 "new default Wine config file. Convert?"
493 conf_yesno_answer "(yes/no) "
494 if [ "$ANSWER" = 'yes' ]
495 then {
496 WINEINI=~/.winerc
497 CONVCONF=yes
501 else {
503 conf_question low drivec_path \
504 "Configuring Wine without Windows." \
505 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
506 "start menu entries, and other things your applications may need to install." \
507 "Where would you like your fake C drive to be placed?"
508 while [ -z "$CROOT" ]
509 do {
510 conf_string_answer "(default is $DCROOT) "
511 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
512 if ! [ -d "$ANSWER" ]
513 then {
514 if mkdir -p "$ANSWER"
515 then CROOT="$ANSWER"
516 else
517 echo "Directory $ANSWER can't be created !"
518 conf_reset_question drivec_path
521 else CROOT="$ANSWER"
524 done
525 echo "Configuring Wine for a no-windows install in $CROOT..."
527 create_windows_directories
531 # create $LCONF using the default config file $WINEINI
532 if [ "$DOLOCALCONF" = 'yes' ] && [ "$CONVCONF" = 'no' ]
533 then {
534 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
535 conf_reset_question default_config
536 conf_question low default_config \
537 "Created $LCONF using default Wine configuration." \
538 "You probably want to review the file, though."
542 # now we really should install the registry
543 if [ "$DOREG" = 'auto' ]
544 then DOREG=yes
548 echo
550 #install the local config file $LCONF
551 if [ "$DOLOCALCONF" = 'yes' ]
552 then
553 if [ ! -w ~/.wine ]
554 then
555 mkdir ~/.wine
558 if [ "$CONVCONF" = 'no' ]
559 then
560 cp $TMPCONF $LCONF > /dev/null
562 else
563 DOREG=no
566 #install the global config file $GCONF
567 if [ "$DOGLOBALCONF" = 'yes' ]
568 then
569 if [ ! -f $sysconfdir ]
570 then
571 mkdir -p $sysconfdir
574 cp $TMPCONF $GCONF > /dev/null
577 # check whether we need to install default registry
578 # (not to be done if windows registry exists)
579 if [ "$DOREG" = 'auto' ]
580 then {
581 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
582 echo "Checking for real Windows registry..."
583 if [ -f "$CROOT/windows/system.dat" ]
584 then DOREG=no
585 elif [ -f "$CROOT/windows/system32/config/system" ]
586 then DOREG=no
587 else DOREG=yes
589 if [ "$DOREG" = 'yes' ]
590 then echo "Not found, default Wine registry will be installed."
591 else echo "Windows registry found, will not install default Wine registry."
593 echo
597 # install default registry entries
598 if [ "$DOREG" = 'yes' ]
599 then {
600 if [ "$BINDIST" = 'no' ]
601 then {
602 echo "Compiling regapi..."
603 (cd programs/regapi; make)
604 echo
607 echo "Preparing to install default Wine registry entries..."
609 # edit config files so we don't have to run regapi under X
610 if [ "$CONVCONF" = 'yes' ]
611 then
612 mv $WINEINI $WINEINI.new
613 sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $WINEINI.new > $WINEINI
614 else
615 mv $LCONF $LCONF.new
616 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"ttydrv\"/" $LCONF.new > $LCONF
619 # create a temporary wineinstall.reg with fixed debugger path
620 $DEFCAT $DEFREG | sed "s|debugger/winedbg|${DEBUGGER}|" > $TMPREG
622 echo "Installing default Wine registry entries..."
623 echo
624 if ! $REGAPI setValue < $TMPREG > /dev/null
625 then {
626 rm -f $TMPREG
627 echo "Registry install failed."
628 conf_reset_question regapi_error
629 conf_question high regapi_error
630 exit 1
632 else {
633 # if we are converting from a .winerc file, running regapi once
634 # will ONLY convert .winerc -> ~/.wine/config, it will not import the
635 # registry data. so if we are converting we need to run regapi twice
636 if [ "$CONVCONF" = 'yes' ]
637 then
638 if ! $REGAPI setValue < $TMPREG > /dev/null
639 then
640 rm -f $TMPREG
641 echo "Registry install failed."
642 conf_reset_question regapi_error
643 conf_question high regapi_error
644 exit 1
645 else
646 echo
647 echo "Registry entries successfully installed."
649 else
650 echo
651 echo "Registry entries successfully installed."
655 rm -f $TMPREG
656 if [ "$SYSREG" = 'auto' ]
657 then SYSREG=yes
660 # if we converted we need to change the graphics driver back and
661 # restore the original .winerc file
662 if [ "$CONVCONF" = 'yes' ]
663 then
664 mv $WINEINI.new $WINEINI
667 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"x11drv\"/" $LCONF > $LCONF.new
668 mv $LCONF.new $LCONF
672 # make root's registry global, if desired
673 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
674 then {
675 [ -d ~/.wine ] || mkdir ~/.wine
676 if ! [ -f $sysconfdir/wine.userreg ]
677 then {
678 echo "Linking root's user registry hive to the global registry..."
679 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
680 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
683 if ! [ -f $sysconfdir/wine.systemreg ]
684 then {
685 echo "Linking root's system registry hive to the global registry..."
686 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
687 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
693 # cleanup any temporary files that may remain
694 if [ -f $TMPCONF ]
695 then rm -f $TMPCONF
697 if [ -f $TMPREG ]
698 then rm -f $TMPREG
702 # it's a wrap
703 echo
704 echo "Installation complete for now. Good luck (this is still alpha software)."
705 echo "If you have problems with WINE, please read the documentation first,"
706 echo "as many kinds of potential problems are explained there."
708 exit 0