Add more missing defs.
[wine] / tools / wineinstall
index eb0dde4..a4610c4 100755 (executable)
 # 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
-#  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
-# Oct 29 2000 - Ove Kåven
-#  added --enable-opengl to default confargs
-#  added conf_question, conf_yesno_answer, and conf_string_answer functions
-#  added DEFCAT variable
-# (later that day...)
-#  added conf_reset_question function
-#  added file existence checks to the registry copying
-#  fixed problem with no-windows directory creation
-#  some text reformatting from Eric Maryniak
-# Jan 5 2000 - Chris Morgan
-#  use default config file in /documentation/samples/config
-#  replace .winerc with ~/.wine/config in printed text
-#  added user question to convert .winerc file(if exists) or use the default
-#    config file
-#  add conf_question to allow root to install a local config file and
-#    registry
-# Jan 12 2000 - Chris Morgan
-#  distinguish between creating local and global config files
-#  display a message about the status of global config files
-#  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)
-# Aug 29 2002 - Rok Mandeljc <rok.mandeljc@gimb.org>
-#  -added two symlinks; windows/winhelp.exe and windows/winhlp32.exe because it seems
-#   that some apps look for winhlp32.exe/winhelp to display help
-#
 
 #--- defaults (change these if you are a packager)
-CONFARGS="--enable-opengl"    # configure args, e.g. --prefix=/usr --sysconfdir=/etc
+CONFARGS=""                   # configure args, e.g. --prefix=/usr --sysconfdir=/etc
 prefix=/usr/local             # installation prefix
 sysconfdir=$prefix/etc        # where wine.conf and the global registry are supposed to be
 bindir=$prefix/bin            # where winelib apps will be (or are) installed
 libdir=$prefix/lib            # where libwine.so will be (or is) installed
 exdir=documentation/samples   # where the sample system.ini resides
-GCONF=$sysconfdir/wine.conf   # default path of the wine.conf global config file
 LCONF=~/.wine/config          # default path of the local config file
 BINDIST=no                    # whether called from a binary package config script
-DOGLOBALCONF=auto             # whether to autogenerate wine.conf
 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
-
-# "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       # path to the wineconf perl script
 
 # this is only for no-windows installs
 WINEINI=$exdir/config         # path to the default wine config file (also used by wineconf)
-WININI=/dev/null              # path to the default win.ini
-SYSTEMINI=$exdir/system.ini   # path to the default system.ini
-REGEDIT=programs/regedit/regedit       # path to the regedit winelib application
-DEFREG=winedefault.reg        # path of the registry file to be fed to regedit
 # CROOT=/var/wine             # 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
 
 # temporary files used by the installer
 TMPCONF=/tmp/wineinstall.conf
-TMPREG=/tmp/wineinstall.reg
 
 # functions
 
