New loading scheme for Winelib apps, makes them behave like builtin
[wine] / tools / wineinstall
index 9f50a31..52c1bb5 100755 (executable)
@@ -1,7 +1,24 @@
 #!/bin/bash
 # WINE Installation script
 # 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# History:
 # Mar 31 1999 - Ove Kåven
 #  First version
 # Dec 9 1999 - Ove Kåven
 #  misc cleanups and reordering of questions
 #  added check to see if wine is installed when we are running as a normal
 #    user and print a message if wine cannot be found
+# Feb 16 2002 - Adam D. Moss
+#  Use config.status instead of config.cache to check whether we're
+#    configured/compiled and to recreate the configuration
+# Feb 20 2002 - Adam D. Moss
+#  Partially revert previous changes, force configure to write an
+#    old-style config.cache
+# Mar 27 2002 - Chris Morgan
+#  prevent the user from running wineinstall as root
+#  add script commands so we su root for 'make install' and other commands
+#    that require root access
+#  add text to tell the user we need to run stuff as root so they don't 
+#    think we are trying to pull something funny
+# Apr 14 2002 - Dustin Navea
+#  Fix sed command when finding real-windows registry so it actually 
+#   accesses a file (~/.wine/config) instead of null ($CONF?!)
+#  Added search for clean-install (not upgrade) Win2k registry
+#  (next day, after some sleep)
+#  Fix sed string when finding real-windows registry to actually find 
+#   windows partition name in [Drive C] section
+#  it should now almost always find the windows partition and real-windows 
+#  registry (if not, let me know)
 
 #--- defaults (change these if you are a packager)
 CONFARGS="--enable-opengl"    # configure args, e.g. --prefix=/usr --sysconfdir=/etc
@@ -61,6 +99,7 @@ DOLOCALCONF=auto              # whether to autogenerate localconf
 DOWCHK=auto                   # whether to autoconfigure existing-windows installation
 DOWINE=auto                   # whether to autoconfigure no-windows installation
 DOREG=auto                    # whether to install default registry
+DOAPP=auto                    # whether to install applications, distributed with Wine
 SYSREG=yes                    # whether to make root's registry global (system-default)
 CONVCONF=no                  # whether we are converting an existing .winerc or not
 
@@ -79,8 +118,8 @@ WINECONF=tools/wineconf       # the path of wineconf perl script
 WINEINI=$exdir/config         # the path of default wine config file (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
+REGEDIT=programs/regedit/regedit # the path of regedit winelib application
+DEFREG=winedefault.reg        # the path of the registry file to be fed to regedit
 # CROOT=/var/wine             # the path of the fake Drive C (asks user if not set)
 DEFCAT=cat                    # program to cat $DEFREG with (some packages need zcat)
 #--- end of defaults
