Support for regular files (as opposed to directories).
[wine/multimedia.git] / tools / wineinstall
bloba4610c4a4b1a4046c16b421c210f1004d1195954
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 LCONF=~/.wine/config # default path of the local config file
30 BINDIST=no # whether called from a binary package config script
31 DOLOCALCONF=auto # whether to autogenerate localconf
32 DOWCHK=auto # whether to autoconfigure existing-windows installation
33 DOWINE=auto # whether to autoconfigure no-windows installation
34 DOREG=auto # whether to install default registry
35 DOAPP=auto # whether to install applications, distributed with Wine
36 SYSREG=yes # whether to make root's registry global (system-default)
38 # this is only for existing-windows installs
39 WINECONF=tools/wineconf # path to the wineconf perl script
41 # this is only for no-windows installs
42 WINEINI=$exdir/config # path to the default wine config file (also used by wineconf)
43 # CROOT=/var/wine # path of the fake Drive C (asks user if not set)
44 #--- end of defaults
46 # temporary files used by the installer
47 TMPCONF=/tmp/wineinstall.conf
49 # functions
51 function std_sleep {
52 sleep 1
55 function conf_question {
56 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
57 # the first two parameters can be used by e.g. debconf in debian packages
58 # but here we just print the message
59 shift 2
60 echo
61 local LINE="$1"
62 while [ $# -gt 0 ] && shift
63 do {
64 echo "$LINE"
65 LINE="$1"
67 done
70 function conf_reset_question {
71 # parameters: $1 = question-id
72 # this is used to flush any cached answers and "already-displayed" flags
73 shift # dummy command
76 function conf_yesno_answer {
77 unset ANSWER
78 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
79 do {
80 echo -n "$1"
81 read ANSWER
83 done
86 function conf_string_answer {
87 echo -n "$1"
88 read ANSWER
91 # startup...
93 echo "WINE Installer v0.74"
94 echo
96 if [ "$BINDIST" = 'no' ]
97 then {
99 if ! [ -f configure ]
100 then {
101 if [ -f ../configure ]
102 then {
103 pushd ..
105 else {
106 echo "You're running this from the wrong directory."
107 echo "Change to the Wine source's main directory and try again."
108 exit 1
114 if [ `whoami` = 'root' ]
115 then {
116 echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
117 echo "Aborting."
118 exit 1
122 if [ ! -w . ]
123 then {
124 echo "The source directory is not writable. You probably extracted the sources as root."
125 echo "You should remove the source tree and extract it again as a normal user."
126 exit 1
130 # check whether RPM installed, and if it is, remove any old wine rpm.
131 hash rpm &>/dev/null
132 RET=$?
133 if [ $RET -eq 0 ]; then
134 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
135 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
136 conf_yesno_answer "(yes/no) "
137 if [ "$ANSWER" = 'yes' ]; then
138 echo "We need to remove the rpm as root, please enter your root password"
139 echo
140 echo Starting wine rpm removal...
141 su -c "rpm -e wine; RET=$?"
142 if [ $RET -eq 0 ]; then
143 echo Done.
144 else
145 echo "FAILED. Probably you aren't installing as root."
146 echo "Expect problems (library conflicts with existing install etc.)."
148 else
149 echo "Sorry, I won't install Wine when an rpm version is still installed."
150 echo "(Wine support suffered from way too many conflicts between RPM"
151 echo "and source installs)"
152 echo "Have a nice day !"
153 exit 1
158 # check whether wine binary still available
159 if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; then
160 echo "Warning !! wine binary (still) found, which may indicate"
161 echo "a (conflicting) previous installation."
162 echo "You might want to abort and uninstall Wine first."
163 echo "(If you previously tried to install from source manually, "
164 echo "run 'make uninstall' from the wine root directory)"
165 std_sleep
168 # run the configure script, if necessary
170 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
171 then {
172 echo
173 echo "I see that WINE has already been configured, so I'll skip that."
174 std_sleep
175 # load configure results
176 . ./config.cache
178 else {
179 echo "Running configure..."
180 echo
181 if ! ./configure -C $CONFARGS --prefix=$prefix
182 then {
183 echo
184 echo "Configure failed, aborting install."
185 rm -f config.cache
186 exit 1
189 # load configure results
190 . ./config.cache
191 # make sure X was found
192 eval "$ac_cv_have_x"
193 if [ "$have_x" != "yes" ]
194 then {
195 echo "Install the X development headers and try again."
196 rm -f config.cache
197 exit 1
203 # now do the compilation and install, we need to always do this because we
204 # don't want the 'make install' command we might run to run 'make' as root
205 if [ `whoami` != 'root' ]
206 then {
207 # ask the user if they want to build and install wine
208 echo
209 echo "We need to install wine as root user, do you want us to build wine,"
210 echo "'su root' and install Wine? Enter 'no' to continue without installing"
211 conf_yesno_answer "(yes/no) "
212 ROOTINSTALL="$ANSWER"
214 if [ "$ROOTINSTALL" = "yes" ]
215 then {
216 # start out with the basic command
217 sucommand="make install"
219 # if the user doesn't have $libdir in their ld.so.conf add this
220 # to our sucommand string
221 if [ -f /etc/ld.so.conf ]
222 then
223 if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
224 then {
225 echo
226 echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
227 echo "when we perform the install..."
228 sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
231 # run ldconfig always just in case some updated files don't get linked
232 sucommand="$sucommand;$ac_cv_path_LDCONFIG"
235 fi # [ "$ROOTINSTALL" = "yes" ]
237 echo
239 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
240 echo "in the meantime..."
241 echo
242 std_sleep
244 # try to just make wine, if this fails 'make depend' and try to remake
245 if ! { make; }
246 then {
247 if ! { make depend && make; }
248 then {
249 echo
250 echo "Compilation failed, aborting install."
251 exit 1
257 if [ "$ROOTINSTALL" = "yes" ]
258 then {
259 echo
261 echo "Performing 'make install' as root to install binaries, enter root password"
263 std_sleep
265 if ! su root -c "$sucommand"
266 then {
267 if ! su root -c "$sucommand"
268 then {
269 echo
270 echo "Either you entered an incorrect password or we failed to"
271 echo "run '$sucommand' correctly."
272 echo "If you didn't enter an incorrect password then please"
273 echo "report this error and any steps to possibly reproduce it to"
274 echo "http://bugs.winehq.org/"
275 echo
276 echo "Installation failed, aborting."
277 exit 1
283 echo
285 # see if wine is installed on the users system, if not prompt them
286 # and then exit
287 if [ ! `which wine` ]
288 then
289 echo "Could not find wine on your system. Run wineinstall as root to install wine"
290 echo "before re-running wineinstall as a user."
291 echo
292 echo "Exiting wineinstall"
293 exit 1;
296 WINEINSTALLED=yes
298 else {
299 WINEINSTALLED=no
301 fi # [ "$ROOTINSTALL" = "yes" ]
303 fi # [ `whoami` != 'root' ]
306 fi # BINDIST
308 # now check whether we should generate wine.conf
309 if [ "$DOLOCALCONF" = 'auto' ]
310 then {
311 # see if the user is root, if so, explicitly ask them if they want a
312 # local config file
313 if [ `whoami` = 'root' ]
314 then
315 echo "You are running as root. Do you want a local config file,"
316 echo "file, ~/.wine/config, created?"
317 conf_yesno_answer "(yes/no) "
318 DOLOCALCONF="$ANSWER"
319 else
320 # if the user has an existing config file ask them if they want us to
321 # overwrite it, otherwise just ask them if they want to create one
322 if [ -f "$LCONF" ]
323 then
324 echo "Found existing $LCONF, do you want to overwrite this"
325 echo "existing Wine configuration file?"
326 conf_yesno_answer "(yes/no) "
327 DOLOCALCONF="$ANSWER"
328 echo
329 if [ "$ANSWER" = "yes" ]
330 then
332 echo "Would you like to make a backup of this old config file?"
333 conf_yesno_answer "(yes/no) "
334 echo
335 if [ "$ANSWER" = "yes" ]
336 then
338 echo "Renaming $LCONF to $LCONF.old"
339 mv -f "$LCONF" "$LCONF.old"
340 echo
345 else
347 echo "Create local config file ~/.wine/config?"
348 conf_yesno_answer "(yes/no) "
349 DOLOCALCONF="$ANSWER"
350 echo
351 if [ "$ANSWER" = 'no' ]
352 then
353 conf_question high need_root \
354 "Aborting install. Try again as root to generate a system wine.conf."
355 exit 1
363 # generate $TMPCONF from existing windows install, if any
364 if [ "$DOLOCALCONF" = 'yes' ]
365 then {
366 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
367 then {
368 echo -n "Searching for an existing Windows installation..."
369 if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
370 then {
371 rm -f $TMPCONF > /dev/null
373 echo " not found. (no matching /etc/fstab mount entry found)"
374 conf_question low do_without_windows \
375 "Windows was not found on your system, so I assume you want" \
376 "a Wine-only installation. Am I correct?"
377 conf_yesno_answer "(yes/no) "
378 if [ "$ANSWER" = 'no' ]
379 then {
380 conf_question high windows_not_found \
381 "Aborting install. Make sure your Windows partition is mounted and try again," \
382 "or create $LCONF manually by copying from $WINEINI and adapting the drive paths."
383 exit 1
386 DOWINE=yes
388 else {
389 echo " found."
391 conf_question low do_without_windows \
392 "Windows was found on your system, and so we can use the Windows" \
393 "Drive as our Wine drive. You may, however, wish to create a clean" \
394 "Wine install anyways."
395 conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
396 if [ "$ANSWER" = 'yes' ]
397 then {
398 conf_reset_question windows_found
399 conf_question low windows_found \
400 "Created $LCONF using your existing Windows installation." \
401 "You probably want to review the file, though."
402 DOWINE=no
404 else {
405 DOWINE=yes
411 elif [ "$DOWINE" = 'auto' ]
412 then DOWINE=yes
415 elif [ "$DOWINE" = 'auto' ]
416 then
417 DOWINE=no
420 # setup a no-windows installation, if necessary
421 if [ "$DOWINE" = 'yes' ]
422 then {
423 # set an appropriate DCROOT
424 if [ `whoami` != 'root' ]
425 then DCROOT=~/.wine/drive_c
426 else DCROOT=/c
429 conf_question low drivec_path \
430 "Configuring Wine without Windows." \
431 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
432 "start menu entries, and other things your applications may need to install." \
433 "Where would you like your fake C drive to be placed?"
434 while [ -z "$CROOT" ]
435 do {
436 conf_string_answer "(default is $DCROOT) "
437 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
438 if ! [ -d "$ANSWER" ]
439 then {
440 if mkdir -p "$ANSWER"
441 then CROOT="$ANSWER"
442 else
443 echo "Directory $ANSWER can't be created !"
444 conf_reset_question drivec_path
447 else CROOT="$ANSWER"
450 done
451 echo "Configuring Wine for a no-windows install in $CROOT..."
453 if [ ! -d ~/.wine/dosdevices ]
454 then
455 [ -d ~/.wine ] || mkdir ~/.wine
456 mkdir ~/.wine/dosdevices
457 ln -s /mnt/fd0 ~/.wine/dosdevices/a:
458 ln -s $CROOT ~/.wine/dosdevices/c:
459 ln -s /cdrom ~/.wine/dosdevices/d:
460 ln -s /tmp ~/.wine/dosdevices/e:
461 ln -s ~ ~/.wine/dosdevices/f:
462 ln -s / ~/.wine/dosdevices/z:
465 if [ "$WINEINSTALLED" = 'no' ]
466 then
467 tools/wineprefixcreate --use-wine-tree .
468 else
469 wineprefixcreate
472 # create $LCONF using the default config file $WINEINI
473 if [ "$DOLOCALCONF" = 'yes' ]
474 then {
475 cp $WINEINI $TMPCONF
476 conf_reset_question default_config
477 conf_question low default_config \
478 "Created $LCONF using default Wine configuration." \
479 "You probably want to review the file, though."
483 # now we really should install the registry
484 if [ "$DOREG" = 'auto' ]
485 then DOREG=yes
489 echo
491 #install the local config file $LCONF
492 if [ "$DOLOCALCONF" = 'yes' ]
493 then
494 if [ ! -w ~/.wine ]
495 then
496 mkdir ~/.wine
498 cp $TMPCONF $LCONF > /dev/null
499 else
500 DOREG=no
503 # make root's registry global, if desired
504 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
505 then {
506 [ -d ~/.wine ] || mkdir ~/.wine
507 if ! [ -f $sysconfdir/wine.userreg ]
508 then {
509 echo "Linking root's user registry hive to the global registry..."
510 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
511 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
514 if ! [ -f $sysconfdir/wine.systemreg ]
515 then {
516 echo "Linking root's system registry hive to the global registry..."
517 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
518 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
524 # cleanup any temporary files that may remain
525 if [ -f $TMPCONF ]
526 then rm -f $TMPCONF
530 # it's a wrap
531 echo
532 echo "Installation complete for now. Good luck (this is still alpha software)."
533 echo "If you have problems with WINE, please read the documentation first,"
534 echo "as many kinds of potential problems are explained there."
536 exit 0