@@ -145,7 +59,7 @@ function conf_question {
   shift 2
   echo
   local LINE="$1"
-  while shift
+  while [ $# -gt 0 ] && shift
   do {
     echo "$LINE"
     LINE="$1"
@@ -174,47 +88,9 @@ function conf_string_answer {
   read ANSWER
 }
 
-function create_windows_directories {
-  for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/system32" \
-              "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
-              "$CROOT/Program Files" "$CROOT/Program Files/Common Files" \
-              "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator" \
-              "$CROOT/windows/Fonts" "$CROOT/windows/Start Menu/Programs/Startup"
-  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"
-}
-
-#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 $libdir/wine/$1.exe.so $2
-}
-
-#puts windows applications replacements to windows directories,
-#configures them
-function configure_wine_applications {
-  link_app notepad      "$CROOT/windows/notepad.exe"
-  link_app regedit      "$CROOT/windows/regedit.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"
-  link_app uninstaller  "$CROOT/windows/uninstall.exe"
-  link_app winhelp      "$CROOT/windows/winhelp.exe"
-  link_app winhelp      "$CROOT/windows/winhlp32.exe"
-}
-
 # startup...
 
-echo "WINE Installer v0.73"
+echo "WINE Installer v0.74"
 echo
 
 if [ "$BINDIST" = 'no' ]
@@ -235,7 +111,7 @@ then {
   }
   fi
 
-  if [ `whoami` == 'root' ]
+  if [ `whoami` = 'root' ]
   then {
     echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
     echo "Aborting."
@@ -243,6 +119,14 @@ then {
   }
   fi
 
+  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
+
   # check whether RPM installed, and if it is, remove any old wine rpm.
   hash rpm &>/dev/null
   RET=$?
@@ -276,6 +160,8 @@ 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
 
@@ -292,7 +178,7 @@ then {
   else {
     echo "Running configure..."
     echo
-    if ! ./configure -C $CONFARGS
+    if ! ./configure -C $CONFARGS --prefix=$prefix
     then {
       echo
       echo "Configure failed, aborting install."
@@ -334,7 +220,7 @@ then {
       # to our sucommand string
       if [ -f /etc/ld.so.conf ]
       then
-        if ! grep -qs "$libdir" /etc/ld.so.conf
+        if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
         then {
           echo
           echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
@@ -342,7 +228,7 @@ then {
           sucommand="$sucommand;echo $libdir>>/etc/ld.so.conf"
         }
         fi
-        # run ldconfig always just in case some updated files dont get linked
+        # run ldconfig always just in case some updated files don't get linked
         sucommand="$sucommand;$ac_cv_path_LDCONFIG"
       fi
     }
@@ -378,16 +264,20 @@ then {
 
       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
-      }
+       if ! 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
 
       echo
@@ -402,24 +292,11 @@ then {
         echo "Exiting wineinstall"
         exit 1;
       fi
+
+      WINEINSTALLED=yes
     }
     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
+      WINEINSTALLED=no
     }
     fi # [ "$ROOTINSTALL" = "yes" ]
   }
@@ -429,25 +306,6 @@ then {
 fi # BINDIST
 
 # now check whether we should generate wine.conf
-if [ -z "$DOGLOBALCONF" ]
-then
-  DOGLOBALCONF=auto
-fi
-
-if [ "$DOGLOBALCONF" = 'auto' ]
-then {
-  # see if we already have a system wine.conf
-  if [ ! -f $GCONF ] && [ `whoami` = 'root' ]
-  then
-    DOGLOBALCONF=no
-    echo "Creation of a global config file is not supported in wineinstall at this"
-    echo "time.  When the configuration architecture is cleaned up this functionality"
-    echo "will be restored to wineinstall."
-    echo
-  fi
-}
-fi
-
 if [ "$DOLOCALCONF" = 'auto' ]
 then {
   # see if the user is root, if so, explicitly ask them if they want a
@@ -510,7 +368,7 @@ then {
     echo -n "Searching for an existing Windows installation..."
     if ! $WINECONF -inifile "$WINEINI" > $TMPCONF 2>/dev/null
     then {
-      rm -f $TMPCONF $TMPREG > /dev/null
+      rm -f $TMPCONF > /dev/null
 
       echo " not found. (no matching /etc/fstab mount entry found)"
       conf_question low do_without_windows \
@@ -530,11 +388,23 @@ then {
     else {
       echo " found."
 
-      conf_reset_question windows_found
-      conf_question low windows_found \
-       "Created $LCONF using your existing Windows installation." \
-       "You probably want to review the file, though."
-      DOWINE=no
+      conf_question low do_without_windows \
+       "Windows was found on your system, and so we can use the Windows" \
+       "Drive as our Wine drive. You may, however, wish to create a clean" \
+       "Wine install anyways."
+      conf_yesno_answer "Should I use the Windows drive for the Wine install? (yes/no) "
+      if [ "$ANSWER" = 'yes' ]
+      then {
+        conf_reset_question windows_found
+        conf_question low windows_found \
+         "Created $LCONF using your existing Windows installation." \
+         "You probably want to review the file, though."
+        DOWINE=no
+      }
+      else {
+        DOWINE=yes
+      }
+      fi
     }
     fi
   }
@@ -552,59 +422,57 @@ if [ "$DOWINE" = 'yes' ]
 then {
   # set an appropriate DCROOT
   if [ `whoami` != 'root' ]
-  then DCROOT=~/c
+  then DCROOT=~/.wine/drive_c
   else DCROOT=/c
   fi
 
-  if [ -f ~/.winerc ]
-  then {
-    conf_question medium convert_config \
-     "I found the old version Wine config file, .winerc, in your " \
-     "home directory.  I can convert this to the new format or use the" \
-     "new default Wine config file. Convert?"
-    conf_yesno_answer "(yes/no) "
-    if [ "$ANSWER" = 'yes' ]
-    then {
-      WINEINI=~/.winerc
-      CONVCONF=yes
-    }
-    fi
-  }
-  else {
-
-    conf_question low drivec_path \
+  conf_question low drivec_path \
      "Configuring Wine without Windows." \
      "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
      "start menu entries, and other things your applications may need to install." \
      "Where would you like your fake C drive to be placed?"
-    while [ -z "$CROOT" ]
-    do {
-      conf_string_answer "(default is $DCROOT) "
-      [ -z "$ANSWER" ] && ANSWER="$DCROOT"
-      if ! [ -d "$ANSWER" ]
-      then {
-        if mkdir -p "$ANSWER"
-        then CROOT="$ANSWER"
-        else
+  while [ -z "$CROOT" ]
+  do {
+    conf_string_answer "(default is $DCROOT) "
+    [ -z "$ANSWER" ] && ANSWER="$DCROOT"
+    if ! [ -d "$ANSWER" ]
+    then {
+      if mkdir -p "$ANSWER"
+      then CROOT="$ANSWER"
+      else
           echo "Directory $ANSWER can't be created !"
           conf_reset_question drivec_path
-        fi
-      }
-      else CROOT="$ANSWER"
       fi
     }
-    done
-    echo "Configuring Wine for a no-windows install in $CROOT..."
-
-    create_windows_directories
-    configure_wine_applications
+    else CROOT="$ANSWER"
+    fi
   }
+  done
+  echo "Configuring Wine for a no-windows install in $CROOT..."
+
+  if [ ! -d ~/.wine/dosdevices ]
+  then
+    [ -d ~/.wine ] || mkdir ~/.wine
+    mkdir ~/.wine/dosdevices
+    ln -s /mnt/fd0 ~/.wine/dosdevices/a:
+    ln -s $CROOT ~/.wine/dosdevices/c:
+    ln -s /cdrom ~/.wine/dosdevices/d:
+    ln -s /tmp ~/.wine/dosdevices/e:
+    ln -s ~ ~/.wine/dosdevices/f:
+    ln -s / ~/.wine/dosdevices/z:
+  fi
+
+  if [ "$WINEINSTALLED" = 'no' ]
+  then
+      tools/wineprefixcreate --use-wine-tree .
+  else
+      wineprefixcreate
   fi
 
   # create $LCONF using the default config file $WINEINI
-  if [ "$DOLOCALCONF" = 'yes' ] && [ "$CONVCONF" = 'no' ]
+  if [ "$DOLOCALCONF" = 'yes' ]
   then {
-    sed "s|\"Path\" = \"/c\"\$|\"Path\" = \"${CROOT}\"|" $WINEINI > $TMPCONF
+    cp $WINEINI $TMPCONF
     conf_reset_question default_config
     conf_question low default_config \
      "Created $LCONF using default Wine configuration." \
@@ -627,123 +495,11 @@ then
   then
     mkdir ~/.wine
   fi
-
-  if [ "$CONVCONF" = 'no' ]
-  then
-    cp $TMPCONF $LCONF > /dev/null
-  fi
+  cp $TMPCONF $LCONF > /dev/null
 else
   DOREG=no
 fi
 
-#install the global config file $GCONF
-if [ "$DOGLOBALCONF" = 'yes' ]
-then
-  if [ ! -f $sysconfdir ]
-  then
-    mkdir -p $sysconfdir
-  fi
-
-  cp $TMPCONF $GCONF > /dev/null
-fi
-
-# check whether we need to install default registry
-# (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' ]
-  then echo "Not found, default Wine registry will be installed."
-  else echo "Windows registry found, will not install default Wine registry."
-  fi
-  echo
-}
-fi
-
-# install default registry entries
-if [ "$DOREG" = 'yes' ]
-then {
-  if [ "$BINDIST" = 'no' ]
-  then {
-    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 regedit under X
-  if [ "$CONVCONF" = 'yes' ]
-  then
-    mv $WINEINI $WINEINI.new
-    sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $WINEINI.new > $WINEINI
-  else
-    mv $LCONF $LCONF.new
-    sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"ttydrv\"/" $LCONF.new > $LCONF
-  fi
-
-  # create a temporary wineinstall.reg with fixed debugger path
-  $DEFCAT $DEFREG | sed "s|debugger/winedbg|${DEBUGGER}|" > $TMPREG
-
-  echo "Installing default Wine registry entries..."
-  echo
-  if ! $REGEDIT $TMPREG > /dev/null
-  then {
-    rm -f $TMPREG
-    echo "Registry install failed."
-    conf_reset_question regedit_error
-    conf_question high regedit_error
-    exit 1
-  }
-  else {
-    # 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 regedit twice
-    if [ "$CONVCONF" = 'yes' ]
-    then
-      if ! $REGEDIT $TMPREG > /dev/null
-      then
-        rm -f $TMPREG
-        echo "Registry install failed."
-        conf_reset_question regedit_error
-        conf_question high regedit_error
-        exit 1
-      else
-        echo
-        echo "Registry entries successfully installed."
-      fi
-    else
-      echo
-      echo "Registry entries successfully installed."
-    fi
-  }
-  fi
-  rm -f $TMPREG
-  if [ "$SYSREG" = 'auto' ]
-  then SYSREG=yes
-  fi
-
-  # if we converted we need to change the graphics driver back and
-  # restore the original .winerc file
-  if [ "$CONVCONF" = 'yes' ]
-  then
-     mv $WINEINI.new $WINEINI
-  fi
-
-  sed "s/\"GraphicsDriver\" = .*/\"GraphicsDriver\" = \"x11drv\"/" $LCONF > $LCONF.new
-  mv $LCONF.new $LCONF
-}
-fi
-
 # make root's registry global, if desired
 if [ `whoami` = 'root' ] && [ "$DOREG" = 'yes' ] && [ "$SYSREG" = 'yes' ]
 then {
@@ -769,9 +525,6 @@ fi
 if [ -f $TMPCONF ]
 then rm -f $TMPCONF
 fi
-if [ -f $TMPREG ]
-then rm -f $TMPREG
-fi
 
 
 # it's a wrap