@@ -132,9 +171,9 @@ function conf_string_answer {
 }
 
 function create_windows_directories {
-  for tdir in "$CROOT/windows" "$CROOT/windows/system" \
+  for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/system32" \
               "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
-              "$CROOT/Common Files" "$CROOT/Program Files" \
+              "$CROOT/Program Files" "$CROOT/Program Files/Common Files" \
               "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator"
   do [ -d "$tdir" ] || mkdir "$tdir"
   done
@@ -142,9 +181,33 @@ function create_windows_directories {
   [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
 }
 
+#creates symbolic link in windows directory to installed winelib application
+#parameters:
+# - name of the installed winelib application
+# - full path to application in the winelib directory
+function link_app {
+  ln -sf $bindir/$1 $2
+  ln -sf $bindir/$1.so $2.so
+}
+
+#puts windows applications replacements to windows directories,
+#configures them
+function configure_wine_applications {
+  link_app regedit      "$CROOT/windows/regedit.exe"
+  link_app uninstaller  "$CROOT/windows/uninstall.exe"
+  link_app wcmd         "$CROOT/windows/system32/cmd.exe"
+  link_app control      "$CROOT/windows/system32/control.exe"
+  link_app winhelp      "$CROOT/windows/system32/help.exe"
+  link_app notepad      "$CROOT/windows/system32/notepad.exe"
+  link_app progman      "$CROOT/windows/system32/progman.exe"
+  link_app regsvr32     "$CROOT/windows/system32/regsvr32.exe"
+  link_app winemine     "$CROOT/windows/system32/winmine.exe"
+  link_app winver       "$CROOT/windows/system32/winver.exe"
+}
+
 # startup...
 
-echo "WINE Installer v0.7"
+echo "WINE Installer v0.73"
 echo
 
 if [ "$BINDIST" = 'no' ]
@@ -158,6 +221,14 @@ then {
 }
 fi
 
+if [ `whoami` == 'root' ]
+then {
+  echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
+  echo "Aborting."
+  exit 1
+}
+fi
+
 # check whether RPM installed, and if it is, remove any old wine rpm.
 hash rpm &>/dev/null
 RET=$?
@@ -166,8 +237,10 @@ if [ $RET -eq 0 ]; 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...
-      rpm -e wine; RET=$?
+      su -c "rpm -e wine; RET=$?"
       if [ $RET -eq 0 ]; then
         echo Done.
       else
@@ -176,17 +249,27 @@ if [ $RET -eq 0 ]; then
       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)"
+      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
 
+# check whether wine binary still available
+if [ -n "`which wine 2>/dev/null|grep '/wine'`" ]; 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."
+  std_sleep
+fi
+
 # run the configure script, if necessary
 
 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
 then {
+  echo
   echo "I see that WINE has already been configured, so I'll skip that."
   std_sleep
   # load configure results
@@ -195,7 +278,7 @@ then {
 else {
   echo "Running configure..."
   echo
-  if ! ./configure $CONFARGS
+  if ! ./configure -C $CONFARGS
   then {
     echo
     echo "Configure failed, aborting install."
@@ -213,99 +296,127 @@ else {
     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 ]
+# now do the compilation and install, we need to always do this because we 
+# don't want the 'make install' command we might run to run 'make' as root
+if [ `whoami` != 'root' ]
 then {
-  echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
-  std_sleep
-}
-else {
-  echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
-  echo "in the meantime..."
+  # ask the user if they want to build and install wine
   echo
-  std_sleep
-  if ! { make depend && make; }
+  echo "We need to install wine as root user, do you want us to build wine,"
+  echo "'su root' and install Wine?  Enter 'no' to continue without installing"
+  conf_yesno_answer "(yes/no) "
+
+  if [ "$ANSWER" = "yes" ]
   then {
-    echo
-    echo "Compilation failed, aborting install."
-    exit 1
-  }
-  fi
-  echo
-}
-fi
+    # start out with the basic command
+    sucommand="make install"
 
-# and installation, if root
+    # if the user doesn't have $libdir in their ld.so.conf add this
+    # to our sucommand string
+    if [ -f /etc/ld.so.conf ]
+    then
+      if ! grep -qs "$libdir" /etc/ld.so.conf
+      then {
+       echo
+       echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
+       echo "when we perform the install..."
+        sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
+      }
+      fi
+      # run ldconfig always just in case some updated files dont get linked
+      sucommand="$sucommand;$ac_cv_path_LDCONFIG"
+    fi
 
-if [ `whoami` != 'root' ]
-then {
-  echo "You aren't root, so I'll skip the make install."
+    echo
 
-  # 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."
-  echo
+    echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
+    echo "in the meantime..."
+    echo
+    std_sleep
 
-  # see if wine is installed on the users system, if not prompt them
-  # and then exit
-  if [ ! `which wine` ]
-  then
-    echo "Could not find wine on your system.  Run wineinstall as root to install wine"
-    echo "before re-running wineinstall as a user."
+    # 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
     echo
-    echo "Exiting wineinstall"
-    exit 1;
-  fi
-}
-else {
-  echo "Now installing binaries onto the system..."
-  echo
-  std_sleep
-  if ! make install
-  then {
+
+    echo "Performing 'make install' as root to install binaries, enter root password"
+
+    std_sleep
+
+    if ! su root -c "$sucommand"
+    then {
+      echo
+      echo "Either you entered an incorrect password or we failed to run"
+      echo "'$sucommand' correctly."
+      echo "If you didn't enter an incorrect password then please report this"
+      echo "error and any steps to possibly reproduce it to"
+      echo "http://bugs.winehq.com/"
+      echo
+      echo "Installation failed, aborting."
+      exit 1
+    }
+    fi
+
     echo
-    echo "Installation failed, aborting."
-    exit 1
+
+    # see if wine is installed on the users system, if not prompt them
+    # and then exit
+    if [ ! `which wine` ]
+    then
+      echo "Could not find wine on your system.  Run wineinstall as root to install wine"
+      echo "before re-running wineinstall as a user."
+      echo
+      echo "Exiting wineinstall"
+      exit 1;
+    fi
   }
-  fi
-  if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
-  then {
+  else {
+    # user didn't want to install wine so tell them about running from the
+    # current directory and set some stuff up for them
+
+    # 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."
     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
 }
-fi
+else {
+  echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
+  echo "Aborting."
+  exit 1
+}
+fi # [ `whoami` != 'root' ]
 
 }
 fi # BINDIST
 
 # now check whether we should generate wine.conf
 if [ -z "$DOGLOBALCONF" ]
-then DOGLOBALCONF=auto
+then
+  DOGLOBALCONF=auto
 fi
 
 if [ "$DOGLOBALCONF" = 'auto' ]
@@ -333,28 +444,27 @@ then {
     conf_yesno_answer "(yes/no) "
     DOLOCALCONF="$ANSWER"
   else
-    echo "Create local config file ~/.wine/config?"
-    conf_yesno_answer "(yes/no) "
-    echo
-    DOLOCALCONF="$ANSWER"
-    if [ "$ANSWER" = 'no' ]
+    # if the user has an existing config file ask them if they want us to
+    # overwrite it, otherwise just ask them if they want to create one
+    if [ -f "$LCONF" ]
     then
-      conf_question high need_root \
-        "Aborting install. Try again as root to generate a system wine.conf."
-      exit 1
-    fi
-  fi
-
-  if [ -f "$LCONF" ]
-  then
-    echo "Found existing $LCONF, if you continue this file will be"
-    echo "overwritten.  Continue running wineinstall?"
-    conf_yesno_answer "(yes/no) "
-    echo
-    if [ "$ANSWER" = 'no' ]
-    then
-      echo "Exiting wineinstall"
-      exit 1
+      echo "Found existing $LCONF, do you want to overwrite this"
+      echo "existing Wine configuration file?"
+      conf_yesno_answer "(yes/no) "
+      DOLOCALCONF="$ANSWER"
+      echo
+    else {
+      echo "Create local config file ~/.wine/config?"
+      conf_yesno_answer "(yes/no) "
+      DOLOCALCONF="$ANSWER"
+      echo
+      if [ "$ANSWER" = 'no' ]
+      then
+        conf_question high need_root \
+          "Aborting install. Try again as root to generate a system wine.conf."
+        exit 1
+      fi
+    }
     fi
   fi
 }
@@ -370,7 +480,7 @@ then {
     then {
       rm -f $TMPCONF $TMPREG > /dev/null
 
-      echo " not found."
+      echo " not found. (no matching /etc/fstab mount entry found)"
       conf_question low do_without_windows \
        "Windows was not found on your system, so I assume you want" \
        "a Wine-only installation. Am I correct?"
@@ -455,6 +565,7 @@ then {
     echo "Configuring Wine for a no-windows install in $CROOT..."
   
     create_windows_directories
+    configure_wine_applications
   }
   fi
 
@@ -508,11 +619,14 @@ fi
 # (not to be done if windows registry exists)
 if [ "$DOREG" = 'auto' ]
 then {
+  CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^\"Path\" = \"\(.*\)\"/\1/p' $LCONF`
   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
+  elif [ -f "$CROOT/WINNT/system32/config/system" ]
+  then DOREG=no 
   else DOREG=yes
   fi
   if [ "$DOREG" = 'yes' ]
@@ -528,14 +642,14 @@ if [ "$DOREG" = 'yes' ]
 then {
   if [ "$BINDIST" = 'no' ]
   then {
-    echo "Compiling regapi..."
-    (cd programs/regapi; make)
+    echo "Compiling regedit..."
+    (cd programs/regedit; make)
     echo
   }
   fi
   echo "Preparing to install default Wine registry entries..."
 
-  # edit config files so we don't have to run regapi under X
+  # edit config files so we don't have to run regedit under X
   if [ "$CONVCONF" = 'yes' ]
   then
     mv $WINEINI $WINEINI.new
@@ -550,26 +664,26 @@ then {
 
   echo "Installing default Wine registry entries..."
   echo
-  if ! $REGAPI setValue < $TMPREG > /dev/null
+  if ! $REGEDIT $TMPREG > /dev/null
   then {
     rm -f $TMPREG
     echo "Registry install failed."
-    conf_reset_question regapi_error
-    conf_question high regapi_error
+    conf_reset_question regedit_error
+    conf_question high regedit_error
     exit 1
   }
   else {
-    # if we are converting from a .winerc file, running regapi once
+    # if we are converting from a .winerc file, running regedit once
     # will ONLY convert .winerc -> ~/.wine/config, it will not import the
-    # registry data.  so if we are converting we need to run regapi twice
+    # registry data.  so if we are converting we need to run regedit twice
     if [ "$CONVCONF" = 'yes' ]
     then
-      if ! $REGAPI setValue < $TMPREG > /dev/null
+      if ! $REGEDIT $TMPREG > /dev/null
       then
         rm -f $TMPREG
         echo "Registry install failed."
-        conf_reset_question regapi_error
-        conf_question high regapi_error
+        conf_reset_question regedit_error
+        conf_question high regedit_error
         exit 1
       else
         echo