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 # this is only for existing-windows installs
41 WINECONF=tools/wineconf # path to the wineconf perl script
43 # this is only for no-windows installs
44 WINEINI=$exdir/config # path to the default wine config file (also used by wineconf)
45 RUNDLL32=programs/rundll32/rundll32 # path to the rundll32 winelib application
46 INFSCRIPT=tools/wine.inf # path to the default .inf script
47 # CROOT=/var/wine # path of the fake Drive C (asks user if not set)
50 # temporary files used by the installer
51 TMPCONF=/tmp/wineinstall.conf
59 function conf_question {
60 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
61 # the first two parameters can be used by e.g. debconf in debian packages
62 # but here we just print the message
74 function conf_reset_question {
75 # parameters: $1 = question-id
76 # this is used to flush any cached answers and "already-displayed" flags
80 function conf_yesno_answer {
82 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
90 function conf_string_answer {
95 function create_windows_directories {
96 for tdir in "$CROOT/windows" "$CROOT/windows/system" \
97 "$CROOT/windows/command" \
98 "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
99 "$CROOT/Program Files" "$CROOT/Program Files/Common Files" \
100 "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator" \
101 "$CROOT/windows/Fonts" "$CROOT/windows/Start Menu/Programs/Startup"
102 do [ -d "$tdir" ] || mkdir "$tdir"
104 cp $INFSCRIPT "$CROOT/windows/system/wine.inf"
107 #creates symbolic link in windows directory to installed winelib application
109 # - name of the installed winelib application
110 # - full path to application in the winelib directory
112 if [ "$WINEINSTALLED" = 'no' ]
114 ln -sf $PWD/programs/$1/$1.exe.so $2
117 ln -sf $libdir/wine/$1.exe.so $2
122 #puts windows applications replacements to windows directories,
124 function configure_wine_applications {
125 link_app start "$CROOT/windows/command/start.exe"
126 link_app notepad "$CROOT/windows/notepad.exe"
127 link_app regedit "$CROOT/windows/regedit.exe"
128 link_app rundll32 "$CROOT/windows/rundll32.exe"
129 link_app wcmd "$CROOT/windows/system/wcmd.exe"
130 link_app control "$CROOT/windows/system/control.exe"
131 link_app winhelp "$CROOT/windows/system/help.exe"
132 link_app notepad "$CROOT/windows/system/notepad.exe"
133 link_app progman "$CROOT/windows/system/progman.exe"
134 link_app regsvr32 "$CROOT/windows/system/regsvr32.exe"
135 link_app winemine "$CROOT/windows/system/winmine.exe"
136 link_app winver "$CROOT/windows/system/winver.exe"
137 link_app uninstaller "$CROOT/windows/uninstall.exe"
138 link_app winhelp "$CROOT/windows/winhelp.exe"
139 link_app winhelp "$CROOT/windows/winhlp32.exe"
140 link_app winebrowser "$CROOT/windows/winebrowser.exe"
145 echo "WINE Installer v0.74"
148 if [ "$BINDIST" = 'no' ]
151 if ! [ -f configure ]
153 if [ -f ../configure ]
158 echo "You're running this from the wrong directory."
159 echo "Change to the Wine source's main directory and try again."
166 if [ `whoami` = 'root' ]
168 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
176 echo "The source directory is not writable. You probably extracted the sources as root."
177 echo "You should remove the source tree and extract it again as a normal user."
182 # check whether RPM installed, and if it is, remove any old wine rpm.
185 if [ $RET -eq 0 ]; then
186 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
187 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
188 conf_yesno_answer "(yes/no) "
189 if [ "$ANSWER" = 'yes' ]; then
190 echo "We need to remove the rpm as root, please enter your root password"
192 echo Starting wine rpm removal...
193 su -c "rpm -e wine; RET=$?"
194 if [ $RET -eq 0 ]; then
197 echo "FAILED. Probably you aren't installing as root."
198 echo "Expect problems (library conflicts with existing install etc.)."
201 echo "Sorry, I won't install Wine when an rpm version is still installed."
202 echo "(Wine support suffered from way too many conflicts between RPM"
203 echo "and source installs)"
204 echo "Have a nice day !"
210 # check whether wine binary still available
211 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
212 echo "Warning !! wine binary (still) found, which may indicate"
213 echo "a (conflicting) previous installation."
214 echo "You might want to abort and uninstall Wine first."
218 # run the configure script, if necessary
220 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
223 echo "I see that WINE has already been configured, so I'll skip that."
225 # load configure results
229 echo "Running configure..."
231 if ! ./configure -C $CONFARGS --prefix=$prefix
234 echo "Configure failed, aborting install."
239 # load configure results
241 # make sure X was found
243 if [ "$have_x" != "yes" ]
245 echo "Install the X development headers and try again."
253 # now do the compilation and install, we need to always do this because we
254 # don't want the 'make install' command we might run to run 'make' as root
255 if [ `whoami` != 'root' ]
257 # ask the user if they want to build and install wine
259 echo "We need to install wine as root user, do you want us to build wine,"
260 echo "'su root' and install Wine? Enter 'no' to continue without installing"
261 conf_yesno_answer "(yes/no) "
262 ROOTINSTALL="$ANSWER"
264 if [ "$ROOTINSTALL" = "yes" ]
266 # start out with the basic command
267 sucommand="make install"
269 # if the user doesn't have $libdir in their ld.so.conf add this
270 # to our sucommand string
271 if [ -f /etc/ld.so.conf ]
273 if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
276 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
277 echo "when we perform the install..."
278 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
281 # run ldconfig always just in case some updated files don't get linked
282 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
285 fi # [ "$ROOTINSTALL" = "yes" ]
289 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
290 echo "in the meantime..."
294 # try to just make wine, if this fails 'make depend' and try to remake
297 if ! { make depend && make; }
300 echo "Compilation failed, aborting install."
307 if [ "$ROOTINSTALL" = "yes" ]
311 echo "Performing 'make install' as root to install binaries, enter root password"
315 if ! su root -c "$sucommand"
317 if ! su root -c "$sucommand"
320 echo "Either you entered an incorrect password or we failed to"
321 echo "run '$sucommand' correctly."
322 echo "If you didn't enter an incorrect password then please"
323 echo "report this error and any steps to possibly reproduce it to"
324 echo "http://bugs.winehq.org/"
326 echo "Installation failed, aborting."
335 # see if wine is installed on the users system, if not prompt them
337 if [ ! `which wine` ]
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."
342 echo "Exiting wineinstall"
351 fi # [ "$ROOTINSTALL" = "yes" ]
353 fi # [ `whoami` != 'root' ]
358 # now check whether we should generate wine.conf
359 if [ -z "$DOGLOBALCONF" ]
364 if [ "$DOGLOBALCONF" = 'auto' ]
366 # see if we already have a system wine.conf
367 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
370 echo "Creation of a global config file is not supported in wineinstall at this"
371 echo "time. When the configuration architecture is cleaned up this functionality"
372 echo "will be restored to wineinstall."
378 if [ "$DOLOCALCONF" = 'auto' ]
380 # see if the user is root, if so, explicitly ask them if they want a
382 if [ `whoami` = 'root' ]
384 echo "You are running as root. Do you want a local config file,"
385 echo "file, ~/.wine/config, created?"
386 conf_yesno_answer "(yes/no) "
387 DOLOCALCONF="$ANSWER"
389 # if the user has an existing config file ask them if they want us to
390 # overwrite it, otherwise just ask them if they want to create one
393 echo "Found existing $LCONF, do you want to overwrite this"
394 echo "existing Wine configuration file?"
395 conf_yesno_answer "(yes/no) "
396 DOLOCALCONF="$ANSWER"
398 if [ "$ANSWER" = "yes" ]
401 echo "Would you like to make a backup of this old config file?"
402 conf_yesno_answer "(yes/no) "
404 if [ "$ANSWER" = "yes" ]
407 echo "Renaming $LCONF to $LCONF.old"
408 mv -f "$LCONF" "$LCONF.old"
416 echo "Create local config file ~/.wine/config?"
417 conf_yesno_answer "(yes/no) "
418 DOLOCALCONF="$ANSWER"
420 if [ "$ANSWER" = 'no' ]
422 conf_question high need_root \
423 "Aborting install. Try again as root to generate a system wine.conf."
432 # generate $TMPCONF from existing windows install, if any
433 if [ "$DOLOCALCONF" = 'yes' ]
435 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
437 echo -n "Searching for an existing Windows installation..."
438 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
440 rm -f $TMPCONF > /dev/null
442 echo " not found. (no matching /etc/fstab mount entry found)"
443 conf_question low do_without_windows \
444 "Windows was not found on your system, so I assume you want" \
445 "a Wine-only installation. Am I correct?"
446 conf_yesno_answer "(yes/no) "
447 if [ "$ANSWER" = 'no' ]
449 conf_question high windows_not_found \
450 "Aborting install. Make sure your Windows partition is mounted and try again," \
451 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
460 conf_question low do_without_windows \
461 "Windows was found on your system, and so we can use the Windows" \
462 "Drive as our Wine drive. You may, however, wish to create a clean" \
463 "Wine install anyways."
464 conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
465 if [ "$ANSWER" = 'yes' ]
467 conf_reset_question windows_found
468 conf_question low windows_found \
469 "Created $LCONF using your existing Windows installation." \
470 "You probably want to review the file, though."
480 elif [ "$DOWINE" = 'auto' ]
484 elif [ "$DOWINE" = 'auto' ]
489 # setup a no-windows installation, if necessary
490 if [ "$DOWINE" = 'yes' ]
492 # set an appropriate DCROOT
493 if [ `whoami` != 'root' ]
498 conf_question low drivec_path \
499 "Configuring Wine without Windows." \
500 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
501 "start menu entries, and other things your applications may need to install." \
502 "Where would you like your fake C drive to be placed?"
503 while [ -z "$CROOT" ]
505 conf_string_answer "(default is $DCROOT) "
506 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
507 if ! [ -d "$ANSWER" ]
509 if mkdir -p "$ANSWER"
512 echo "Directory $ANSWER can't be created !"
513 conf_reset_question drivec_path
520 echo "Configuring Wine for a no-windows install in $CROOT..."
522 create_windows_directories
523 configure_wine_applications
525 # create $LCONF using the default config file $WINEINI
526 if [ "$DOLOCALCONF" = 'yes' ]
528 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
529 conf_reset_question default_config
530 conf_question low default_config \
531 "Created $LCONF using default Wine configuration." \
532 "You probably want to review the file, though."
536 # now we really should install the registry
537 if [ "$DOREG" = 'auto' ]
544 #install the local config file $LCONF
545 if [ "$DOLOCALCONF" = 'yes' ]
551 cp $TMPCONF $LCONF > /dev/null
556 #install the global config file $GCONF
557 if [ "$DOGLOBALCONF" = 'yes' ]
559 if [ ! -f $sysconfdir ]
564 cp $TMPCONF $GCONF > /dev/null
567 # check whether we need to install default registry
568 # (not to be done if windows registry exists)
569 if [ "$DOREG" = 'auto' ]
571 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
572 echo "Checking for real Windows registry..."
573 if [ -f "$CROOT/windows/system.dat" ]
575 elif [ -f "$CROOT/windows/system32/config/system" ]
577 elif [ -f "$CROOT/WINNT/system32/config/system" ]
581 if [ "$DOREG" = 'yes' ]
582 then echo "Not found, default Wine registry will be installed."
583 else echo "Windows registry found, will not install default Wine registry."
589 # install default registry entries
590 if [ "$DOREG" = 'yes' ]
592 if [ "$BINDIST" = 'no' ]
594 echo "Compiling rundll32..."
595 (cd programs/rundll32; make)
599 echo "Preparing to install default Wine registry entries..."
601 # Make sure we are on a Windows drive
602 mv $LCONF $LCONF.orig
603 sed "s/\"Path\" = \"%HOME%\"$/\"Path\" = \"%PWD%\"/" $LCONF.orig> $LCONF
605 echo "Installing default Wine registry entries..."
607 if ! $RUNDLL32 setupapi.dll,InstallHinfSection DefaultInstall 128 $INFSCRIPT > /dev/null
609 echo "Registry install failed."
610 mv $LCONF.orig $LCONF
611 conf_reset_question regedit_error
612 conf_question high regedit_error
617 echo "Registry entries successfully installed."
618 mv $LCONF.orig $LCONF
621 if [ "$SYSREG" = 'auto' ]
627 # make root's registry global, if desired
628 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
630 [ -d ~/.wine ] || mkdir ~/.wine
631 if ! [ -f $sysconfdir/wine.userreg ]
633 echo "Linking root's user registry hive to the global registry..."
634 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
635 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
638 if ! [ -f $sysconfdir/wine.systemreg ]
640 echo "Linking root's system registry hive to the global registry..."
641 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
642 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
648 # cleanup any temporary files that may remain
656 echo "Installation complete for now. Good luck (this is still alpha software)."
657 echo "If you have problems with WINE, please read the documentation first,"
658 echo "as many kinds of potential problems are explained there."