Added some stubs.
[wine/dcerpc.git] / tools / wineinstall
blobaa1c13e3f71aba1238b1abc3ed9b8d009233a2a9
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
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
72 #--- defaults (change these if you are a packager)
73 CONFARGS="--enable-opengl" # configure args, e.g. --prefix=/usr --sysconfdir=/etc
74 prefix=/usr/local # installation prefix
75 sysconfdir=$prefix/etc # where wine.conf and global registry is supposed to be
76 bindir=$prefix/bin # where winelib apps will be (or is) installed
77 libdir=$prefix/lib # where libwine.so will be (or is) installed
78 exdir=documentation/samples # where the example system.ini resides
79 GCONF=$sysconfdir/wine.conf # default path of the wine.conf global config file
80 LCONF=~/.wine/config # default path of the local config file
81 BINDIST=no # whether called from a binary package config script
82 DOGLOBALCONF=auto # whether to autogenerate wine.conf
83 DOLOCALCONF=auto # whether to autogenerate localconf
84 DOWCHK=auto # whether to autoconfigure existing-windows installation
85 DOWINE=auto # whether to autoconfigure no-windows installation
86 DOREG=auto # whether to install default registry
87 SYSREG=yes # whether to make root's registry global (system-default)
88 CONVCONF=no # whether we are converting an existing .winerc or not
90 # "make install" still installs the dlls into $libdir, but this may change in the future
91 # (DLLPATH should point to them if/when they are not in standard ld.so paths)
92 DLLPATH=$libdir/wine # default path of the dll .so files (except libwine.so)
94 # having the Wine debugger launched automatically will be a plus for us
95 DEBUGGER=$bindir/winedbg # the (installed) path of winedbg
96 HDEBUGGER=debugger/winedbg # the (non-installed) path of winedbg
98 # this is only for existing-windows installs
99 WINECONF=tools/wineconf # the path of wineconf perl script
101 # this is only for no-windows installs
102 WINEINI=$exdir/config # the path of default wine config file (also used by wineconf)
103 WININI=/dev/null # the path of default win.ini
104 SYSTEMINI=$exdir/system.ini # the path of default system.ini
105 REGAPI=programs/regapi/regapi # the path of regapi winelib application
106 DEFREG=winedefault.reg # the path of the registry file to be fed to regapi
107 # CROOT=/var/wine # the path of the fake Drive C (asks user if not set)
108 DEFCAT=cat # program to cat $DEFREG with (some packages need zcat)
109 #--- end of defaults
111 # temporary files used by the installer
112 TMPCONF=/tmp/wineinstall.conf
113 TMPREG=/tmp/wineinstall.reg
115 # functions
117 function std_sleep {
118 sleep 1
121 function conf_question {
122 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
123 # the first two parameters can be used by e.g. debconf in debian packages
124 # but here we just print the message
125 shift 2
126 echo
127 local LINE="$1"
128 while shift
129 do {
130 echo "$LINE"
131 LINE="$1"
133 done
136 function conf_reset_question {
137 # parameters: $1 = question-id
138 # this is used to flush any cached answers and "already-displayed" flags
139 shift # dummy command
142 function conf_yesno_answer {
143 unset ANSWER
144 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
145 do {
146 echo -n "$1"
147 read ANSWER
149 done
152 function conf_string_answer {
153 echo -n "$1"
154 read ANSWER
157 function create_windows_directories {
158 for tdir in "$CROOT/windows" "$CROOT/windows/system" \
159 "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
160 "$CROOT/Common Files" "$CROOT/Program Files" \
161 "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator"
162 do [ -d "$tdir" ] || mkdir "$tdir"
163 done
164 [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
165 [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
168 # startup...
170 echo "WINE Installer v0.71"
171 echo
173 if [ "$BINDIST" = 'no' ]
174 then {
176 if ! [ -f configure ]
177 then {
178 echo "You're running this from the wrong directory."
179 echo "Change to the Wine source's main directory and try again."
180 exit 1
184 # check whether RPM installed, and if it is, remove any old wine rpm.
185 hash rpm &>/dev/null
186 RET=$?
187 if [ $RET -eq 0 ]; then
188 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
189 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
190 conf_yesno_answer "(yes/no) "
191 if [ "$ANSWER" = 'yes' ]; then
192 echo Starting wine rpm removal...
193 rpm -e wine; RET=$?
194 if [ $RET -eq 0 ]; then
195 echo Done.
196 else
197 echo "FAILED. Probably you aren't installing as root."
198 echo "Expect problems (library conflicts with existing install etc.)."
200 else
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)"
203 echo "Have a nice day !"
204 exit 1
209 # check whether wine binary still available
210 if [ -n "`which 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."
214 std_sleep
217 # run the configure script, if necessary
219 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
220 then {
221 echo "I see that WINE has already been configured, so I'll skip that."
222 std_sleep
223 # load configure results
224 . ./config.cache
226 else {
227 echo "Running configure..."
228 echo
229 if ! ./configure -C $CONFARGS
230 then {
231 echo
232 echo "Configure failed, aborting install."
233 rm -f config.cache
234 exit 1
237 # load configure results
238 . ./config.cache
239 # make sure X was found
240 eval "$ac_cv_have_x"
241 if [ "$have_x" != "yes" ]
242 then {
243 echo "Install the X development headers and try again."
244 rm -f config.cache
245 exit 1
251 # now do the compilation
253 if [ -f wine ] && [ wine -nt config.cache ]
254 then {
255 echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
256 std_sleep
258 else {
259 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
260 echo "in the meantime..."
261 echo
262 std_sleep
263 if ! { make depend && make; }
264 then {
265 echo
266 echo "Compilation failed, aborting install."
267 exit 1
270 echo
274 # and installation, if root
276 if [ `whoami` != 'root' ]
277 then {
278 echo "You aren't root, so I'll skip the make install."
280 # setup to run from current directory
281 DLLPATH="$PWD/dlls"
282 if [ -z "$LD_LIBRARY_PATH" ]
283 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
284 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
286 export LD_LIBRARY_PATH
287 DEBUGGER="$PWD/$HDEBUGGER"
288 echo
289 echo "NOTE! To run Wine without installing, you must set the environment variable"
290 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
291 echo "in your logon scripts."
292 echo
294 # see if wine is installed on the users system, if not prompt them
295 # and then exit
296 if [ ! `which wine` ]
297 then
298 echo "Could not find wine on your system. Run wineinstall as root to install wine"
299 echo "before re-running wineinstall as a user."
300 echo
301 echo "Exiting wineinstall"
302 exit 1;
305 else {
306 echo "Now installing binaries onto the system..."
307 echo
308 std_sleep
309 if ! make install
310 then {
311 echo
312 echo "Installation failed, aborting."
313 exit 1
316 if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
317 then {
318 echo
319 echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
320 echo "$libdir" >>/etc/ld.so.conf
321 echo "Re-running ldconfig..."
322 eval "$ac_cv_path_LDCONFIG"
329 fi # BINDIST
331 # now check whether we should generate wine.conf
332 if [ -z "$DOGLOBALCONF" ]
333 then
334 DOGLOBALCONF=auto
337 if [ "$DOGLOBALCONF" = 'auto' ]
338 then {
339 # see if we already have a system wine.conf
340 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
341 then
342 DOGLOBALCONF=no
343 echo "Creation of a global config file is not supported in wineinstall at this"
344 echo "time. When the configuration architecture is cleaned up this functionality"
345 echo "will be restored to wineinstall."
346 echo
351 if [ "$DOLOCALCONF" = 'auto' ]
352 then {
353 # see if the user is root, if so, explicitly ask them if they want a
354 # local config file
355 if [ `whoami` = 'root' ]
356 then
357 echo "You are running as root. Do you want a local config file,"
358 echo "file, ~/.wine/config, created?"
359 conf_yesno_answer "(yes/no) "
360 DOLOCALCONF="$ANSWER"
361 else
362 echo "Create local config file ~/.wine/config?"
363 conf_yesno_answer "(yes/no) "
364 echo
365 DOLOCALCONF="$ANSWER"
366 if [ "$ANSWER" = 'no' ]
367 then
368 conf_question high need_root \
369 "Aborting install. Try again as root to generate a system wine.conf."
370 exit 1
374 if [ -f "$LCONF" ]
375 then
376 echo "Found existing $LCONF, if you continue this file will be"
377 echo "overwritten. Continue running wineinstall?"
378 conf_yesno_answer "(yes/no) "
379 echo
380 if [ "$ANSWER" = 'no' ]
381 then
382 echo "Exiting wineinstall"
383 exit 1
389 # generate $TMPCONF from existing windows install, if any
390 if [ "$DOLOCALCONF" = 'yes' ]
391 then {
392 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
393 then {
394 echo -n "Searching for an existing Windows installation..."
395 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
396 then {
397 rm -f $TMPCONF $TMPREG > /dev/null
399 echo " not found. (no matching /etc/fstab mount entry found)"
400 conf_question low do_without_windows \
401 "Windows was not found on your system, so I assume you want" \
402 "a Wine-only installation. Am I correct?"
403 conf_yesno_answer "(yes/no) "
404 if [ "$ANSWER" = 'no' ]
405 then {
406 conf_question high windows_not_found \
407 "Aborting install. Make sure your Windows partition is mounted and try again," \
408 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
409 exit 1
412 DOWINE=yes
414 else {
415 echo " found."
417 conf_reset_question windows_found
418 conf_question low windows_found \
419 "Created $LCONF using your existing Windows installation." \
420 "You probably want to review the file, though."
421 DOWINE=no
425 elif [ "$DOWINE" = 'auto' ]
426 then DOWINE=yes
429 elif [ "$DOWINE" = 'auto' ]
430 then
431 DOWINE=no
434 # setup a no-windows installation, if necessary
435 if [ "$DOWINE" = 'yes' ]
436 then {
437 # set an appropriate DCROOT
438 if [ `whoami` != 'root' ]
439 then DCROOT=~/c
440 else DCROOT=/c
443 if [ -f ~/.winerc ]
444 then {
445 conf_question medium convert_config \
446 "I found the old version Wine config file, .winerc, in your " \
447 "home directory. I can convert this to the new format or use the" \
448 "new default Wine config file. Convert?"
449 conf_yesno_answer "(yes/no) "
450 if [ "$ANSWER" = 'yes' ]
451 then {
452 WINEINI=~/.winerc
453 CONVCONF=yes
457 else {
459 conf_question low drivec_path \
460 "Configuring Wine without Windows." \
461 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
462 "start menu entries, and other things your applications may need to install." \
463 "Where would you like your fake C drive to be placed?"
464 while [ -z "$CROOT" ]
465 do {
466 conf_string_answer "(default is $DCROOT) "
467 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
468 if ! [ -d "$ANSWER" ]
469 then {
470 if mkdir -p "$ANSWER"
471 then CROOT="$ANSWER"
472 else
473 echo "Directory $ANSWER can't be created !"
474 conf_reset_question drivec_path
477 else CROOT="$ANSWER"
480 done
481 echo "Configuring Wine for a no-windows install in $CROOT..."
483 create_windows_directories
487 # create $LCONF using the default config file $WINEINI
488 if [ "$DOLOCALCONF" = 'yes' ] && [ "$CONVCONF" = 'no' ]
489 then {
490 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
491 conf_reset_question default_config
492 conf_question low default_config \
493 "Created $LCONF using default Wine configuration." \
494 "You probably want to review the file, though."
498 # now we really should install the registry
499 if [ "$DOREG" = 'auto' ]
500 then DOREG=yes
504 echo
506 #install the local config file $LCONF
507 if [ "$DOLOCALCONF" = 'yes' ]
508 then
509 if [ ! -w ~/.wine ]
510 then
511 mkdir ~/.wine
514 if [ "$CONVCONF" = 'no' ]
515 then
516 cp $TMPCONF $LCONF > /dev/null
518 else
519 DOREG=no
522 #install the global config file $GCONF
523 if [ "$DOGLOBALCONF" = 'yes' ]
524 then
525 if [ ! -f $sysconfdir ]
526 then
527 mkdir -p $sysconfdir
530 cp $TMPCONF $GCONF > /dev/null
533 # check whether we need to install default registry
534 # (not to be done if windows registry exists)
535 if [ "$DOREG" = 'auto' ]
536 then {
537 echo "Checking for real Windows registry..."
538 if [ -f "$CROOT/windows/system.dat" ]
539 then DOREG=no
540 elif [ -f "$CROOT/windows/system32/config/system" ]
541 then DOREG=no
542 else DOREG=yes
544 if [ "$DOREG" = 'yes' ]
545 then echo "Not found, default Wine registry will be installed."
546 else echo "Windows registry found, will not install default Wine registry."
548 echo
552 # install default registry entries
553 if [ "$DOREG" = 'yes' ]
554 then {
555 if [ "$BINDIST" = 'no' ]
556 then {
557 echo "Compiling regapi..."
558 (cd programs/regapi; make)
559 echo
562 echo "Preparing to install default Wine registry entries..."
564 # edit config files so we don't have to run regapi under X
565 if [ "$CONVCONF" = 'yes' ]
566 then
567 mv $WINEINI $WINEINI.new
568 sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $WINEINI.new > $WINEINI
569 else
570 mv $LCONF $LCONF.new
571 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"ttydrv\"/" $LCONF.new > $LCONF
574 # create a temporary wineinstall.reg with fixed debugger path
575 $DEFCAT $DEFREG | sed "s|debugger/winedbg|${DEBUGGER}|" > $TMPREG
577 echo "Installing default Wine registry entries..."
578 echo
579 if ! $REGAPI setValue < $TMPREG > /dev/null
580 then {
581 rm -f $TMPREG
582 echo "Registry install failed."
583 conf_reset_question regapi_error
584 conf_question high regapi_error
585 exit 1
587 else {
588 # if we are converting from a .winerc file, running regapi once
589 # will ONLY convert .winerc -> ~/.wine/config, it will not import the
590 # registry data. so if we are converting we need to run regapi twice
591 if [ "$CONVCONF" = 'yes' ]
592 then
593 if ! $REGAPI setValue < $TMPREG > /dev/null
594 then
595 rm -f $TMPREG
596 echo "Registry install failed."
597 conf_reset_question regapi_error
598 conf_question high regapi_error
599 exit 1
600 else
601 echo
602 echo "Registry entries successfully installed."
604 else
605 echo
606 echo "Registry entries successfully installed."
610 rm -f $TMPREG
611 if [ "$SYSREG" = 'auto' ]
612 then SYSREG=yes
615 # if we converted we need to change the graphics driver back and
616 # restore the original .winerc file
617 if [ "$CONVCONF" = 'yes' ]
618 then
619 mv $WINEINI.new $WINEINI
622 sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"x11drv\"/" $LCONF > $LCONF.new
623 mv $LCONF.new $LCONF
627 # make root's registry global, if desired
628 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
629 then {
630 [ -d ~/.wine ] || mkdir ~/.wine
631 if ! [ -f $sysconfdir/wine.userreg ]
632 then {
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 ]
639 then {
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
649 if [ -f $TMPCONF ]
650 then rm -f $TMPCONF
652 if [ -f $TMPREG ]
653 then rm -f $TMPREG
657 # it's a wrap
658 echo
659 echo "Installation complete for now. Good luck (this is still alpha software)."
660 echo "If you have problems with WINE, please read the documentation first,"
661 echo "as many kinds of potential problems are explained there."
663 exit 0