Implementation of IPersistFile::IsDirty().
[wine.git] / tools / wineinstall
blobc122b4e52b0a9a59f1db2689f4079465bf265033
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 # 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)
48 #--- end of defaults
50 # temporary files used by the installer
51 TMPCONF=/tmp/wineinstall.conf
53 # functions
55 function std_sleep {
56 sleep 1
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
63 shift 2
64 echo
65 local LINE="$1"
66 while shift
67 do {
68 echo "$LINE"
69 LINE="$1"
71 done
74 function conf_reset_question {
75 # parameters: $1 = question-id
76 # this is used to flush any cached answers and "already-displayed" flags
77 shift # dummy command
80 function conf_yesno_answer {
81 unset ANSWER
82 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
83 do {
84 echo -n "$1"
85 read ANSWER
87 done
90 function conf_string_answer {
91 echo -n "$1"
92 read 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"
103 done
104 cp $INFSCRIPT "$CROOT/windows/system/wine.inf"
107 #creates symbolic link in windows directory to installed winelib application
108 #parameters:
109 # - name of the installed winelib application
110 # - full path to application in the winelib directory
111 function link_app {
112 if [ "$WINEINSTALLED" = 'no' ]
113 then {
114 ln -sf $PWD/programs/$1/$1.exe.so $2
116 else {
117 ln -sf $libdir/wine/$1.exe.so $2
122 #puts windows applications replacements to windows directories,
123 #configures them
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"
143 # startup...
145 echo "WINE Installer v0.74"
146 echo
148 if [ "$BINDIST" = 'no' ]
149 then {
151 if ! [ -f configure ]
152 then {
153 if [ -f ../configure ]
154 then {
155 pushd ..
157 else {
158 echo "You're running this from the wrong directory."
159 echo "Change to the Wine source's main directory and try again."
160 exit 1
166 if [ `whoami` = 'root' ]
167 then {
168 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
169 echo "Aborting."
170 exit 1
174 if [ ! -w . ]
175 then {
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."
178 exit 1
182 # check whether RPM installed, and if it is, remove any old wine rpm.
183 hash rpm &>/dev/null
184 RET=$?
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"
191 echo
192 echo Starting wine rpm removal...
193 su -c "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 between RPM"
203 echo "and source installs)"
204 echo "Have a nice day !"
205 exit 1
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."
215 std_sleep
218 # run the configure script, if necessary
220 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
221 then {
222 echo
223 echo "I see that WINE has already been configured, so I'll skip that."
224 std_sleep
225 # load configure results
226 . ./config.cache
228 else {
229 echo "Running configure..."
230 echo
231 if ! ./configure -C $CONFARGS --prefix=$prefix
232 then {
233 echo
234 echo "Configure failed, aborting install."
235 rm -f config.cache
236 exit 1
239 # load configure results
240 . ./config.cache
241 # make sure X was found
242 eval "$ac_cv_have_x"
243 if [ "$have_x" != "yes" ]
244 then {
245 echo "Install the X development headers and try again."
246 rm -f config.cache
247 exit 1
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' ]
256 then {
257 # ask the user if they want to build and install wine
258 echo
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" ]
265 then {
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 ]
272 then
273 if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
274 then {
275 echo
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" ]
287 echo
289 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
290 echo "in the meantime..."
291 echo
292 std_sleep
294 # try to just make wine, if this fails 'make depend' and try to remake
295 if ! { make; }
296 then {
297 if ! { make depend && make; }
298 then {
299 echo
300 echo "Compilation failed, aborting install."
301 exit 1
307 if [ "$ROOTINSTALL" = "yes" ]
308 then {
309 echo
311 echo "Performing 'make install' as root to install binaries, enter root password"
313 std_sleep
315 if ! su root -c "$sucommand"
316 then {
317 if ! su root -c "$sucommand"
318 then {
319 echo
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/"
325 echo
326 echo "Installation failed, aborting."
327 exit 1
333 echo
335 # see if wine is installed on the users system, if not prompt them
336 # and then exit
337 if [ ! `which wine` ]
338 then
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."
341 echo
342 echo "Exiting wineinstall"
343 exit 1;
346 WINEINSTALLED=yes
348 else {
349 WINEINSTALLED=no
351 fi # [ "$ROOTINSTALL" = "yes" ]
353 fi # [ `whoami` != 'root' ]
356 fi # BINDIST
358 # now check whether we should generate wine.conf
359 if [ -z "$DOGLOBALCONF" ]
360 then
361 DOGLOBALCONF=auto
364 if [ "$DOGLOBALCONF" = 'auto' ]
365 then {
366 # see if we already have a system wine.conf
367 if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
368 then
369 DOGLOBALCONF=no
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."
373 echo
378 if [ "$DOLOCALCONF" = 'auto' ]
379 then {
380 # see if the user is root, if so, explicitly ask them if they want a
381 # local config file
382 if [ `whoami` = 'root' ]
383 then
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"
388 else
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
391 if [ -f "$LCONF" ]
392 then
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"
397 echo
398 if [ "$ANSWER" = "yes" ]
399 then
401 echo "Would you like to make a backup of this old config file?"
402 conf_yesno_answer "(yes/no) "
403 echo
404 if [ "$ANSWER" = "yes" ]
405 then
407 echo "Renaming $LCONF to $LCONF.old"
408 mv -f "$LCONF" "$LCONF.old"
409 echo
414 else
416 echo "Create local config file ~/.wine/config?"
417 conf_yesno_answer "(yes/no) "
418 DOLOCALCONF="$ANSWER"
419 echo
420 if [ "$ANSWER" = 'no' ]
421 then
422 conf_question high need_root \
423 "Aborting install. Try again as root to generate a system wine.conf."
424 exit 1
432 # generate $TMPCONF from existing windows install, if any
433 if [ "$DOLOCALCONF" = 'yes' ]
434 then {
435 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
436 then {
437 echo -n "Searching for an existing Windows installation..."
438 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
439 then {
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' ]
448 then {
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."
452 exit 1
455 DOWINE=yes
457 else {
458 echo " found."
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' ]
466 then {
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."
471 DOWINE=no
473 else {
474 DOWINE=yes
480 elif [ "$DOWINE" = 'auto' ]
481 then DOWINE=yes
484 elif [ "$DOWINE" = 'auto' ]
485 then
486 DOWINE=no
489 # setup a no-windows installation, if necessary
490 if [ "$DOWINE" = 'yes' ]
491 then {
492 # set an appropriate DCROOT
493 if [ `whoami` != 'root' ]
494 then DCROOT=~/c
495 else DCROOT=/c
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" ]
504 do {
505 conf_string_answer "(default is $DCROOT) "
506 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
507 if ! [ -d "$ANSWER" ]
508 then {
509 if mkdir -p "$ANSWER"
510 then CROOT="$ANSWER"
511 else
512 echo "Directory $ANSWER can't be created !"
513 conf_reset_question drivec_path
516 else CROOT="$ANSWER"
519 done
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' ]
527 then {
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' ]
538 then DOREG=yes
542 echo
544 #install the local config file $LCONF
545 if [ "$DOLOCALCONF" = 'yes' ]
546 then
547 if [ ! -w ~/.wine ]
548 then
549 mkdir ~/.wine
551 cp $TMPCONF $LCONF > /dev/null
552 else
553 DOREG=no
556 #install the global config file $GCONF
557 if [ "$DOGLOBALCONF" = 'yes' ]
558 then
559 if [ ! -f $sysconfdir ]
560 then
561 mkdir -p $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' ]
570 then {
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" ]
574 then DOREG=no
575 elif [ -f "$CROOT/windows/system32/config/system" ]
576 then DOREG=no
577 elif [ -f "$CROOT/WINNT/system32/config/system" ]
578 then DOREG=no
579 else DOREG=yes
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."
585 echo
589 # install default registry entries
590 if [ "$DOREG" = 'yes' ]
591 then {
592 if [ "$BINDIST" = 'no' ]
593 then {
594 echo "Compiling rundll32..."
595 (cd programs/rundll32; make)
596 echo
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..."
606 echo
607 if ! $RUNDLL32 setupapi.dll,InstallHinfSection DefaultInstall 128 $INFSCRIPT > /dev/null
608 then {
609 echo "Registry install failed."
610 mv $LCONF.orig $LCONF
611 conf_reset_question regedit_error
612 conf_question high regedit_error
613 exit 1
615 else {
616 echo
617 echo "Registry entries successfully installed."
618 mv $LCONF.orig $LCONF
621 if [ "$SYSREG" = 'auto' ]
622 then SYSREG=yes
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
654 # it's a wrap
655 echo
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."
660 exit 0