Symlink root's registry to global registry. Minor cleanups.
[wine] / tools / wineinstall
1 #!/bin/bash
2 # WINE Installation script
3
4 # Mar 31 1999 - Ove Kåven
5 #  First version
6 # Dec 9 1999 - Ove Kåven
7 #  require Xpm
8 # Feb 25 2000 - Ove Kåven
9 #  auto-add /usr/local/lib to /etc/ld.so.conf
10 # Mar 2 2000 - Ove Kåven
11 #  source rather than grep config.cache
12 #  use sourced config.cache to start ldconfig
13 #  reconfigure if config.cache doesn't exist
14 # Mar 30 2000 - Ove Kåven
15 #  autoconfigure no-windows installs
16 #  do not install registry on real-windows installs
17 #  some support for binary package installs
18 #  set and tell user about LD_LIBRARY_PATH if necessary
19 #  set EXTRA_LD_LIBRARY_PATH in wine.conf
20 # Apr 9 2000 - Ove Kåven
21 #  make root's registry global (system-default)
22
23 # defaults (change these if you are a packager)
24 CONFARGS=                     # configure args, e.g. --prefix=/usr --sysconfdir=/etc
25 prefix=/usr/local             # installation prefix
26 sysconfdir=$prefix/etc        # where wine.conf and global registry is supposed to be
27 libdir=$prefix/lib            # where libwine.so will be (or is) installed
28 exdir=documentation/samples   # where the example system.ini resides
29 CONF=$sysconfdir/wine.conf    # default path of the wine.conf
30 BINDIST=no                    # whether called from a binary package config script
31 DOCONF=auto                   # whether to autogenerate wine.conf
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 SYSREG=yes                    # whether to make root's registry global (system-default)
36 # elfdlls are not implemented yet, so this has no effect yet
37 DLLPATH=$libdir/wine          # default path of the elfdll .so files
38 # only for existing-windows installs
39 WINECONF=tools/wineconf       # the path of wineconf perl script
40 # only for no-windows installs
41 WINEINI=wine.ini              # the path of default wine.ini (also used by wineconf)
42 WININI=/dev/null              # the path of default win.ini
43 SYSTEMINI=$exdir/system.ini   # the path of default system.ini
44 REGAPI=programs/regapi/regapi # the path of regapi winelib application
45 DEFREG=winedefault.reg        # the path of the registry file to be fed to regapi
46 # CROOT=/var/wine             # the path of the fake Drive C (asks user if not set)
47
48 # startup...
49
50 echo "WINE Installer v0.3"
51 echo
52
53 if [ "$BINDIST" = 'no' ]
54 then {
55
56 if ! [ -f configure ]
57 then {
58   echo "You're running this from the wrong directory."
59   echo "Change to the Wine directory and try again."
60   exit 1
61 }
62 fi
63
64 # run the configure script, if necessary
65
66 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
67 then {
68   echo "I see that WINE has already been configured, so I'll skip that."
69   # load configure results
70   . ./config.cache
71 }
72 else {
73   echo "Running configure..."
74   echo
75   if ! ./configure $CONFARGS
76   then {
77     echo
78     echo "Configure failed, aborting install."
79     rm -f config.cache
80     exit 1
81   }
82   fi
83   # load configure results
84   . ./config.cache
85   # make sure X was found
86   eval "$ac_cv_have_x"
87   if [ "$have_x" != "yes" ]
88   then {
89     echo "Install the X development headers and try again."
90     rm -f config.cache
91     exit 1
92   }
93   elif [ "$ac_cv_header_X11_xpm_h" != "yes" ]
94   then {
95     echo "Install the Xpm development headers and try again."
96     rm -f config.cache
97     exit 1
98   }
99   fi
100 }
101 fi
102
103 # now do the compilation
104
105 if [ -f wine ] && [ wine -nt Makefile ]
106 then {
107   echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
108 }
109 else {
110   echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever, in the meantime..."
111   echo
112   if ! { make depend && make; }
113   then {
114     echo
115     echo "Compilation failed, aborting install."
116     exit 1
117   }
118   fi
119   echo
120 }
121 fi
122
123 # and installation, if root
124
125 if [ `whoami` != 'root' ]
126 then {
127   echo "You aren't root, so I'll skip the make install."
128   # setup to run from current directory
129   DLLPATH="$PWD/dlls"
130   if [ -z "$LD_LIBRARY_PATH" ]
131   then LD_LIBRARY_PATH="$PWD:$DLLPATH"
132   else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
133   fi
134   export LD_LIBRARY_PATH
135   echo
136   echo "NOTE! To run Wine without installing, you must set the environment variable"
137   echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
138   echo "in your logon scripts."
139 }
140 else {
141   echo "Now installing binaries onto the system..."
142   echo
143   if ! make install
144   then {
145     echo
146     echo "Installation failed, aborting."
147     exit 1
148   }
149   fi
150   if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
151   then {
152     echo
153     echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
154     echo "$libdir" >>/etc/ld.so.conf
155     echo "Re-running ldconfig..."
156     eval "$ac_cv_path_LDCONFIG"
157   }
158   fi
159 }
160 fi
161 echo
162
163 }
164 fi # BINDIST
165
166 # now check whether we should generate wine.conf
167 if [ -z "$DOCONF" ]
168 then DOCONF=auto
169 fi
170
171 if [ "$DOCONF" = 'auto' ]
172 then {
173   # see if we already have a system wine.conf
174   if [ -f $CONF ]
175   then DOCONF=no
176   fi
177 }
178 fi
179
180 if [ "$DOCONF" != 'no' ]
181 then {
182   if [ `whoami` != 'root' ]
183   then {
184     CONF=~/.winerc
185     if ! [ -f $CONF ]
186     then {
187       if [ "$DOCONF" != 'yes' ]
188       then {
189         echo "Since you aren't root, and there's no system wine.conf, I assume"
190         echo "you want a user-specific .winerc. Am I correct? (yes/no)"
191         while [ "$DOCONF" != 'yes' ] && [ "$DOCONF" != 'no' ]
192         do read DOCONF
193         done
194       }
195       fi
196       if [ "$DOCONF" = 'no' ]
197       then {
198         echo "Aborting install. Try again as root to generate a system wine.conf."
199         exit 1
200       }
201       fi
202       echo
203     }
204     fi
205   }
206   else {
207     mkdir -p $sysconfdir
208     DOCONF=yes
209   }
210   fi
211 }
212 fi
213
214 # generate wine.conf from existing windows install, if any
215 if [ "$DOCONF" = 'yes' ]
216 then {
217   if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
218   then {
219     echo "Searching for an existing Windows installation..."
220     if ! $WINECONF > $CONF 2>/dev/null
221     then {
222       rm -f $CONF
223       echo
224       echo "Windows was not found on your system, so I assume you want a Wine-only installation."
225       echo "Am I correct? (yes/no)"
226       while [ "$DOWINE" != 'yes' ] && [ "$DOWINE" != 'no' ]
227       do read DOWINE
228       done
229       if [ "$DOWINE" = 'no' ]
230       then {
231         echo "Aborting install. Make sure your Windows partition is mounted and try again,"
232         echo "or create $CONF manually by copying from $WINEINI and adapting the drive paths."
233         exit 1
234       }
235       fi
236     }
237     else {
238       echo
239       echo "Created $CONF using your existing Windows installation."
240       echo "You probably want to review the file, though."
241       DOWINE=no
242     }
243     fi
244     echo
245   }
246   elif [ "$DOWINE" = 'auto' ]
247   then DOWINE=yes
248   fi
249 }
250 elif [ "$DOWINE" = 'auto' ]
251 then DOWINE=no
252 fi
253
254 # setup a no-windows installation, if necessary
255 if [ "$DOWINE" = 'yes' ]
256 then {
257   if [ `whoami` != 'root' ]
258   then DCROOT=~/c
259   else DCROOT=/c
260   fi
261   echo "Configuring Wine without Windows. Some fake Windows directories must be created, to"
262   echo "hold any .ini files, DLLs, and start menu entries your applications may need to install."
263   while [ -z "$CROOT" ]
264   do {
265     echo "Where would you like your fake C drive to be placed? (default is $DCROOT)"
266     read CROOT
267     if [ -z "$CROOT" ]
268     then CROOT="$DCROOT"
269     fi
270     if ! [ -d "$CROOT" ]
271     then {
272       if ! mkdir -p "$CROOT"
273       then unset CROOT
274       fi
275     }
276     fi
277   }
278   done
279   echo "Configuring Wine for a no-windows install in $CROOT..."
280   for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs"
281   do [ -d "$tdir" ] || mkdir "$tdir"
282   done
283   [ -f "$CROOT/windows/win.ini" ]    || cp "$WININI"    "$CROOT/windows/win.ini"
284   [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
285   if [ "$DOCONF" = 'yes' ]
286   then {
287     sed "s/Path=\/c$/Path=${CROOT//\//\\/}/" $WINEINI > $CONF
288     echo "Created $CONF using default Wine configuration."
289     echo "You probably want to review the file, though."
290   }
291   fi
292   # now we really need to install the registry
293   DOREG=yes
294 }
295 elif [ -z "$CROOT" ]
296 then {
297   echo "Reading current Wine configuration from $CONF..."
298   CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
299   echo "Drive C is configured at $CROOT."
300 }
301 fi
302 echo
303
304 # fixup EXTRA_LD_LIBRARY_PATH
305 if [ "$DOCONF" = 'yes' ]
306 then {
307   echo "Setting EXTRA_LD_LIBRARY_PATH in .winerc to $DLLPATH..."
308   sed "s/EXTRA_LD_LIBRARY_PATH=.*/EXTRA_LD_LIBRARY_PATH=${DLLPATH//\//\\/}/" $CONF > $CONF.new
309   mv -f $CONF.new $CONF
310   echo
311 }
312 fi
313
314 # check whether we need to install default registry
315 # (not to be done if windows registry exists)
316 if [ "$DOREG" = 'auto' ]
317 then {
318   echo "Checking for real Windows registry..."
319   if [ -f "$CROOT/windows/system.dat" ]
320   then DOREG=no
321   elif [ -f "$CROOT/windows/system32/config/system" ]
322   then DOREG=no
323   else DOREG=yes
324   fi
325   if [ "$DOREG" = 'yes' ]
326   then echo "Not found, default Wine registry will be installed."
327   else echo "Windows registry found, will not install default Wine registry."
328   fi
329   echo
330 }
331 fi
332
333 # install default registry entries
334 if [ "$DOREG" = 'yes' ]
335 then {
336   if [ "$BINDIST" = 'no' ]
337   then {
338     echo "Compiling regapi..."
339     echo
340     (cd programs/regapi; make)
341     echo
342   }
343   fi
344   echo "Installing default Wine registry entries..."
345   echo
346   if ! $REGAPI setValue < $DEFREG > /dev/null
347   then {
348     echo
349     echo "Registry install failed. Perhaps you weren't running X."
350     exit 1
351   }
352   else echo "Registry entries successfully installed."
353   fi
354   if [ "$SYSREG" = 'auto' ]
355   then SYSREG=yes
356   fi
357 }
358 fi
359
360 # make root's registry global, if desired
361 if [ `whoami` = 'root' ] && [ "$SYSREG" = 'yes' ]
362 then {
363   if ! [ -f $sysconfdir/wine.userreg ]
364   then {
365     echo "Linking root's user registry hive to the global registry..."
366     cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
367     ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
368   }
369   fi
370   if ! [ -f $sysconfdir/wine.systemreg ]
371   then {
372     echo "Linking root's system registry hive to the global registry..."
373     cp ~/.wine/system.reg $sysconfdir/wine.systemreg
374     ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
375   }
376   fi
377 }
378 fi
379
380 # it's a wrap
381 echo
382 echo "Installation complete for now. Good luck (this is still alpha software)."
383 echo "If you have problems with WINE, please read the documentation first,"
384 echo "as many kinds of potential problems are explained there."