Remove unused variables EXE, BAT, CMD, and COM.
[wine/hacks.git] / tools / wineinstall
blobc4af41a88c734f20f0b0715bd8f43ab60a49e974
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
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)
55 #--- end of defaults
57 # temporary files used by the installer
58 TMPCONF=/tmp/wineinstall.conf
60 # functions
62 function std_sleep {
63 sleep 1
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
70 shift 2
71 echo
72 local LINE="$1"
73 while shift
74 do {
75 echo "$LINE"
76 LINE="$1"
78 done
81 function conf_reset_question {
82 # parameters: $1 = question-id
83 # this is used to flush any cached answers and "already-displayed" flags
84 shift # dummy command
87 function conf_yesno_answer {
88 unset ANSWER
89 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
90 do {
91 echo -n "$1"
92 read ANSWER
94 done
97 function conf_string_answer {
98 echo -n "$1"
99 read 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"
110 done
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
116 #parameters:
117 # - name of the installed winelib application
118 # - full path to application in the winelib directory
119 function link_app {
120 if [ "$WINEINSTALLED" = 'no' ]
121 then {
122 ln -sf $PWD/programs/$1/$1.exe.so $2
124 else {
125 ln -sf $libdir/wine/$1.exe.so $2
130 #puts windows applications replacements to windows directories,
131 #configures them
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"
150 # startup...
152 echo "WINE Installer v0.74"
153 echo
155 # check for redhat 9 with tls libs so we can enable --with-nptl until runtime detection is complete
156 if [ -e /etc/redhat-release ] && grep "Shrike" /etc/redhat-release &>/dev/null && [ -e /lib/tls ]; then
157 CONFARGS="$CONFARGS --with-nptl"
160 if [ "$BINDIST" = 'no' ]
161 then {
163 if ! [ -f configure ]
164 then {
165 if [ -f ../configure ]
166 then {
167 pushd ..
169 else {
170 echo "You're running this from the wrong directory."
171 echo "Change to the Wine source's main directory and try again."
172 exit 1
178 if [ `whoami` == 'root' ]
179 then {
180 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
181 echo "Aborting."
182 exit 1
186 if [ ! -w . ]
187 then {
188 echo "The source directory is not writable. You probably extracted the sources as root."
189 echo "You should remove the source tree and extract it again as a normal user."
190 exit 1
194 # check whether RPM installed, and if it is, remove any old wine rpm.
195 hash rpm &>/dev/null
196 RET=$?
197 if [ $RET -eq 0 ]; then
198 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
199 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
200 conf_yesno_answer "(yes/no) "
201 if [ "$ANSWER" = 'yes' ]; then
202 echo "We need to remove the rpm as root, please enter your root password"
203 echo
204 echo Starting wine rpm removal...
205 su -c "rpm -e wine; RET=$?"
206 if [ $RET -eq 0 ]; then
207 echo Done.
208 else
209 echo "FAILED. Probably you aren't installing as root."
210 echo "Expect problems (library conflicts with existing install etc.)."
212 else
213 echo "Sorry, I won't install Wine when an rpm version is still installed."
214 echo "(Wine support suffered from way too many conflicts between RPM"
215 echo "and source installs)"
216 echo "Have a nice day !"
217 exit 1
222 # check whether wine binary still available
223 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
224 echo "Warning !! wine binary (still) found, which may indicate"
225 echo "a (conflicting) previous installation."
226 echo "You might want to abort and uninstall Wine first."
227 std_sleep
230 # run the configure script, if necessary
232 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
233 then {
234 echo
235 echo "I see that WINE has already been configured, so I'll skip that."
236 std_sleep
237 # load configure results
238 . ./config.cache
240 else {
241 echo "Running configure..."
242 echo
243 if ! ./configure -C $CONFARGS --prefix=$prefix
244 then {
245 echo
246 echo "Configure failed, aborting install."
247 rm -f config.cache
248 exit 1
251 # load configure results
252 . ./config.cache
253 # make sure X was found
254 eval "$ac_cv_have_x"
255 if [ "$have_x" != "yes" ]
256 then {
257 echo "Install the X development headers and try again."
258 rm -f config.cache
259 exit 1
265 # now do the compilation and install, we need to always do this because we
266 # don't want the 'make install' command we might run to run 'make' as root
267 if [ `whoami` != 'root' ]
268 then {
269 # ask the user if they want to build and install wine
270 echo
271 echo "We need to install wine as root user, do you want us to build wine,"
272 echo "'su root' and install Wine? Enter 'no' to continue without installing"
273 conf_yesno_answer "(yes/no) "
274 ROOTINSTALL="$ANSWER"
276 if [ "$ROOTINSTALL" = "yes" ]
277 then {
278 # start out with the basic command
279 sucommand="make install"
281 # if the user doesn't have $libdir in their ld.so.conf add this
282 # to our sucommand string
283 if [ -f /etc/ld.so.conf ]
284 then
285 if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
286 then {
287 echo
288 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
289 echo "when we perform the install..."
290 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
293 # run ldconfig always just in case some updated files dont get linked
294 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
297 fi # [ "$ROOTINSTALL" = "yes" ]
299 echo
301 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
302 echo "in the meantime..."
303 echo
304 std_sleep
306 # try to just make wine, if this fails 'make depend' and try to remake
307 if ! { make; }
308 then {
309 if ! { make depend && make; }
310 then {
311 echo
312 echo "Compilation failed, aborting install."
313 exit 1
319 if [ "$ROOTINSTALL" = "yes" ]
320 then {
321 echo
323 echo "Performing 'make install' as root to install binaries, enter root password"
325 std_sleep
327 if ! su root -c "$sucommand"
328 then {
329 if ! su root -c "$sucommand"
330 then {
331 echo
332 echo "Either you entered an incorrect password or we failed to"
333 echo "run '$sucommand' correctly."
334 echo "If you didn't enter an incorrect password then please"
335 echo "report this error and any steps to possibly reproduce it to"
336 echo "http://bugs.winehq.com/"
337 echo
338 echo "Installation failed, aborting."
339 exit 1
345 echo
347 # see if wine is installed on the users system, if not prompt them
348 # and then exit
349 if [ ! `which wine` ]
350 then
351 echo "Could not find wine on your system. Run wineinstall as root to install wine"
352 echo "before re-running wineinstall as a user."
353 echo
354 echo "Exiting wineinstall"
355 exit 1;
358 WINEINSTALLED=yes
360 else {
361 # user didn't want to install wine so tell them about running from the
362 # current directory and set some stuff up for them
364 # setup to run from current directory
365 DLLPATH="$PWD/dlls"
366 if [ -z "$LD_LIBRARY_PATH" ]
367 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
368 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
370 export LD_LIBRARY_PATH
371 echo
372 echo "NOTE! To run Wine without installing, you must set the environment variable"
373 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
374 echo "in your logon scripts."
375 echo
377 WINEINSTALLED=no
379 fi # [ "$ROOTINSTALL" = "yes" ]
381 fi # [ `whoami` != 'root' ]
384 fi # BINDIST
386 # now check whether we should generate wine.conf
387 if [ -z "$DOGLOBALCONF" ]
388 then
389 DOGLOBALCONF=auto
392 if [ "$DOGLOBALCONF" = 'auto' ]
393 then {
394 # see if we already have a system wine.conf
395 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
396 then
397 DOGLOBALCONF=no
398 echo "Creation of a global config file is not supported in wineinstall at this"
399 echo "time. When the configuration architecture is cleaned up this functionality"
400 echo "will be restored to wineinstall."
401 echo
406 if [ "$DOLOCALCONF" = 'auto' ]
407 then {
408 # see if the user is root, if so, explicitly ask them if they want a
409 # local config file
410 if [ `whoami` = 'root' ]
411 then
412 echo "You are running as root. Do you want a local config file,"
413 echo "file, ~/.wine/config, created?"
414 conf_yesno_answer "(yes/no) "
415 DOLOCALCONF="$ANSWER"
416 else
417 # if the user has an existing config file ask them if they want us to
418 # overwrite it, otherwise just ask them if they want to create one
419 if [ -f "$LCONF" ]
420 then
421 echo "Found existing $LCONF, do you want to overwrite this"
422 echo "existing Wine configuration file?"
423 conf_yesno_answer "(yes/no) "
424 DOLOCALCONF="$ANSWER"
425 echo
426 if [ "$ANSWER" = "yes" ]
427 then
429 echo "Would you like to make a backup of this old config file?"
430 conf_yesno_answer "(yes/no) "
431 echo
432 if [ "$ANSWER" = "yes" ]
433 then
435 echo "Renaming $LCONF to $LCONF.old"
436 mv -f "$LCONF" "$LCONF.old"
437 echo
442 else
444 echo "Create local config file ~/.wine/config?"
445 conf_yesno_answer "(yes/no) "
446 DOLOCALCONF="$ANSWER"
447 echo
448 if [ "$ANSWER" = 'no' ]
449 then
450 conf_question high need_root \
451 "Aborting install. Try again as root to generate a system wine.conf."
452 exit 1
460 # generate $TMPCONF from existing windows install, if any
461 if [ "$DOLOCALCONF" = 'yes' ]
462 then {
463 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
464 then {
465 echo -n "Searching for an existing Windows installation..."
466 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
467 then {
468 rm -f $TMPCONF > /dev/null
470 echo " not found. (no matching /etc/fstab mount entry found)"
471 conf_question low do_without_windows \
472 "Windows was not found on your system, so I assume you want" \
473 "a Wine-only installation. Am I correct?"
474 conf_yesno_answer "(yes/no) "
475 if [ "$ANSWER" = 'no' ]
476 then {
477 conf_question high windows_not_found \
478 "Aborting install. Make sure your Windows partition is mounted and try again," \
479 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
480 exit 1
483 DOWINE=yes
485 else {
486 echo " found."
488 conf_question low do_without_windows \
489 "Windows was found on your system, and so we can use the Windows" \
490 "Drive as our Wine drive. You may, however, wish to create a clean" \
491 "Wine install anyways."
492 conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
493 if [ "$ANSWER" = 'yes' ]
494 then {
495 conf_reset_question windows_found
496 conf_question low windows_found \
497 "Created $LCONF using your existing Windows installation." \
498 "You probably want to review the file, though."
499 DOWINE=no
501 else {
502 DOWINE=yes
508 elif [ "$DOWINE" = 'auto' ]
509 then DOWINE=yes
512 elif [ "$DOWINE" = 'auto' ]
513 then
514 DOWINE=no
517 # setup a no-windows installation, if necessary
518 if [ "$DOWINE" = 'yes' ]
519 then {
520 # set an appropriate DCROOT
521 if [ `whoami` != 'root' ]
522 then DCROOT=~/c
523 else DCROOT=/c
526 conf_question low drivec_path \
527 "Configuring Wine without Windows." \
528 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
529 "start menu entries, and other things your applications may need to install." \
530 "Where would you like your fake C drive to be placed?"
531 while [ -z "$CROOT" ]
532 do {
533 conf_string_answer "(default is $DCROOT) "
534 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
535 if ! [ -d "$ANSWER" ]
536 then {
537 if mkdir -p "$ANSWER"
538 then CROOT="$ANSWER"
539 else
540 echo "Directory $ANSWER can't be created !"
541 conf_reset_question drivec_path
544 else CROOT="$ANSWER"
547 done
548 echo "Configuring Wine for a no-windows install in $CROOT..."
550 create_windows_directories
551 configure_wine_applications
553 # create $LCONF using the default config file $WINEINI
554 if [ "$DOLOCALCONF" = 'yes' ]
555 then {
556 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
557 conf_reset_question default_config
558 conf_question low default_config \
559 "Created $LCONF using default Wine configuration." \
560 "You probably want to review the file, though."
564 # now we really should install the registry
565 if [ "$DOREG" = 'auto' ]
566 then DOREG=yes
570 echo
572 #install the local config file $LCONF
573 if [ "$DOLOCALCONF" = 'yes' ]
574 then
575 if [ ! -w ~/.wine ]
576 then
577 mkdir ~/.wine
579 cp $TMPCONF $LCONF > /dev/null
580 else
581 DOREG=no
584 #install the global config file $GCONF
585 if [ "$DOGLOBALCONF" = 'yes' ]
586 then
587 if [ ! -f $sysconfdir ]
588 then
589 mkdir -p $sysconfdir
592 cp $TMPCONF $GCONF > /dev/null
595 # check whether we need to install default registry
596 # (not to be done if windows registry exists)
597 if [ "$DOREG" = 'auto' ]
598 then {
599 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
600 echo "Checking for real Windows registry..."
601 if [ -f "$CROOT/windows/system.dat" ]
602 then DOREG=no
603 elif [ -f "$CROOT/windows/system32/config/system" ]
604 then DOREG=no
605 elif [ -f "$CROOT/WINNT/system32/config/system" ]
606 then DOREG=no
607 else DOREG=yes
609 if [ "$DOREG" = 'yes' ]
610 then echo "Not found, default Wine registry will be installed."
611 else echo "Windows registry found, will not install default Wine registry."
613 echo
617 # install default registry entries
618 if [ "$DOREG" = 'yes' ]
619 then {
620 if [ "$BINDIST" = 'no' ]
621 then {
622 echo "Compiling regedit..."
623 (cd programs/regedit; make)
624 echo
627 echo "Preparing to install default Wine registry entries..."
629 # Make sure we are on a Windows drive
630 mv $LCONF $LCONF.orig
631 sed "s/\"Path\" = \"%HOME%\"$/\"Path\" = \"%PWD%\"/" $LCONF.orig> $LCONF
633 echo "Installing default Wine registry entries..."
634 echo
635 if ! $REGEDIT $DEFREG > /dev/null
636 then {
637 echo "Registry install failed."
638 mv $LCONF.orig $LCONF
639 conf_reset_question regedit_error
640 conf_question high regedit_error
641 exit 1
643 else {
644 echo
645 echo "Registry entries successfully installed."
646 mv $LCONF.orig $LCONF
649 if [ "$SYSREG" = 'auto' ]
650 then SYSREG=yes
655 # make root's registry global, if desired
656 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
657 then {
658 [ -d ~/.wine ] || mkdir ~/.wine
659 if ! [ -f $sysconfdir/wine.userreg ]
660 then {
661 echo "Linking root's user registry hive to the global registry..."
662 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
663 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
666 if ! [ -f $sysconfdir/wine.systemreg ]
667 then {
668 echo "Linking root's system registry hive to the global registry..."
669 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
670 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
676 # cleanup any temporary files that may remain
677 if [ -f $TMPCONF ]
678 then rm -f $TMPCONF
682 # it's a wrap
683 echo
684 echo "Installation complete for now. Good luck (this is still alpha software)."
685 echo "If you have problems with WINE, please read the documentation first,"
686 echo "as many kinds of potential problems are explained there."
688 exit 0