-#!/bin/bash
+#!/bin/sh
# WINE Installation script
-
-# Mar 31 1999 - Ove Kåven
-# First version
-# Dec 9 1999 - Ove Kåven
-# require Xpm
-# Feb 25 2000 - Ove Kåven
-# auto-add /usr/local/lib to /etc/ld.so.conf
-# Mar 2 2000 - Ove Kåven
-# source rather than grep config.cache
-# use sourced config.cache to start ldconfig
-# reconfigure if config.cache doesn't exist
-# Mar 30 2000 - Ove Kåven
-# autoconfigure no-windows installs
-# do not install registry on real-windows installs
-# some support for binary package installs
-# set and tell user about LD_LIBRARY_PATH if necessary
-# set EXTRA_LD_LIBRARY_PATH in wine.conf
-# Apr 9 2000 - Ove Kåven
-# make root's registry global (system-default)
-# May 9 2000 - Ove Kåven
-# use ttydrv when running regapi, so we don't have to run from X
-# change debugger path in registry
+# Can do almost everything from compiling to configuring...
+#
+# Copyright 1999 Ove Kåven
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
#--- defaults (change these if you are a packager)
-CONFARGS= # configure args, e.g. --prefix=/usr --sysconfdir=/etc
-prefix=/usr/local # installation prefix
-sysconfdir=$prefix/etc # where wine.conf and global registry is supposed to be
-bindir=$prefix/bin # where winelib apps will be (or is) installed
-libdir=$prefix/lib # where libwine.so will be (or is) installed
-exdir=documentation/samples # where the example system.ini resides
-CONF=$sysconfdir/wine.conf # default path of the wine.conf
-BINDIST=no # whether called from a binary package config script
-DOCONF=auto # whether to autogenerate wine.conf
-DOWCHK=auto # whether to autoconfigure existing-windows installation
-DOWINE=auto # whether to autoconfigure no-windows installation
-DOREG=auto # whether to install default registry
-SYSREG=yes # whether to make root's registry global (system-default)
-
-# "make install" still installs the dlls into $libdir, but this may change in the future
-# (DLLPATH should point to them if/when they are not in standard ld.so paths)
-DLLPATH=$libdir/wine # default path of the dll .so files (except libwine.so)
-
-# having the Wine debugger launched automatically will be a plus for us
-DEBUGGER=$bindir/winedbg # the (installed) path of winedbg
-HDEBUGGER=debugger/winedbg # the (non-installed) path of winedbg
-
-# this is only for existing-windows installs
-WINECONF=tools/wineconf # the path of wineconf perl script
+CONFARGS="" # configure args, e.g. --prefix=/usr
-# this is only for no-windows installs
-WINEINI=wine.ini # the path of default wine.ini (also used by wineconf)
-WININI=/dev/null # the path of default win.ini
-SYSTEMINI=$exdir/system.ini # the path of default system.ini
-REGAPI=programs/regapi/regapi # the path of regapi winelib application
-DEFREG=winedefault.reg # the path of the registry file to be fed to regapi
-# CROOT=/var/wine # the path of the fake Drive C (asks user if not set)
-#--- end of defaults
+std_sleep() {
+ sleep 1
+}
-# temporary files used by the installer
-TMPCONF=/tmp/wineinstall.conf
-TMPREG=/tmp/wineinstall.reg
+conf_yesno_answer() {
+ unset ANSWER
+ while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
+ do {
+ echo -n "$1"
+ read ANSWER
+ }
+ done
+}
# startup...
-echo "WINE Installer v0.4"
+echo "Wine Installer v1.0"
echo
-if [ "$BINDIST" = 'no' ]
-then {
-
-if ! [ -f configure ]
-then {
- echo "You're running this from the wrong directory."
- echo "Change to the Wine directory and try again."
- exit 1
-}
+if [ ! -f configure ]
+then
+ if [ -f ../configure ]
+ then {
+ cd ..
+ }
+ else {
+ echo "You're running this from the wrong directory."
+ echo "Change to the Wine source's main directory and try again."
+ exit 1
+ }
+ fi
fi
-# run the configure script, if necessary
-
-if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
-then {
- echo "I see that WINE has already been configured, so I'll skip that."
- # load configure results
- . ./config.cache
-}
-else {
- echo "Running configure..."
- echo
- if ! ./configure $CONFARGS
- then {
- echo
- echo "Configure failed, aborting install."
- rm -f config.cache
+if [ -w / ]
+then
+ echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
+ echo "Aborting."
exit 1
- }
- fi
- # load configure results
- . ./config.cache
- # make sure X was found
- eval "$ac_cv_have_x"
- if [ "$have_x" != "yes" ]
- then {
- echo "Install the X development headers and try again."
- rm -f config.cache
- exit 1
- }
- elif [ "$ac_cv_header_X11_xpm_h" != "yes" ]
- then {
- echo "Install the Xpm development headers and try again."
- rm -f config.cache
- exit 1
- }
- fi
-}
fi
-# now do the compilation
-
-if [ -f wine ] && [ wine -nt Makefile ]
-then {
- echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
-}
-else {
- echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever, in the meantime..."
- echo
- if ! { make depend && make; }
- then {
- echo
- echo "Compilation failed, aborting install."
+if [ ! -w . ]
+then
+ echo "The source directory is not writable. You probably extracted the sources as root."
+ echo "You should remove the source tree and extract it again as a normal user."
exit 1
- }
- fi
- echo
-}
fi
-# and installation, if root
+# check whether RPM installed, and if it is, remove any old wine rpm.
+if [ -x `which rpm 2>/dev/null` ]; then
+ if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
+ echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
+ conf_yesno_answer "(yes/no) "
+ if [ "$ANSWER" = 'yes' ]; then
+ echo "We need to remove the rpm as root, please enter your root password"
+ echo
+ echo Starting wine rpm removal...
+ su -c "rpm -e wine; RET=$?"
+ if [ $RET -eq 0 ]; then
+ echo Done.
+ else
+ echo "FAILED. Probably you aren't installing as root."
+ echo "Expect problems (library conflicts with existing install etc.)."
+ fi
+ else
+ echo "Sorry, I won't install Wine when an rpm version is still installed."
+ echo "(Wine support suffered from way too many conflicts between RPM"
+ echo "and source installs)"
+ echo "Have a nice day !"
+ exit 1
+ fi
+ fi
+fi
-if [ `whoami` != 'root' ]
-then {
- echo "You aren't root, so I'll skip the make install."
- # setup to run from current directory
- DLLPATH="$PWD/dlls"
- if [ -z "$LD_LIBRARY_PATH" ]
- then LD_LIBRARY_PATH="$PWD:$DLLPATH"
- else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
- fi
- export LD_LIBRARY_PATH
- DEBUGGER=$PWD/$HDEBUGGER
- echo
- echo "NOTE! To run Wine without installing, you must set the environment variable"
- echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
- echo "in your logon scripts."
-}
-else {
- echo "Now installing binaries onto the system..."
- echo
- if ! make install
- then {
- echo
- echo "Installation failed, aborting."
- exit 1
- }
- fi
- if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
- then {
- echo
- echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
- echo "$libdir" >>/etc/ld.so.conf
- echo "Re-running ldconfig..."
- eval "$ac_cv_path_LDCONFIG"
- }
- fi
-}
+# check whether wine binary still available
+if [ -x `which wine 2>/dev/null` ] && [ -n "`wine --version 2>/dev/null`" ]
+then
+ echo "Warning !! wine binary (still) found, which may indicate"
+ echo "a (conflicting) previous installation."
+ echo "You might want to abort and uninstall Wine first."
+ echo "(If you previously tried to install from source manually, "
+ echo "run 'make uninstall' from the wine root directory)"
+ std_sleep
fi
-echo
-}
-fi # BINDIST
+# Ask the user if they want to build and install Wine:
+echo
+echo "We need to install Wine as the root user. Do you want us to build Wine,"
+echo "'su root' and install Wine? Enter 'no' to build Wine without installing:"
+conf_yesno_answer "(yes/no) "
+ROOTINSTALL="$ANSWER"
-# now check whether we should generate wine.conf
-if [ -z "$DOCONF" ]
-then DOCONF=auto
+if [ "$ROOTINSTALL" = "yes" ]
+then sucommand="make install"
fi
-if [ "$DOCONF" = 'auto' ]
-then {
- # see if we already have a system wine.conf
- if [ -f $CONF ]
- then DOCONF=no
- fi
-}
-fi
+# run the configure script, if necessary
-if [ "$DOCONF" != 'no' ]
-then {
- if [ `whoami` != 'root' ]
- then {
- CONF=~/.winerc
- if ! [ -f $CONF ]
+if [ -f Makefile ]
+then
+ echo "I see that Wine has already been configured, so I'll skip that."
+ std_sleep
+else
+ echo "Running configure..."
+ echo
+ if ! ./configure $CONFARGS
then {
- if [ "$DOCONF" != 'yes' ]
- then {
- echo "Since you aren't root, and there's no system wine.conf, I assume"
- echo "you want a user-specific .winerc. Am I correct? (yes/no)"
- while [ "$DOCONF" != 'yes' ] && [ "$DOCONF" != 'no' ]
- do read DOCONF
- done
- }
- fi
- if [ "$DOCONF" = 'no' ]
- then {
- echo "Aborting install. Try again as root to generate a system wine.conf."
- exit 1
- }
- fi
echo
+ echo "Configure failed, aborting install."
+ exit 1
}
fi
- }
- else {
- mkdir -p $sysconfdir
- DOCONF=yes
- }
- fi
-}
fi
-# generate wine.conf from existing windows install, if any
-if [ "$DOCONF" = 'yes' ]
-then {
- if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
- then {
- echo "Searching for an existing Windows installation..."
- if ! $WINECONF > $CONF 2>/dev/null
- then {
- rm -f $CONF
- echo
- echo "Windows was not found on your system, so I assume you want a Wine-only installation."
- echo "Am I correct? (yes/no)"
- while [ "$DOWINE" != 'yes' ] && [ "$DOWINE" != 'no' ]
- do read DOWINE
- done
- if [ "$DOWINE" = 'no' ]
- then {
- echo "Aborting install. Make sure your Windows partition is mounted and try again,"
- echo "or create $CONF manually by copying from $WINEINI and adapting the drive paths."
- exit 1
- }
- fi
- }
- else {
- echo
- echo "Created $CONF using your existing Windows installation."
- echo "You probably want to review the file, though."
- DOWINE=no
- }
- fi
- echo
- }
- elif [ "$DOWINE" = 'auto' ]
- then DOWINE=yes
- fi
-}
-elif [ "$DOWINE" = 'auto' ]
-then DOWINE=no
-fi
+# Now do the compilation and (optionally) installation
-# setup a no-windows installation, if necessary
-if [ "$DOWINE" = 'yes' ]
-then {
- if [ `whoami` != 'root' ]
- then DCROOT=~/c
- else DCROOT=/c
- fi
- echo "Configuring Wine without Windows. Some fake Windows directories must be created, to"
- echo "hold any .ini files, DLLs, and start menu entries your applications may need to install."
- while [ -z "$CROOT" ]
- do {
- echo "Where would you like your fake C drive to be placed? (default is $DCROOT)"
- read CROOT
- if [ -z "$CROOT" ]
- then CROOT="$DCROOT"
- fi
- if ! [ -d "$CROOT" ]
- then {
- if ! mkdir -p "$CROOT"
- then unset CROOT
- fi
- }
- fi
- }
- done
- echo "Configuring Wine for a no-windows install in $CROOT..."
- for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs"
- do [ -d "$tdir" ] || mkdir "$tdir"
- done
- [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
- [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
- if [ "$DOCONF" = 'yes' ]
- then {
- sed "s/Path=\/c$/Path=${CROOT//\//\\/}/" $WINEINI > $CONF
- echo "Created $CONF using default Wine configuration."
- echo "You probably want to review the file, though."
- }
- fi
- # now we really need to install the registry
- DOREG=yes
-}
-elif [ -z "$CROOT" ]
-then {
- echo "Reading current Wine configuration from $CONF..."
- CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
- echo "Drive C is configured at $CROOT."
-}
-fi
echo
+echo "Compiling Wine. Grab a lunch or two, rent a video, or whatever,"
+echo "in the meantime..."
+echo
+std_sleep
-# fixup EXTRA_LD_LIBRARY_PATH
-if [ "$DOCONF" = 'yes' ]
-then {
- echo "Setting EXTRA_LD_LIBRARY_PATH in .winerc to $DLLPATH..."
- sed "s/EXTRA_LD_LIBRARY_PATH=.*/EXTRA_LD_LIBRARY_PATH=${DLLPATH//\//\\/}/" $CONF > $CONF.new
- mv -f $CONF.new $CONF
- echo
-}
+# try to just make wine, if this fails 'make depend' and try to remake
+if ! { make; }
+then
+ if ! { make depend && make; }
+ then
+ echo
+ echo "Compilation failed, aborting install."
+ exit 1
+ fi
fi
-# check whether we need to install default registry
-# (not to be done if windows registry exists)
-if [ "$DOREG" = 'auto' ]
-then {
- echo "Checking for real Windows registry..."
- if [ -f "$CROOT/windows/system.dat" ]
- then DOREG=no
- elif [ -f "$CROOT/windows/system32/config/system" ]
- then DOREG=no
- else DOREG=yes
- fi
- if [ "$DOREG" = 'yes' ]
- then echo "Not found, default Wine registry will be installed."
- else echo "Windows registry found, will not install default Wine registry."
- fi
- echo
-}
+if [ "$ROOTINSTALL" = "no" ]
+then
+ exit 0
fi
-# install default registry entries
-if [ "$DOREG" = 'yes' ]
-then {
- if [ "$BINDIST" = 'no' ]
- then {
- echo "Compiling regapi..."
- echo
- (cd programs/regapi; make)
- echo
- }
- fi
- echo "Preparing to install default Wine registry entries..."
-
- # create a temporary wineinstall.conf file using ttydrv,
- # so that we don't have to run regapi under X
- sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $CONF > $TMPCONF
-
- # create a temporary wineinstall.reg with fixed debugger path
- sed "s/debugger\/winedbg/${DEBUGGER//\//\\/}/" $DEFREG > $TMPREG
+echo
+echo "Performing 'make install' as root to install binaries, enter root password"
- echo "Installing default Wine registry entries..."
- echo
- if ! $REGAPI --config $TMPCONF setValue < $TMPREG > /dev/null
- then {
- rm -f $TMPCONF $TMPREG
+if ! su root -c "$sucommand"
+then
echo
- echo "Registry install failed."
- exit 1
- }
- else echo "Registry entries successfully installed."
- fi
- rm -f $TMPCONF $TMPREG
- if [ "$SYSREG" = 'auto' ]
- then SYSREG=yes
- fi
-}
-fi
-
-# make root's registry global, if desired
-if [ `whoami` = 'root' ] && [ "$SYSREG" = 'yes' ]
-then {
- if ! [ -f $sysconfdir/wine.userreg ]
- then {
- echo "Linking root's user registry hive to the global registry..."
- cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
- ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
- }
- fi
- if ! [ -f $sysconfdir/wine.systemreg ]
- then {
- echo "Linking root's system registry hive to the global registry..."
- cp ~/.wine/system.reg $sysconfdir/wine.systemreg
- ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
- }
- fi
-}
+ echo "Incorrect root password. If you are running Ubuntu or a similar distribution,"
+ echo "'make install' needs to be run via the sudo wrapper, so trying that one now"
+ if ! sudo su root -c "$sucommand"
+ then
+ echo
+ echo "Either you entered an incorrect password or we failed to"
+ echo "run '$sucommand' correctly."
+ echo "If you didn't enter an incorrect password then please"
+ echo "report this error and any steps to possibly reproduce it to"
+ echo "http://bugs.winehq.org/"
+ echo
+ echo "Installation failed, aborting."
+ exit 1
+ fi
fi
# it's a wrap
echo
-echo "Installation complete for now. Good luck (this is still alpha software)."
-echo "If you have problems with WINE, please read the documentation first,"
+echo "Installation complete."
+echo "If you have problems with Wine, please read the documentation first,"
echo "as many kinds of potential problems are explained there."
+
+exit 0