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 GCONF=$sysconfdir/wine.conf # default path of the wine.conf global config file
30 LCONF=~/.wine/config # default path of the local config file
31 BINDIST=no # whether called from a binary package config script
32 DOGLOBALCONF=auto # whether to autogenerate wine.conf
33 DOLOCALCONF=auto # whether to autogenerate localconf
34 DOWCHK=auto # whether to autoconfigure existing-windows installation
35 DOWINE=auto # whether to autoconfigure no-windows installation
36 DOREG=auto # whether to install default registry
37 DOAPP=auto # whether to install applications, distributed with Wine
38 SYSREG=yes # whether to make root's registry global (system-default)
40 # "make install" still installs the dlls into $libdir, but this may change in the future
41 # (DLLPATH should point to them if/when they are not in standard ld.so paths)
42 DLLPATH=$libdir/wine # default path of the dll .so files (except libwine.so)
44 # this is only for existing-windows installs
45 WINECONF=tools/wineconf # path to the wineconf perl script
47 # this is only for no-windows installs
48 WINEINI=$exdir/config # path to the default wine config file (also used by wineconf)
49 WININI=/dev/null # path to the default win.ini
50 SYSTEMINI=$exdir/system.ini # path to the default system.ini
51 REGEDIT=programs/regedit/regedit # path to the regedit winelib application
52 DEFREG=winedefault.reg # path of the registry file to be fed to regedit
53 # CROOT=/var/wine # path of the fake Drive C (asks user if not set)
54 DEFCAT=cat # program to cat $DEFREG with (some packages need zcat)
57 # temporary files used by the installer
58 TMPCONF=/tmp/wineinstall.conf
66 function conf_question {
67 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
68 # the first two parameters can be used by e.g. debconf in debian packages
69 # but here we just print the message
81 function conf_reset_question {
82 # parameters: $1 = question-id
83 # this is used to flush any cached answers and "already-displayed" flags
87 function conf_yesno_answer {
89 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
97 function conf_string_answer {
102 function create_windows_directories {
103 for tdir in "$CROOT/windows" "$CROOT/windows/system" \
104 "$CROOT/windows/command" \
105 "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
106 "$CROOT/Program Files" "$CROOT/Program Files/Common Files" \
107 "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator" \
108 "$CROOT/windows/Fonts" "$CROOT/windows/Start Menu/Programs/Startup"
109 do [ -d "$tdir" ] || mkdir "$tdir"
111 [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
112 [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
115 #creates symbolic link in windows directory to installed winelib application
117 # - name of the installed winelib application
118 # - full path to application in the winelib directory
120 if [ "$WINEINSTALLED" = 'no' ]
122 ln -sf $PWD/programs/$1/$1.exe.so $2
125 ln -sf $libdir/wine/$1.exe.so $2
130 #puts windows applications replacements to windows directories,
132 function configure_wine_applications {
133 link_app start "$CROOT/windows/command/start.exe"
134 link_app notepad "$CROOT/windows/notepad.exe"
135 link_app regedit "$CROOT/windows/regedit.exe"
136 link_app rundll32 "$CROOT/windows/rundll32.exe"
137 link_app wcmd "$CROOT/windows/system/wcmd.exe"
138 link_app control "$CROOT/windows/system/control.exe"
139 link_app winhelp "$CROOT/windows/system/help.exe"
140 link_app notepad "$CROOT/windows/system/notepad.exe"
141 link_app progman "$CROOT/windows/system/progman.exe"
142 link_app regsvr32 "$CROOT/windows/system/regsvr32.exe"
143 link_app winemine "$CROOT/windows/system/winmine.exe"
144 link_app winver "$CROOT/windows/system/winver.exe"
145 link_app uninstaller "$CROOT/windows/uninstall.exe"
146 link_app winhelp "$CROOT/windows/winhelp.exe"
147 link_app winhelp "$CROOT/windows/winhlp32.exe"
152 echo "WINE Installer v0.74"
155 if [ "$BINDIST" = 'no' ]
158 if ! [ -f configure ]
160 if [ -f ../configure ]
165 echo "You're running this from the wrong directory."
166 echo "Change to the Wine source's main directory and try again."
173 if [ `whoami` == 'root' ]
175 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
181 # check whether RPM installed, and if it is, remove any old wine rpm.
184 if [ $RET -eq 0 ]; then
185 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
186 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
187 conf_yesno_answer "(yes/no) "
188 if [ "$ANSWER" = 'yes' ]; then
189 echo "We need to remove the rpm as root, please enter your root password"
191 echo Starting wine rpm removal...
192 su -c "rpm -e wine; RET=$?"
193 if [ $RET -eq 0 ]; then
196 echo "FAILED. Probably you aren't installing as root."
197 echo "Expect problems (library conflicts with existing install etc.)."
200 echo "Sorry, I won't install Wine when an rpm version is still installed."
201 echo "(Wine support suffered from way too many conflicts between RPM"
202 echo "and source installs)"
203 echo "Have a nice day !"
209 # check whether wine binary still available
210 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
211 echo "Warning !! wine binary (still) found, which may indicate"
212 echo "a (conflicting) previous installation."
213 echo "You might want to abort and uninstall Wine first."
217 # run the configure script, if necessary
219 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
222 echo "I see that WINE has already been configured, so I'll skip that."
224 # load configure results
228 echo "Running configure..."
230 if ! ./configure -C $CONFARGS
233 echo "Configure failed, aborting install."
238 # load configure results
240 # make sure X was found
242 if [ "$have_x" != "yes" ]
244 echo "Install the X development headers and try again."
252 # now do the compilation and install, we need to always do this because we
253 # don't want the 'make install' command we might run to run 'make' as root
254 if [ `whoami` != 'root' ]
256 # ask the user if they want to build and install wine
258 echo "We need to install wine as root user, do you want us to build wine,"
259 echo "'su root' and install Wine? Enter 'no' to continue without installing"
260 conf_yesno_answer "(yes/no) "
261 ROOTINSTALL="$ANSWER"
263 if [ "$ROOTINSTALL" = "yes" ]
265 # start out with the basic command
266 sucommand="make install"
268 # if the user doesn't have $libdir in their ld.so.conf add this
269 # to our sucommand string
270 if [ -f /etc/ld.so.conf ]
272 if ! grep -qs "$libdir" /etc/ld.so.conf
275 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
276 echo "when we perform the install..."
277 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
280 # run ldconfig always just in case some updated files dont get linked
281 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
284 fi # [ "$ROOTINSTALL" = "yes" ]
288 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
289 echo "in the meantime..."
293 # try to just make wine, if this fails 'make depend' and try to remake
296 if ! { make depend && make; }
299 echo "Compilation failed, aborting install."
306 if [ "$ROOTINSTALL" = "yes" ]
310 echo "Performing 'make install' as root to install binaries, enter root password"
314 if ! su root -c "$sucommand"
317 echo "Either you entered an incorrect password or we failed to run"
318 echo "'$sucommand' correctly."
319 echo "If you didn't enter an incorrect password then please report this"
320 echo "error and any steps to possibly reproduce it to"
321 echo "http://bugs.winehq.com/"
323 echo "Installation failed, aborting."
330 # see if wine is installed on the users system, if not prompt them
332 if [ ! `which wine` ]
334 echo "Could not find wine on your system. Run wineinstall as root to install wine"
335 echo "before re-running wineinstall as a user."
337 echo "Exiting wineinstall"
344 # user didn't want to install wine so tell them about running from the
345 # current directory and set some stuff up for them
347 # setup to run from current directory
349 if [ -z "$LD_LIBRARY_PATH" ]
350 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
351 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
353 export LD_LIBRARY_PATH
355 echo "NOTE! To run Wine without installing, you must set the environment variable"
356 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
357 echo "in your logon scripts."
362 fi # [ "$ROOTINSTALL" = "yes" ]
364 fi # [ `whoami` != 'root' ]
369 # now check whether we should generate wine.conf
370 if [ -z "$DOGLOBALCONF" ]
375 if [ "$DOGLOBALCONF" = 'auto' ]
377 # see if we already have a system wine.conf
378 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
381 echo "Creation of a global config file is not supported in wineinstall at this"
382 echo "time. When the configuration architecture is cleaned up this functionality"
383 echo "will be restored to wineinstall."
389 if [ "$DOLOCALCONF" = 'auto' ]
391 # see if the user is root, if so, explicitly ask them if they want a
393 if [ `whoami` = 'root' ]
395 echo "You are running as root. Do you want a local config file,"
396 echo "file, ~/.wine/config, created?"
397 conf_yesno_answer "(yes/no) "
398 DOLOCALCONF="$ANSWER"
400 # if the user has an existing config file ask them if they want us to
401 # overwrite it, otherwise just ask them if they want to create one
404 echo "Found existing $LCONF, do you want to overwrite this"
405 echo "existing Wine configuration file?"
406 conf_yesno_answer "(yes/no) "
407 DOLOCALCONF="$ANSWER"
409 if [ "$ANSWER" = "yes" ]
412 echo "Would you like to make a backup of this old config file?"
413 conf_yesno_answer "(yes/no) "
415 if [ "$ANSWER" = "yes" ]
418 echo "Renaming $LCONF to $LCONF.old"
419 mv -f "$LCONF" "$LCONF.old"
427 echo "Create local config file ~/.wine/config?"
428 conf_yesno_answer "(yes/no) "
429 DOLOCALCONF="$ANSWER"
431 if [ "$ANSWER" = 'no' ]
433 conf_question high need_root \
434 "Aborting install. Try again as root to generate a system wine.conf."
443 # generate $TMPCONF from existing windows install, if any
444 if [ "$DOLOCALCONF" = 'yes' ]
446 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
448 echo -n "Searching for an existing Windows installation..."
449 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
451 rm -f $TMPCONF > /dev/null
453 echo " not found. (no matching /etc/fstab mount entry found)"
454 conf_question low do_without_windows \
455 "Windows was not found on your system, so I assume you want" \
456 "a Wine-only installation. Am I correct?"
457 conf_yesno_answer "(yes/no) "
458 if [ "$ANSWER" = 'no' ]
460 conf_question high windows_not_found \
461 "Aborting install. Make sure your Windows partition is mounted and try again," \
462 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
471 conf_question low do_without_windows \
472 "Windows was found on your system, and so we can use the Windows" \
473 "Drive as our Wine drive. You may, however, wish to create a clean" \
474 "Wine install anyways."
475 conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
476 if [ "$ANSWER" = 'yes' ]
478 conf_reset_question windows_found
479 conf_question low windows_found \
480 "Created $LCONF using your existing Windows installation." \
481 "You probably want to review the file, though."
491 elif [ "$DOWINE" = 'auto' ]
495 elif [ "$DOWINE" = 'auto' ]
500 # setup a no-windows installation, if necessary
501 if [ "$DOWINE" = 'yes' ]
503 # set an appropriate DCROOT
504 if [ `whoami` != 'root' ]
509 conf_question low drivec_path \
510 "Configuring Wine without Windows." \
511 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
512 "start menu entries, and other things your applications may need to install." \
513 "Where would you like your fake C drive to be placed?"
514 while [ -z "$CROOT" ]
516 conf_string_answer "(default is $DCROOT) "
517 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
518 if ! [ -d "$ANSWER" ]
520 if mkdir -p "$ANSWER"
523 echo "Directory $ANSWER can't be created !"
524 conf_reset_question drivec_path
531 echo "Configuring Wine for a no-windows install in $CROOT..."
533 create_windows_directories
534 configure_wine_applications
536 # create $LCONF using the default config file $WINEINI
537 if [ "$DOLOCALCONF" = 'yes' ]
539 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
540 conf_reset_question default_config
541 conf_question low default_config \
542 "Created $LCONF using default Wine configuration." \
543 "You probably want to review the file, though."
547 # now we really should install the registry
548 if [ "$DOREG" = 'auto' ]
555 #install the local config file $LCONF
556 if [ "$DOLOCALCONF" = 'yes' ]
562 cp $TMPCONF $LCONF > /dev/null
567 #install the global config file $GCONF
568 if [ "$DOGLOBALCONF" = 'yes' ]
570 if [ ! -f $sysconfdir ]
575 cp $TMPCONF $GCONF > /dev/null
578 # check whether we need to install default registry
579 # (not to be done if windows registry exists)
580 if [ "$DOREG" = 'auto' ]
582 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
583 echo "Checking for real Windows registry..."
584 if [ -f "$CROOT/windows/system.dat" ]
586 elif [ -f "$CROOT/windows/system32/config/system" ]
588 elif [ -f "$CROOT/WINNT/system32/config/system" ]
592 if [ "$DOREG" = 'yes' ]
593 then echo "Not found, default Wine registry will be installed."
594 else echo "Windows registry found, will not install default Wine registry."
600 # install default registry entries
601 if [ "$DOREG" = 'yes' ]
603 if [ "$BINDIST" = 'no' ]
605 echo "Compiling regedit..."
606 (cd programs/regedit; make)
610 echo "Preparing to install default Wine registry entries..."
612 # edit config files so we don't have to run regedit under X
613 mv $LCONF $LCONF.orig
614 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"ttydrv\"/" $LCONF.orig > $LCONF
616 echo "Installing default Wine registry entries..."
618 if ! $REGEDIT $DEFREG > /dev/null
620 echo "Registry install failed."
621 mv $LCONF.orig $LCONF
622 conf_reset_question regedit_error
623 conf_question high regedit_error
628 echo "Registry entries successfully installed."
629 mv $LCONF.orig $LCONF
632 if [ "$SYSREG" = 'auto' ]
638 # make root's registry global, if desired
639 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
641 [ -d ~/.wine ] || mkdir ~/.wine
642 if ! [ -f $sysconfdir/wine.userreg ]
644 echo "Linking root's user registry hive to the global registry..."
645 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
646 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
649 if ! [ -f $sysconfdir/wine.systemreg ]
651 echo "Linking root's system registry hive to the global registry..."
652 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
653 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
659 # cleanup any temporary files that may remain
667 echo "Installation complete for now. Good luck (this is still alpha software)."
668 echo "If you have problems with WINE, please read the documentation first,"
669 echo "as many kinds of potential problems are explained there."