Added a new flag to wrc, to be used to assess translations
[wine.git] / tools / wineinstall
blob1856cd1bdd6f07a4da9900bc74249d987e8846ec
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"
148 link_app winebrowser "$CROOT/windows/winebrowser.exe"
151 # startup...
153 echo "WINE Installer v0.74"
154 echo
156 if [ "$BINDIST" = 'no' ]
157 then {
159 if ! [ -f configure ]
160 then {
161 if [ -f ../configure ]
162 then {
163 pushd ..
165 else {
166 echo "You're running this from the wrong directory."
167 echo "Change to the Wine source's main directory and try again."
168 exit 1
174 if [ `whoami` == 'root' ]
175 then {
176 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
177 echo "Aborting."
178 exit 1
182 if [ ! -w . ]
183 then {
184 echo "The source directory is not writable. You probably extracted the sources as root."
185 echo "You should remove the source tree and extract it again as a normal user."
186 exit 1
190 # check whether RPM installed, and if it is, remove any old wine rpm.
191 hash rpm &>/dev/null
192 RET=$?
193 if [ $RET -eq 0 ]; then
194 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
195 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
196 conf_yesno_answer "(yes/no) "
197 if [ "$ANSWER" = 'yes' ]; then
198 echo "We need to remove the rpm as root, please enter your root password"
199 echo
200 echo Starting wine rpm removal...
201 su -c "rpm -e wine; RET=$?"
202 if [ $RET -eq 0 ]; then
203 echo Done.
204 else
205 echo "FAILED. Probably you aren't installing as root."
206 echo "Expect problems (library conflicts with existing install etc.)."
208 else
209 echo "Sorry, I won't install Wine when an rpm version is still installed."
210 echo "(Wine support suffered from way too many conflicts between RPM"
211 echo "and source installs)"
212 echo "Have a nice day !"
213 exit 1
218 # check whether wine binary still available
219 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
220 echo "Warning !! wine binary (still) found, which may indicate"
221 echo "a (conflicting) previous installation."
222 echo "You might want to abort and uninstall Wine first."
223 std_sleep
226 # run the configure script, if necessary
228 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
229 then {
230 echo
231 echo "I see that WINE has already been configured, so I'll skip that."
232 std_sleep
233 # load configure results
234 . ./config.cache
236 else {
237 echo "Running configure..."
238 echo
239 if ! ./configure -C $CONFARGS --prefix=$prefix
240 then {
241 echo
242 echo "Configure failed, aborting install."
243 rm -f config.cache
244 exit 1
247 # load configure results
248 . ./config.cache
249 # make sure X was found
250 eval "$ac_cv_have_x"
251 if [ "$have_x" != "yes" ]
252 then {
253 echo "Install the X development headers and try again."
254 rm -f config.cache
255 exit 1
261 # now do the compilation and install, we need to always do this because we
262 # don't want the 'make install' command we might run to run 'make' as root
263 if [ `whoami` != 'root' ]
264 then {
265 # ask the user if they want to build and install wine
266 echo
267 echo "We need to install wine as root user, do you want us to build wine,"
268 echo "'su root' and install Wine? Enter 'no' to continue without installing"
269 conf_yesno_answer "(yes/no) "
270 ROOTINSTALL="$ANSWER"
272 if [ "$ROOTINSTALL" = "yes" ]
273 then {
274 # start out with the basic command
275 sucommand="make install"
277 # if the user doesn't have $libdir in their ld.so.conf add this
278 # to our sucommand string
279 if [ -f /etc/ld.so.conf ]
280 then
281 if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
282 then {
283 echo
284 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
285 echo "when we perform the install..."
286 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
289 # run ldconfig always just in case some updated files don't get linked
290 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
293 fi # [ "$ROOTINSTALL" = "yes" ]
295 echo
297 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
298 echo "in the meantime..."
299 echo
300 std_sleep
302 # try to just make wine, if this fails 'make depend' and try to remake
303 if ! { make; }
304 then {
305 if ! { make depend && make; }
306 then {
307 echo
308 echo "Compilation failed, aborting install."
309 exit 1
315 if [ "$ROOTINSTALL" = "yes" ]
316 then {
317 echo
319 echo "Performing 'make install' as root to install binaries, enter root password"
321 std_sleep
323 if ! su root -c "$sucommand"
324 then {
325 if ! su root -c "$sucommand"
326 then {
327 echo
328 echo "Either you entered an incorrect password or we failed to"
329 echo "run '$sucommand' correctly."
330 echo "If you didn't enter an incorrect password then please"
331 echo "report this error and any steps to possibly reproduce it to"
332 echo "http://bugs.winehq.org/"
333 echo
334 echo "Installation failed, aborting."
335 exit 1
341 echo
343 # see if wine is installed on the users system, if not prompt them
344 # and then exit
345 if [ ! `which wine` ]
346 then
347 echo "Could not find wine on your system. Run wineinstall as root to install wine"
348 echo "before re-running wineinstall as a user."
349 echo
350 echo "Exiting wineinstall"
351 exit 1;
354 WINEINSTALLED=yes
356 else {
357 # user didn't want to install wine so tell them about running from the
358 # current directory and set some stuff up for them
360 # setup to run from current directory
361 DLLPATH="$PWD/dlls"
362 if [ -z "$LD_LIBRARY_PATH" ]
363 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
364 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
366 export LD_LIBRARY_PATH
367 echo
368 echo "NOTE! To run Wine without installing, you must set the environment variable"
369 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
370 echo "in your logon scripts."
371 echo
373 WINEINSTALLED=no
375 fi # [ "$ROOTINSTALL" = "yes" ]
377 fi # [ `whoami` != 'root' ]
380 fi # BINDIST
382 # now check whether we should generate wine.conf
383 if [ -z "$DOGLOBALCONF" ]
384 then
385 DOGLOBALCONF=auto
388 if [ "$DOGLOBALCONF" = 'auto' ]
389 then {
390 # see if we already have a system wine.conf
391 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
392 then
393 DOGLOBALCONF=no
394 echo "Creation of a global config file is not supported in wineinstall at this"
395 echo "time. When the configuration architecture is cleaned up this functionality"
396 echo "will be restored to wineinstall."
397 echo
402 if [ "$DOLOCALCONF" = 'auto' ]
403 then {
404 # see if the user is root, if so, explicitly ask them if they want a
405 # local config file
406 if [ `whoami` = 'root' ]
407 then
408 echo "You are running as root. Do you want a local config file,"
409 echo "file, ~/.wine/config, created?"
410 conf_yesno_answer "(yes/no) "
411 DOLOCALCONF="$ANSWER"
412 else
413 # if the user has an existing config file ask them if they want us to
414 # overwrite it, otherwise just ask them if they want to create one
415 if [ -f "$LCONF" ]
416 then
417 echo "Found existing $LCONF, do you want to overwrite this"
418 echo "existing Wine configuration file?"
419 conf_yesno_answer "(yes/no) "
420 DOLOCALCONF="$ANSWER"
421 echo
422 if [ "$ANSWER" = "yes" ]
423 then
425 echo "Would you like to make a backup of this old config file?"
426 conf_yesno_answer "(yes/no) "
427 echo
428 if [ "$ANSWER" = "yes" ]
429 then
431 echo "Renaming $LCONF to $LCONF.old"
432 mv -f "$LCONF" "$LCONF.old"
433 echo
438 else
440 echo "Create local config file ~/.wine/config?"
441 conf_yesno_answer "(yes/no) "
442 DOLOCALCONF="$ANSWER"
443 echo
444 if [ "$ANSWER" = 'no' ]
445 then
446 conf_question high need_root \
447 "Aborting install. Try again as root to generate a system wine.conf."
448 exit 1
456 # generate $TMPCONF from existing windows install, if any
457 if [ "$DOLOCALCONF" = 'yes' ]
458 then {
459 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
460 then {
461 echo -n "Searching for an existing Windows installation..."
462 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
463 then {
464 rm -f $TMPCONF > /dev/null
466 echo " not found. (no matching /etc/fstab mount entry found)"
467 conf_question low do_without_windows \
468 "Windows was not found on your system, so I assume you want" \
469 "a Wine-only installation. Am I correct?"
470 conf_yesno_answer "(yes/no) "
471 if [ "$ANSWER" = 'no' ]
472 then {
473 conf_question high windows_not_found \
474 "Aborting install. Make sure your Windows partition is mounted and try again," \
475 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
476 exit 1
479 DOWINE=yes
481 else {
482 echo " found."
484 conf_question low do_without_windows \
485 "Windows was found on your system, and so we can use the Windows" \
486 "Drive as our Wine drive. You may, however, wish to create a clean" \
487 "Wine install anyways."
488 conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
489 if [ "$ANSWER" = 'yes' ]
490 then {
491 conf_reset_question windows_found
492 conf_question low windows_found \
493 "Created $LCONF using your existing Windows installation." \
494 "You probably want to review the file, though."
495 DOWINE=no
497 else {
498 DOWINE=yes
504 elif [ "$DOWINE" = 'auto' ]
505 then DOWINE=yes
508 elif [ "$DOWINE" = 'auto' ]
509 then
510 DOWINE=no
513 # setup a no-windows installation, if necessary
514 if [ "$DOWINE" = 'yes' ]
515 then {
516 # set an appropriate DCROOT
517 if [ `whoami` != 'root' ]
518 then DCROOT=~/c
519 else DCROOT=/c
522 conf_question low drivec_path \
523 "Configuring Wine without Windows." \
524 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
525 "start menu entries, and other things your applications may need to install." \
526 "Where would you like your fake C drive to be placed?"
527 while [ -z "$CROOT" ]
528 do {
529 conf_string_answer "(default is $DCROOT) "
530 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
531 if ! [ -d "$ANSWER" ]
532 then {
533 if mkdir -p "$ANSWER"
534 then CROOT="$ANSWER"
535 else
536 echo "Directory $ANSWER can't be created !"
537 conf_reset_question drivec_path
540 else CROOT="$ANSWER"
543 done
544 echo "Configuring Wine for a no-windows install in $CROOT..."
546 create_windows_directories
547 configure_wine_applications
549 # create $LCONF using the default config file $WINEINI
550 if [ "$DOLOCALCONF" = 'yes' ]
551 then {
552 sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
553 conf_reset_question default_config
554 conf_question low default_config \
555 "Created $LCONF using default Wine configuration." \
556 "You probably want to review the file, though."
560 # now we really should install the registry
561 if [ "$DOREG" = 'auto' ]
562 then DOREG=yes
566 echo
568 #install the local config file $LCONF
569 if [ "$DOLOCALCONF" = 'yes' ]
570 then
571 if [ ! -w ~/.wine ]
572 then
573 mkdir ~/.wine
575 cp $TMPCONF $LCONF > /dev/null
576 else
577 DOREG=no
580 #install the global config file $GCONF
581 if [ "$DOGLOBALCONF" = 'yes' ]
582 then
583 if [ ! -f $sysconfdir ]
584 then
585 mkdir -p $sysconfdir
588 cp $TMPCONF $GCONF > /dev/null
591 # check whether we need to install default registry
592 # (not to be done if windows registry exists)
593 if [ "$DOREG" = 'auto' ]
594 then {
595 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
596 echo "Checking for real Windows registry..."
597 if [ -f "$CROOT/windows/system.dat" ]
598 then DOREG=no
599 elif [ -f "$CROOT/windows/system32/config/system" ]
600 then DOREG=no
601 elif [ -f "$CROOT/WINNT/system32/config/system" ]
602 then DOREG=no
603 else DOREG=yes
605 if [ "$DOREG" = 'yes' ]
606 then echo "Not found, default Wine registry will be installed."
607 else echo "Windows registry found, will not install default Wine registry."
609 echo
613 # install default registry entries
614 if [ "$DOREG" = 'yes' ]
615 then {
616 if [ "$BINDIST" = 'no' ]
617 then {
618 echo "Compiling regedit..."
619 (cd programs/regedit; make)
620 echo
623 echo "Preparing to install default Wine registry entries..."
625 # Make sure we are on a Windows drive
626 mv $LCONF $LCONF.orig
627 sed "s/\"Path\" = \"%HOME%\"$/\"Path\" = \"%PWD%\"/" $LCONF.orig> $LCONF
629 echo "Installing default Wine registry entries..."
630 echo
631 if ! $REGEDIT $DEFREG > /dev/null
632 then {
633 echo "Registry install failed."
634 mv $LCONF.orig $LCONF
635 conf_reset_question regedit_error
636 conf_question high regedit_error
637 exit 1
639 else {
640 echo
641 echo "Registry entries successfully installed."
642 mv $LCONF.orig $LCONF
645 if [ "$SYSREG" = 'auto' ]
646 then SYSREG=yes
651 # make root's registry global, if desired
652 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
653 then {
654 [ -d ~/.wine ] || mkdir ~/.wine
655 if ! [ -f $sysconfdir/wine.userreg ]
656 then {
657 echo "Linking root's user registry hive to the global registry..."
658 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
659 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
662 if ! [ -f $sysconfdir/wine.systemreg ]
663 then {
664 echo "Linking root's system registry hive to the global registry..."
665 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
666 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
672 # cleanup any temporary files that may remain
673 if [ -f $TMPCONF ]
674 then rm -f $TMPCONF
678 # it's a wrap
679 echo
680 echo "Installation complete for now. Good luck (this is still alpha software)."
681 echo "If you have problems with WINE, please read the documentation first,"
682 echo "as many kinds of potential problems are explained there."
684 exit 0