Remove obsolete --enable-opengl.
[wine] / tools / wineinstall
1 #!/bin/bash
2 # WINE Installation script
3 # Can do almost everything from compiling to configuring...
4 #
5 # Copyright 1999 Ove Kåven
6 #
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.
11 #
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.
16 #
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
20 #
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
77 # Apr 14 2002 - Dustin Navea
78 #  Fix sed command when finding real-windows registry so it actually
79 #   accesses a file (~/.wine/config) instead of null ($CONF?!)
80 #  Added search for clean-install (not upgrade) Win2k registry
81 #  (next day, after some sleep)
82 #  Fix sed string when finding real-windows registry to actually find
83 #   windows partition name in [Drive C] section
84 #  it should now almost always find the windows partition and real-windows
85 #  registry (if not, let me know)
86 # Aug 29 2002 - Rok Mandeljc <rok.mandeljc@gimb.org>
87 #  -added two symlinks; windows/winhelp.exe and windows/winhlp32.exe because it seems
88 #   that some apps look for winhlp32.exe/winhelp to display help
89 #
90
91 #--- defaults (change these if you are a packager)
92 CONFARGS=""                   # configure args, e.g. --prefix=/usr --sysconfdir=/etc
93 prefix=/usr/local             # installation prefix
94 sysconfdir=$prefix/etc        # where wine.conf and the global registry are supposed to be
95 bindir=$prefix/bin            # where winelib apps will be (or are) installed
96 libdir=$prefix/lib            # where libwine.so will be (or is) installed
97 exdir=documentation/samples   # where the sample system.ini resides
98 GCONF=$sysconfdir/wine.conf   # default path of the wine.conf global config file
99 LCONF=~/.wine/config          # default path of the local config file
100 BINDIST=no                    # whether called from a binary package config script
101 DOGLOBALCONF=auto             # whether to autogenerate wine.conf
102 DOLOCALCONF=auto              # whether to autogenerate localconf
103 DOWCHK=auto                   # whether to autoconfigure existing-windows installation
104 DOWINE=auto                   # whether to autoconfigure no-windows installation
105 DOREG=auto                    # whether to install default registry
106 DOAPP=auto                    # whether to install applications, distributed with Wine
107 SYSREG=yes                    # whether to make root's registry global (system-default)
108 CONVCONF=no                   # whether we are converting an existing .winerc or not
109
110 # "make install" still installs the dlls into $libdir, but this may change in the future
111 # (DLLPATH should point to them if/when they are not in standard ld.so paths)
112 DLLPATH=$libdir/wine          # default path of the dll .so files (except libwine.so)
113
114 # this is only for existing-windows installs
115 WINECONF=tools/wineconf       # path to the wineconf perl script
116
117 # this is only for no-windows installs
118 WINEINI=$exdir/config         # path to the default wine config file (also used by wineconf)
119 WININI=/dev/null              # path to the default win.ini
120 SYSTEMINI=$exdir/system.ini   # path to the default system.ini
121 REGEDIT=programs/regedit/regedit       # path to the regedit winelib application
122 DEFREG=winedefault.reg        # path of the registry file to be fed to regedit
123 # CROOT=/var/wine             # path of the fake Drive C (asks user if not set)
124 DEFCAT=cat                    # program to cat $DEFREG with (some packages need zcat)
125 #--- end of defaults
126
127 # temporary files used by the installer
128 TMPCONF=/tmp/wineinstall.conf
129
130 # functions
131
132 function std_sleep {
133   sleep 1
134 }
135
136 function conf_question {
137   # parameters: $1 = importance, $2 = question-id, $3+ = message lines
138   # the first two parameters can be used by e.g. debconf in debian packages
139   # but here we just print the message
140   shift 2
141   echo
142   local LINE="$1"
143   while shift
144   do {
145     echo "$LINE"
146     LINE="$1"
147   }
148   done
149 }
150
151 function conf_reset_question {
152   # parameters: $1 = question-id
153   # this is used to flush any cached answers and "already-displayed" flags
154   shift # dummy command
155 }
156
157 function conf_yesno_answer {
158   unset ANSWER
159   while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
160   do {
161     echo -n "$1"
162     read ANSWER
163   }
164   done
165 }
166
167 function conf_string_answer {
168   echo -n "$1"
169   read ANSWER
170 }
171
172 function create_windows_directories {
173   for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/system32" \
174               "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
175               "$CROOT/Program Files" "$CROOT/Program Files/Common Files" \
176               "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator" \
177               "$CROOT/windows/Fonts" "$CROOT/windows/Start Menu/Programs/Startup"
178   do [ -d "$tdir" ] || mkdir "$tdir"
179   done
180   [ -f "$CROOT/windows/win.ini" ]    || cp "$WININI"    "$CROOT/windows/win.ini"
181   [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
182 }
183
184 #creates symbolic link in windows directory to installed winelib application
185 #parameters:
186 # - name of the installed winelib application
187 # - full path to application in the winelib directory
188 function link_app {
189   if [ "$WINEINSTALLED" = 'no' ]
190   then {
191     ln -sf $PWD/programs/$1/$1.exe.so $2
192   }
193   else {
194     ln -sf $libdir/wine/$1.exe.so $2
195   }
196   fi
197 }
198
199 #puts windows applications replacements to windows directories,
200 #configures them
201 function configure_wine_applications {
202   link_app notepad      "$CROOT/windows/notepad.exe"
203   link_app regedit      "$CROOT/windows/regedit.exe"
204   link_app rundll32     "$CROOT/windows/rundll32.exe"
205   link_app wcmd         "$CROOT/windows/system32/cmd.exe"
206   link_app control      "$CROOT/windows/system32/control.exe"
207   link_app winhelp      "$CROOT/windows/system32/help.exe"
208   link_app notepad      "$CROOT/windows/system32/notepad.exe"
209   link_app progman      "$CROOT/windows/system32/progman.exe"
210   link_app regsvr32     "$CROOT/windows/system32/regsvr32.exe"
211   link_app winemine     "$CROOT/windows/system32/winmine.exe"
212   link_app winver       "$CROOT/windows/system32/winver.exe"
213   link_app uninstaller  "$CROOT/windows/uninstall.exe"
214   link_app winhelp      "$CROOT/windows/winhelp.exe"
215   link_app winhelp      "$CROOT/windows/winhlp32.exe"
216 }
217
218 # startup...
219
220 echo "WINE Installer v0.74"
221 echo
222
223 if [ "$BINDIST" = 'no' ]
224 then {
225
226   if ! [ -f configure ]
227   then {
228     if [ -f ../configure ]
229     then {
230       pushd ..
231     }
232     else {
233       echo "You're running this from the wrong directory."
234       echo "Change to the Wine source's main directory and try again."
235       exit 1
236     }
237     fi
238   }
239   fi
240
241   if [ `whoami` == 'root' ]
242   then {
243     echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
244     echo "Aborting."
245     exit 1
246   }
247   fi
248
249   # check whether RPM installed, and if it is, remove any old wine rpm.
250   hash rpm &>/dev/null
251   RET=$?
252   if [ $RET -eq 0 ]; then
253     if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
254       echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
255       conf_yesno_answer "(yes/no) "
256       if [ "$ANSWER" = 'yes' ]; then
257         echo "We need to remove the rpm as root, please enter your root password"
258         echo
259         echo Starting wine rpm removal...
260         su -c "rpm -e wine; RET=$?"
261         if [ $RET -eq 0 ]; then
262           echo Done.
263         else
264           echo "FAILED. Probably you aren't installing as root."
265           echo "Expect problems (library conflicts with existing install etc.)."
266         fi
267       else
268         echo "Sorry, I won't install Wine when an rpm version is still installed."
269         echo "(Wine support suffered from way too many conflicts between RPM"
270         echo "and source installs)"
271         echo "Have a nice day !"
272         exit 1
273       fi
274     fi
275   fi
276
277   # check whether wine binary still available
278   if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
279     echo "Warning !! wine binary (still) found, which may indicate"
280     echo "a (conflicting) previous installation."
281     echo "You might want to abort and uninstall Wine first."
282     std_sleep
283   fi
284
285   # run the configure script, if necessary
286
287   if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
288   then {
289     echo
290     echo "I see that WINE has already been configured, so I'll skip that."
291     std_sleep
292     # load configure results
293     . ./config.cache
294   }
295   else {
296     echo "Running configure..."
297     echo
298     if ! ./configure -C $CONFARGS
299     then {
300       echo
301       echo "Configure failed, aborting install."
302       rm -f config.cache
303       exit 1
304     }
305     fi
306     # load configure results
307     . ./config.cache
308     # make sure X was found
309     eval "$ac_cv_have_x"
310     if [ "$have_x" != "yes" ]
311     then {
312       echo "Install the X development headers and try again."
313       rm -f config.cache
314       exit 1
315     }
316     fi
317   }
318   fi
319
320   # now do the compilation and install, we need to always do this because we
321   # don't want the 'make install' command we might run to run 'make' as root
322   if [ `whoami` != 'root' ]
323   then {
324     # ask the user if they want to build and install wine
325     echo
326     echo "We need to install wine as root user, do you want us to build wine,"
327     echo "'su root' and install Wine?  Enter 'no' to continue without installing"
328     conf_yesno_answer "(yes/no) "
329     ROOTINSTALL="$ANSWER"
330
331     if [ "$ROOTINSTALL" = "yes" ]
332     then {
333       # start out with the basic command
334       sucommand="make install"
335
336       # if the user doesn't have $libdir in their ld.so.conf add this
337       # to our sucommand string
338       if [ -f /etc/ld.so.conf ]
339       then
340         if ! grep -qs "$libdir" /etc/ld.so.conf
341         then {
342           echo
343           echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
344           echo "when we perform the install..."
345           sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
346         }
347         fi
348         # run ldconfig always just in case some updated files dont get linked
349         sucommand="$sucommand;$ac_cv_path_LDCONFIG"
350       fi
351     }
352     fi # [ "$ROOTINSTALL" = "yes" ]
353
354     echo
355
356     echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
357     echo "in the meantime..."
358     echo
359     std_sleep
360
361     # try to just make wine, if this fails 'make depend' and try to remake
362     if ! { make; }
363     then {
364       if ! { make depend && make; }
365       then {
366         echo
367         echo "Compilation failed, aborting install."
368         exit 1
369       }
370       fi
371     }
372     fi
373
374     if [ "$ROOTINSTALL" = "yes" ]
375     then {
376       echo
377
378       echo "Performing 'make install' as root to install binaries, enter root password"
379
380       std_sleep
381
382       if ! su root -c "$sucommand"
383       then {
384         echo
385         echo "Either you entered an incorrect password or we failed to run"
386         echo "'$sucommand' correctly."
387         echo "If you didn't enter an incorrect password then please report this"
388         echo "error and any steps to possibly reproduce it to"
389         echo "http://bugs.winehq.com/"
390         echo
391         echo "Installation failed, aborting."
392         exit 1
393       }
394       fi
395
396       echo
397
398       # see if wine is installed on the users system, if not prompt them
399       # and then exit
400       if [ ! `which wine` ]
401       then
402         echo "Could not find wine on your system.  Run wineinstall as root to install wine"
403         echo "before re-running wineinstall as a user."
404         echo
405         echo "Exiting wineinstall"
406         exit 1;
407       fi
408
409       WINEINSTALLED=yes
410     }
411     else {
412       # user didn't want to install wine so tell them about running from the
413       # current directory and set some stuff up for them
414
415       # setup to run from current directory
416       DLLPATH="$PWD/dlls"
417       if [ -z "$LD_LIBRARY_PATH" ]
418       then LD_LIBRARY_PATH="$PWD:$DLLPATH"
419       else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
420       fi
421       export LD_LIBRARY_PATH
422       echo
423       echo "NOTE! To run Wine without installing, you must set the environment variable"
424       echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
425       echo "in your logon scripts."
426       echo
427
428       WINEINSTALLED=no
429     }
430     fi # [ "$ROOTINSTALL" = "yes" ]
431   }
432   fi # [ `whoami` != 'root' ]
433
434 }
435 fi # BINDIST
436
437 # now check whether we should generate wine.conf
438 if [ -z "$DOGLOBALCONF" ]
439 then
440   DOGLOBALCONF=auto
441 fi
442
443 if [ "$DOGLOBALCONF" = 'auto' ]
444 then {
445   # see if we already have a system wine.conf
446   if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
447   then
448     DOGLOBALCONF=no
449     echo "Creation of a global config file is not supported in wineinstall at this"
450     echo "time.  When the configuration architecture is cleaned up this functionality"
451     echo "will be restored to wineinstall."
452     echo
453   fi
454 }
455 fi
456
457 if [ "$DOLOCALCONF" = 'auto' ]
458 then {
459   # see if the user is root, if so, explicitly ask them if they want a
460   # local config file
461   if [ `whoami` = 'root' ]
462   then
463     echo "You are running as root.  Do you want a local config file,"
464     echo "file, ~/.wine/config, created?"
465     conf_yesno_answer "(yes/no) "
466     DOLOCALCONF="$ANSWER"
467   else
468     # if the user has an existing config file ask them if they want us to
469     # overwrite it, otherwise just ask them if they want to create one
470     if [ -f "$LCONF" ]
471     then
472       echo "Found existing $LCONF, do you want to overwrite this"
473       echo "existing Wine configuration file?"
474       conf_yesno_answer "(yes/no) "
475       DOLOCALCONF="$ANSWER"
476       echo
477       if [ "$ANSWER" = "yes" ]
478       then
479       {
480         echo "Would you like to make a backup of this old config file?"
481         conf_yesno_answer "(yes/no) "
482         echo
483         if [ "$ANSWER" = "yes" ]
484         then
485         {
486           echo "Renaming $LCONF to $LCONF.old"
487           mv -f "$LCONF" "$LCONF.old"
488           echo
489         }
490         fi
491       }
492       fi
493     else
494     {
495       echo "Create local config file ~/.wine/config?"
496       conf_yesno_answer "(yes/no) "
497       DOLOCALCONF="$ANSWER"
498       echo
499       if [ "$ANSWER" = 'no' ]
500       then
501         conf_question high need_root \
502           "Aborting install. Try again as root to generate a system wine.conf."
503         exit 1
504       fi
505     }
506     fi
507   fi
508 }
509 fi
510
511 # generate $TMPCONF from existing windows install, if any
512 if [ "$DOLOCALCONF" = 'yes' ]
513 then {
514   if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
515   then {
516     echo -n "Searching for an existing Windows installation..."
517     if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
518     then {
519       rm -f $TMPCONF > /dev/null
520
521       echo " not found. (no matching /etc/fstab mount entry found)"
522       conf_question low do_without_windows \
523        "Windows was not found on your system, so I assume you want" \
524        "a Wine-only installation. Am I correct?"
525       conf_yesno_answer "(yes/no) "
526       if [ "$ANSWER" = 'no' ]
527       then {
528         conf_question high windows_not_found \
529          "Aborting install. Make sure your Windows partition is mounted and try again," \
530          "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
531         exit 1
532       }
533       fi
534       DOWINE=yes
535     }
536     else {
537       echo " found."
538
539       conf_question low do_without_windows \
540        "Windows was found on your system, and so we can use the Windows" \
541        "Drive as our Wine drive. You may, however, wish to create a clean" \
542        "Wine install anyways."
543       conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
544       if [ "$ANSWER" = 'yes' ]
545       then {
546         conf_reset_question windows_found
547         conf_question low windows_found \
548          "Created $LCONF using your existing Windows installation." \
549          "You probably want to review the file, though."
550         DOWINE=no
551       }
552       else {
553         DOWINE=yes
554       }
555       fi
556     }
557     fi
558   }
559   elif [ "$DOWINE" = 'auto' ]
560   then DOWINE=yes
561   fi
562 }
563 elif [ "$DOWINE" = 'auto' ]
564 then
565   DOWINE=no
566 fi
567
568 # setup a no-windows installation, if necessary
569 if [ "$DOWINE" = 'yes' ]
570 then {
571   # set an appropriate DCROOT
572   if [ `whoami` != 'root' ]
573   then DCROOT=~/c
574   else DCROOT=/c
575   fi
576
577   if [ -f ~/.winerc ]
578   then {
579     conf_question medium convert_config \
580      "I found the old version Wine config file, .winerc, in your " \
581      "home directory.  I can convert this to the new format or use the" \
582      "new default Wine config file. Convert?"
583     conf_yesno_answer "(yes/no) "
584     if [ "$ANSWER" = 'yes' ]
585     then {
586       WINEINI=~/.winerc
587       CONVCONF=yes
588     }
589     fi
590   }
591   else {
592
593     conf_question low drivec_path \
594      "Configuring Wine without Windows." \
595      "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
596      "start menu entries, and other things your applications may need to install." \
597      "Where would you like your fake C drive to be placed?"
598     while [ -z "$CROOT" ]
599     do {
600       conf_string_answer "(default is $DCROOT) "
601       [ -z "$ANSWER" ] && ANSWER="$DCROOT"
602       if ! [ -d "$ANSWER" ]
603       then {
604         if mkdir -p "$ANSWER"
605         then CROOT="$ANSWER"
606         else
607           echo "Directory $ANSWER can't be created !"
608           conf_reset_question drivec_path
609         fi
610       }
611       else CROOT="$ANSWER"
612       fi
613     }
614     done
615     echo "Configuring Wine for a no-windows install in $CROOT..."
616
617     create_windows_directories
618     configure_wine_applications
619   }
620   fi
621
622   # create $LCONF using the default config file $WINEINI
623   if [ "$DOLOCALCONF" = 'yes' ] && [ "$CONVCONF" = 'no' ]
624   then {
625     sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
626     conf_reset_question default_config
627     conf_question low default_config \
628      "Created $LCONF using default Wine configuration." \
629      "You probably want to review the file, though."
630   }
631   fi
632
633   # now we really should install the registry
634   if [ "$DOREG" = 'auto' ]
635   then DOREG=yes
636   fi
637 }
638 fi
639 echo
640
641 #install the local config file $LCONF
642 if [ "$DOLOCALCONF" = 'yes' ]
643 then
644   if [ ! -w ~/.wine ]
645   then
646     mkdir ~/.wine
647   fi
648
649   if [ "$CONVCONF" = 'no' ]
650   then
651     cp $TMPCONF $LCONF > /dev/null
652   fi
653 else
654   DOREG=no
655 fi
656
657 #install the global config file $GCONF
658 if [ "$DOGLOBALCONF" = 'yes' ]
659 then
660   if [ ! -f $sysconfdir ]
661   then
662     mkdir -p $sysconfdir
663   fi
664
665   cp $TMPCONF $GCONF > /dev/null
666 fi
667
668 # check whether we need to install default registry
669 # (not to be done if windows registry exists)
670 if [ "$DOREG" = 'auto' ]
671 then {
672   CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
673   echo "Checking for real Windows registry..."
674   if [ -f "$CROOT/windows/system.dat" ]
675   then DOREG=no
676   elif [ -f "$CROOT/windows/system32/config/system" ]
677   then DOREG=no
678   elif [ -f "$CROOT/WINNT/system32/config/system" ]
679   then DOREG=no
680   else DOREG=yes
681   fi
682   if [ "$DOREG" = 'yes' ]
683   then echo "Not found, default Wine registry will be installed."
684   else echo "Windows registry found, will not install default Wine registry."
685   fi
686   echo
687 }
688 fi
689
690 # install default registry entries
691 if [ "$DOREG" = 'yes' ]
692 then {
693   if [ "$BINDIST" = 'no' ]
694   then {
695     echo "Compiling regedit..."
696     (cd programs/regedit; make)
697     echo
698   }
699   fi
700   echo "Preparing to install default Wine registry entries..."
701
702   # edit config files so we don't have to run regedit under X
703   if [ "$CONVCONF" = 'yes' ]
704   then
705     mv $WINEINI $WINEINI.new
706     sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $WINEINI.new > $WINEINI
707   else
708     mv $LCONF $LCONF.new
709     sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"ttydrv\"/" $LCONF.new > $LCONF
710   fi
711
712   echo "Installing default Wine registry entries..."
713   echo
714   if ! $REGEDIT $DEFREG > /dev/null
715   then {
716     echo "Registry install failed."
717     conf_reset_question regedit_error
718     conf_question high regedit_error
719     exit 1
720   }
721   else {
722     # if we are converting from a .winerc file, running regedit once
723     # will ONLY convert .winerc -> ~/.wine/config, it will not import the
724     # registry data.  so if we are converting we need to run regedit twice
725     if [ "$CONVCONF" = 'yes' ]
726     then
727       if ! $REGEDIT $DEFREG > /dev/null
728       then
729         echo "Registry install failed."
730         conf_reset_question regedit_error
731         conf_question high regedit_error
732         exit 1
733       else
734         echo
735         echo "Registry entries successfully installed."
736       fi
737     else
738       echo
739       echo "Registry entries successfully installed."
740     fi
741   }
742   fi
743   if [ "$SYSREG" = 'auto' ]
744   then SYSREG=yes
745   fi
746
747   # if we converted we need to change the graphics driver back and
748   # restore the original .winerc file
749   if [ "$CONVCONF" = 'yes' ]
750   then
751      mv $WINEINI.new $WINEINI
752   fi
753
754   sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"x11drv\"/" $LCONF > $LCONF.new
755   mv $LCONF.new $LCONF
756 }
757 fi
758
759 # make root's registry global, if desired
760 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
761 then {
762   [ -d ~/.wine ] || mkdir ~/.wine
763   if ! [ -f $sysconfdir/wine.userreg ]
764   then {
765     echo "Linking root's user registry hive to the global registry..."
766     [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
767     ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
768   }
769   fi
770   if ! [ -f $sysconfdir/wine.systemreg ]
771   then {
772     echo "Linking root's system registry hive to the global registry..."
773     [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
774     ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
775   }
776   fi
777 }
778 fi
779
780 # cleanup any temporary files that may remain
781 if [ -f $TMPCONF ]
782 then rm -f $TMPCONF
783 fi
784
785
786 # it's a wrap
787 echo
788 echo "Installation complete for now. Good luck (this is still alpha software)."
789 echo "If you have problems with WINE, please read the documentation first,"
790 echo "as many kinds of potential problems are explained there."
791
792 exit 0