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 # Mar 31 1999 - Ove Kåven
24 # Dec 9 1999 - Ove Kåven
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
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
57 # add conf_question to allow root to install a local config file and
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
91 #--- defaults (change these if you are a packager)
92 CONFARGS="--enable-opengl" # 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
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)
114 # having the Wine debugger launched automatically will be a plus for us
115 DEBUGGER=$bindir/winedbg # the (installed) path of winedbg
116 HDEBUGGER=debugger/winedbg # the (non-installed) path of winedbg
118 # this is only for existing-windows installs
119 WINECONF=tools/wineconf # path to the wineconf perl script
121 # this is only for no-windows installs
122 WINEINI=$exdir/config # path to the default wine config file (also used by wineconf)
123 WININI=/dev/null # path to the default win.ini
124 SYSTEMINI=$exdir/system.ini # path to the default system.ini
125 REGEDIT=$bindir/regedit # path to the regedit winelib application
126 DEFREG=winedefault.reg # path of the registry file to be fed to regedit
127 # CROOT=/var/wine # path of the fake Drive C (asks user if not set)
128 DEFCAT=cat # program to cat $DEFREG with (some packages need zcat)
131 # temporary files used by the installer
132 TMPCONF=/tmp/wineinstall.conf
133 TMPREG=/tmp/wineinstall.reg
141 function conf_question {
142 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
143 # the first two parameters can be used by e.g. debconf in debian packages
144 # but here we just print the message
156 function conf_reset_question {
157 # parameters: $1 = question-id
158 # this is used to flush any cached answers and "already-displayed" flags
159 shift # dummy command
162 function conf_yesno_answer {
164 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
172 function conf_string_answer {
177 function create_windows_directories {
178 for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/system32" \
179 "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
180 "$CROOT/Program Files" "$CROOT/Program Files/Common Files" \
181 "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator" \
182 "$CROOT/windows/Fonts" "$CROOT/windows/Start Menu/Programs/Startup"
183 do [ -d "$tdir" ] || mkdir "$tdir"
185 [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
186 [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
189 #creates symbolic link in windows directory to installed winelib application
191 # - name of the installed winelib application
192 # - full path to application in the winelib directory
194 ln -sf $libdir/wine/$1.exe.so $2
197 #puts windows applications replacements to windows directories,
199 function configure_wine_applications {
200 link_app notepad "$CROOT/windows/notepad.exe"
201 link_app regedit "$CROOT/windows/regedit.exe"
202 link_app wcmd "$CROOT/windows/system32/cmd.exe"
203 link_app control "$CROOT/windows/system32/control.exe"
204 link_app winhelp "$CROOT/windows/system32/help.exe"
205 link_app notepad "$CROOT/windows/system32/notepad.exe"
206 link_app progman "$CROOT/windows/system32/progman.exe"
207 link_app regsvr32 "$CROOT/windows/system32/regsvr32.exe"
208 link_app winemine "$CROOT/windows/system32/winmine.exe"
209 link_app winver "$CROOT/windows/system32/winver.exe"
210 link_app uninstaller "$CROOT/windows/uninstall.exe"
211 link_app winhelp "$CROOT/windows/winhelp.exe"
212 link_app winhelp "$CROOT/windows/winhlp32.exe"
217 echo "WINE Installer v0.73"
220 if [ "$BINDIST" = 'no' ]
223 if ! [ -f configure ]
225 if [ -f ../configure ]
230 echo "You're running this from the wrong directory."
231 echo "Change to the Wine source's main directory and try again."
238 if [ `whoami` == 'root' ]
240 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
246 # check whether RPM installed, and if it is, remove any old wine rpm.
249 if [ $RET -eq 0 ]; then
250 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
251 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
252 conf_yesno_answer "(yes/no) "
253 if [ "$ANSWER" = 'yes' ]; then
254 echo "We need to remove the rpm as root, please enter your root password"
256 echo Starting wine rpm removal...
257 su -c "rpm -e wine; RET=$?"
258 if [ $RET -eq 0 ]; then
261 echo "FAILED. Probably you aren't installing as root."
262 echo "Expect problems (library conflicts with existing install etc.)."
265 echo "Sorry, I won't install Wine when an rpm version is still installed."
266 echo "(Wine support suffered from way too many conflicts between RPM"
267 echo "and source installs)"
268 echo "Have a nice day !"
274 # check whether wine binary still available
275 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
276 echo "Warning !! wine binary (still) found, which may indicate"
277 echo "a (conflicting) previous installation."
278 echo "You might want to abort and uninstall Wine first."
282 # run the configure script, if necessary
284 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
287 echo "I see that WINE has already been configured, so I'll skip that."
289 # load configure results
293 echo "Running configure..."
295 if ! ./configure -C $CONFARGS
298 echo "Configure failed, aborting install."
303 # load configure results
305 # make sure X was found
307 if [ "$have_x" != "yes" ]
309 echo "Install the X development headers and try again."
317 # now do the compilation and install, we need to always do this because we
318 # don't want the 'make install' command we might run to run 'make' as root
319 if [ `whoami` != 'root' ]
321 # ask the user if they want to build and install wine
323 echo "We need to install wine as root user, do you want us to build wine,"
324 echo "'su root' and install Wine? Enter 'no' to continue without installing"
325 conf_yesno_answer "(yes/no) "
326 ROOTINSTALL="$ANSWER"
328 if [ "$ROOTINSTALL" = "yes" ]
330 # start out with the basic command
331 sucommand="make install"
333 # if the user doesn't have $libdir in their ld.so.conf add this
334 # to our sucommand string
335 if [ -f /etc/ld.so.conf ]
337 if ! grep -qs "$libdir" /etc/ld.so.conf
340 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
341 echo "when we perform the install..."
342 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
345 # run ldconfig always just in case some updated files dont get linked
346 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
349 fi # [ "$ROOTINSTALL" = "yes" ]
353 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
354 echo "in the meantime..."
358 # try to just make wine, if this fails 'make depend' and try to remake
361 if ! { make depend && make; }
364 echo "Compilation failed, aborting install."
371 if [ "$ROOTINSTALL" = "yes" ]
375 echo "Performing 'make install' as root to install binaries, enter root password"
379 if ! su root -c "$sucommand"
382 echo "Either you entered an incorrect password or we failed to run"
383 echo "'$sucommand' correctly."
384 echo "If you didn't enter an incorrect password then please report this"
385 echo "error and any steps to possibly reproduce it to"
386 echo "http://bugs.winehq.com/"
388 echo "Installation failed, aborting."
395 # see if wine is installed on the users system, if not prompt them
397 if [ ! `which wine` ]
399 echo "Could not find wine on your system. Run wineinstall as root to install wine"
400 echo "before re-running wineinstall as a user."
402 echo "Exiting wineinstall"
407 # user didn't want to install wine so tell them about running from the
408 # current directory and set some stuff up for them
410 # setup to run from current directory
412 if [ -z "$LD_LIBRARY_PATH" ]
413 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
414 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
416 export LD_LIBRARY_PATH
417 DEBUGGER="$PWD/$HDEBUGGER"
419 echo "NOTE! To run Wine without installing, you must set the environment variable"
420 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
421 echo "in your logon scripts."
424 fi # [ "$ROOTINSTALL" = "yes" ]
426 fi # [ `whoami` != 'root' ]
431 # now check whether we should generate wine.conf
432 if [ -z "$DOGLOBALCONF" ]
437 if [ "$DOGLOBALCONF" = 'auto' ]
439 # see if we already have a system wine.conf
440 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
443 echo "Creation of a global config file is not supported in wineinstall at this"
444 echo "time. When the configuration architecture is cleaned up this functionality"
445 echo "will be restored to wineinstall."
451 if [ "$DOLOCALCONF" = 'auto' ]
453 # see if the user is root, if so, explicitly ask them if they want a
455 if [ `whoami` = 'root' ]
457 echo "You are running as root. Do you want a local config file,"
458 echo "file, ~/.wine/config, created?"
459 conf_yesno_answer "(yes/no) "
460 DOLOCALCONF="$ANSWER"
462 # if the user has an existing config file ask them if they want us to
463 # overwrite it, otherwise just ask them if they want to create one
466 echo "Found existing $LCONF, do you want to overwrite this"
467 echo "existing Wine configuration file?"
468 conf_yesno_answer "(yes/no) "
469 DOLOCALCONF="$ANSWER"
471 if [ "$ANSWER" = "yes" ]
474 echo "Would you like to make a backup of this old config file?"
475 conf_yesno_answer "(yes/no) "
477 if [ "$ANSWER" = "yes" ]
480 echo "Renaming $LCONF to $LCONF.old"
481 mv -f "$LCONF" "$LCONF.old"
489 echo "Create local config file ~/.wine/config?"
490 conf_yesno_answer "(yes/no) "
491 DOLOCALCONF="$ANSWER"
493 if [ "$ANSWER" = 'no' ]
495 conf_question high need_root \
496 "Aborting install. Try again as root to generate a system wine.conf."
505 # generate $TMPCONF from existing windows install, if any
506 if [ "$DOLOCALCONF" = 'yes' ]
508 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
510 echo -n "Searching for an existing Windows installation..."
511 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
513 rm -f $TMPCONF $TMPREG > /dev/null
515 echo " not found. (no matching /etc/fstab mount entry found)"
516 conf_question low do_without_windows \
517 "Windows was not found on your system, so I assume you want" \
518 "a Wine-only installation. Am I correct?"
519 conf_yesno_answer "(yes/no) "
520 if [ "$ANSWER" = 'no' ]
522 conf_question high windows_not_found \
523 "Aborting install. Make sure your Windows partition is mounted and try again," \
524 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
533 conf_reset_question windows_found
534 conf_question low windows_found \
535 "Created $LCONF using your existing Windows installation." \
536 "You probably want to review the file, though."
541 elif [ "$DOWINE" = 'auto' ]
545 elif [ "$DOWINE" = 'auto' ]
550 # setup a no-windows installation, if necessary
551 if [ "$DOWINE" = 'yes' ]
553 # set an appropriate DCROOT
554 if [ `whoami` != 'root' ]
561 conf_question medium convert_config \
562 "I found the old version Wine config file, .winerc, in your " \
563 "home directory. I can convert this to the new format or use the" \
564 "new default Wine config file. Convert?"
565 conf_yesno_answer "(yes/no) "
566 if [ "$ANSWER" = 'yes' ]
575 conf_question low drivec_path \
576 "Configuring Wine without Windows." \
577 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
578 "start menu entries, and other things your applications may need to install." \
579 "Where would you like your fake C drive to be placed?"
580 while [ -z "$CROOT" ]
582 conf_string_answer "(default is $DCROOT) "
583 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
584 if ! [ -d "$ANSWER" ]
586 if mkdir -p "$ANSWER"
589 echo "Directory $ANSWER can't be created !"
590 conf_reset_question drivec_path
597 echo "Configuring Wine for a no-windows install in $CROOT..."
599 create_windows_directories
600 configure_wine_applications
604 # create $LCONF using the default config file $WINEINI
605 if [ "$DOLOCALCONF" = 'yes' ] && [ "$CONVCONF" = 'no' ]
607 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
608 conf_reset_question default_config
609 conf_question low default_config \
610 "Created $LCONF using default Wine configuration." \
611 "You probably want to review the file, though."
615 # now we really should install the registry
616 if [ "$DOREG" = 'auto' ]
623 #install the local config file $LCONF
624 if [ "$DOLOCALCONF" = 'yes' ]
631 if [ "$CONVCONF" = 'no' ]
633 cp $TMPCONF $LCONF > /dev/null
639 #install the global config file $GCONF
640 if [ "$DOGLOBALCONF" = 'yes' ]
642 if [ ! -f $sysconfdir ]
647 cp $TMPCONF $GCONF > /dev/null
650 # check whether we need to install default registry
651 # (not to be done if windows registry exists)
652 if [ "$DOREG" = 'auto' ]
654 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
655 echo "Checking for real Windows registry..."
656 if [ -f "$CROOT/windows/system.dat" ]
658 elif [ -f "$CROOT/windows/system32/config/system" ]
660 elif [ -f "$CROOT/WINNT/system32/config/system" ]
664 if [ "$DOREG" = 'yes' ]
665 then echo "Not found, default Wine registry will be installed."
666 else echo "Windows registry found, will not install default Wine registry."
672 # install default registry entries
673 if [ "$DOREG" = 'yes' ]
675 if [ "$BINDIST" = 'no' ]
677 echo "Compiling regedit..."
678 (cd programs/regedit; make)
682 echo "Preparing to install default Wine registry entries..."
684 # edit config files so we don't have to run regedit under X
685 if [ "$CONVCONF" = 'yes' ]
687 mv $WINEINI $WINEINI.new
688 sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $WINEINI.new > $WINEINI
691 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"ttydrv\"/" $LCONF.new > $LCONF
694 # create a temporary wineinstall.reg with fixed debugger path
695 $DEFCAT $DEFREG | sed "s|debugger/winedbg|${DEBUGGER}|" > $TMPREG
697 echo "Installing default Wine registry entries..."
699 if ! $REGEDIT $TMPREG > /dev/null
702 echo "Registry install failed."
703 conf_reset_question regedit_error
704 conf_question high regedit_error
708 # if we are converting from a .winerc file, running regedit once
709 # will ONLY convert .winerc -> ~/.wine/config, it will not import the
710 # registry data. so if we are converting we need to run regedit twice
711 if [ "$CONVCONF" = 'yes' ]
713 if ! $REGEDIT $TMPREG > /dev/null
716 echo "Registry install failed."
717 conf_reset_question regedit_error
718 conf_question high regedit_error
722 echo "Registry entries successfully installed."
726 echo "Registry entries successfully installed."
731 if [ "$SYSREG" = 'auto' ]
735 # if we converted we need to change the graphics driver back and
736 # restore the original .winerc file
737 if [ "$CONVCONF" = 'yes' ]
739 mv $WINEINI.new $WINEINI
742 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"x11drv\"/" $LCONF > $LCONF.new
747 # make root's registry global, if desired
748 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
750 [ -d ~/.wine ] || mkdir ~/.wine
751 if ! [ -f $sysconfdir/wine.userreg ]
753 echo "Linking root's user registry hive to the global registry..."
754 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
755 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
758 if ! [ -f $sysconfdir/wine.systemreg ]
760 echo "Linking root's system registry hive to the global registry..."
761 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
762 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
768 # cleanup any temporary files that may remain
779 echo "Installation complete for now. Good luck (this is still alpha software)."
780 echo "If you have problems with WINE, please read the documentation first,"
781 echo "as many kinds of potential problems are explained there."