wineinstall 13.9 KB
Newer Older
1 2
#!/bin/bash
# WINE Installation script
3
# Can do almost everything from compiling to configuring...
4 5 6

# Mar 31 1999 - Ove Kven
#  First version
7 8 9 10
# Dec 9 1999 - Ove Kven
#  require Xpm
# Feb 25 2000 - Ove Kven
#  auto-add /usr/local/lib to /etc/ld.so.conf
11 12 13 14
# Mar 2 2000 - Ove Kven
#  source rather than grep config.cache
#  use sourced config.cache to start ldconfig
#  reconfigure if config.cache doesn't exist
15 16 17 18 19 20
# Mar 30 2000 - Ove Kven
#  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
21 22
# Apr 9 2000 - Ove Kven
#  make root's registry global (system-default)
23 24 25
# May 9 2000 - Ove Kven
#  use ttydrv when running regapi, so we don't have to run from X
#  change debugger path in registry
26 27 28 29
# Oct 29 2000 - Ove Kven
#  added --enable-opengl to default confargs
#  added conf_question, conf_yesno_answer, and conf_string_answer functions
#  added DEFCAT variable
30 31 32 33 34
# (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
35

36
#--- defaults (change these if you are a packager)
37
CONFARGS=--enable-opengl      # configure args, e.g. --prefix=/usr --sysconfdir=/etc
38
prefix=/usr/local             # installation prefix
39
sysconfdir=$prefix/etc        # where wine.conf and global registry is supposed to be
40
bindir=$prefix/bin            # where winelib apps will be (or is) installed
41 42
libdir=$prefix/lib            # where libwine.so will be (or is) installed
exdir=documentation/samples   # where the example system.ini resides
43 44 45 46 47 48
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
49
SYSREG=yes                    # whether to make root's registry global (system-default)
50 51 52 53 54 55 56 57 58 59

# "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
60
WINECONF=tools/wineconf       # the path of wineconf perl script
61 62

# this is only for no-windows installs
63 64
WINEINI=wine.ini              # the path of default wine.ini (also used by wineconf)
WININI=/dev/null              # the path of default win.ini
65
SYSTEMINI=$exdir/system.ini   # the path of default system.ini
66 67
REGAPI=programs/regapi/regapi # the path of regapi winelib application
DEFREG=winedefault.reg        # the path of the registry file to be fed to regapi
68
# CROOT=/var/wine             # the path of the fake Drive C (asks user if not set)
69
DEFCAT=cat                    # program to cat $DEFREG with (some packages need zcat)
70 71 72 73 74
#--- end of defaults

# temporary files used by the installer
TMPCONF=/tmp/wineinstall.conf
TMPREG=/tmp/wineinstall.reg
75

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
# functions

function conf_question {
  # parameters: $1 = importance, $2 = question-id, $3+ = message lines
  # the first two parameters can be used by e.g. debconf in debian packages
  # but here we just print the message
  shift 2
  echo
  local LINE="$1"
  while shift
  do {
    echo "$LINE"
    LINE="$1"
  }
  done
}

93 94 95 96 97 98
function conf_reset_question {
  # parameters: $1 = question-id
  # this is used to flush any cached answers and "already-displayed" flags
  shift # dummy command
}

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
function conf_yesno_answer {
  unset ANSWER
  while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
  do {
    echo -n "$1"
    read ANSWER
  }
  done
}

function conf_string_answer {
  echo -n "$1"
  read ANSWER
}

114 115
# startup...

116
echo "WINE Installer v0.5"
117
echo
118 119 120 121

if [ "$BINDIST" = 'no' ]
then {

122 123 124 125 126 127 128 129
if ! [ -f configure ]
then {
  echo "You're running this from the wrong directory."
  echo "Change to the Wine directory and try again."
  exit 1
}
fi

130
# check whether RPM installed, and if it is, remove any old wine rpm.
131 132
hash rpm &>/dev/null
RET=$?
133 134
if [ $RET -eq 0 ]; then
  if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
135 136 137
    echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
    conf_yesno_answer "(yes/no) "
    if [ "$ANSWER" = 'yes' ]; then
138 139 140 141 142
      echo Starting wine rpm removal...
      rpm -e wine; RET=$?
      if [ $RET -eq 0 ]; then
        echo Done.
      else
Phil Cole's avatar
Phil Cole committed
143
        echo "FAILED. Probably you aren't installing as root."
144 145 146 147 148
      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 "Have a nice day !"
149
      exit 1
150 151 152 153
    fi 
  fi
fi

154 155
# run the configure script, if necessary

156
if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
157 158
then {
  echo "I see that WINE has already been configured, so I'll skip that."
159 160
  # load configure results
  . ./config.cache
161 162 163 164
}
else {
  echo "Running configure..."
  echo
165
  if ! ./configure $CONFARGS
166 167 168 169 170 171 172
  then {
    echo
    echo "Configure failed, aborting install."
    rm -f config.cache
    exit 1
  }
  fi
173 174
  # load configure results
  . ./config.cache
175
  # make sure X was found
176 177
  eval "$ac_cv_have_x"
  if [ "$have_x" != "yes" ]
178 179 180 181 182
  then {
    echo "Install the X development headers and try again."
    rm -f config.cache
    exit 1
  }
183
  elif [ "$ac_cv_header_X11_xpm_h" != "yes" ]
184 185 186 187 188
  then {
    echo "Install the Xpm development headers and try again."
    rm -f config.cache
    exit 1
  }
189 190 191 192 193 194 195 196 197 198 199
  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 {
200 201
  echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
  echo "in the meantime..."
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
  echo
  if ! { make depend && make; }
  then {
    echo
    echo "Compilation failed, aborting install."
    exit 1
  }
  fi
  echo
}
fi

# and installation, if root

if [ `whoami` != 'root' ]
then {
  echo "You aren't root, so I'll skip the make install."
219 220 221 222 223 224 225
  # 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
Ove Kaaven's avatar
Ove Kaaven committed
226
  DEBUGGER="$PWD/$HDEBUGGER"
227 228 229 230
  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."
231 232 233 234 235 236 237 238 239 240 241
}
else {
  echo "Now installing binaries onto the system..."
  echo
  if ! make install
  then {
    echo
    echo "Installation failed, aborting."
    exit 1
  }
  fi
242
  if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
243 244
  then {
    echo
245 246
    echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
    echo "$libdir" >>/etc/ld.so.conf
247
    echo "Re-running ldconfig..."
248
    eval "$ac_cv_path_LDCONFIG"
249 250
  }
  fi
251 252 253
}
fi

254 255 256
}
fi # BINDIST

257 258 259 260 261 262 263 264
# now check whether we should generate wine.conf
if [ -z "$DOCONF" ]
then DOCONF=auto
fi

if [ "$DOCONF" = 'auto' ]
then {
  # see if we already have a system wine.conf
265
  if [ -f $CONF ]
266 267 268 269 270 271 272 273 274 275 276 277 278 279
  then DOCONF=no
  fi
}
fi

if [ "$DOCONF" != 'no' ]
then {
  if [ `whoami` != 'root' ]
  then {
    CONF=~/.winerc
    if ! [ -f $CONF ]
    then {
      if [ "$DOCONF" != 'yes' ]
      then {
280 281 282 283 284
        conf_question medium make_user_winerc \
         "Since you aren't root, and there's no system wine.conf, I assume" \
         "you want a user-specific .winerc. Am I correct?"
        conf_yesno_answer "(yes/no) "
        DOCONF="$ANSWER"
285 286 287
      }
      fi
      if [ "$DOCONF" = 'no' ]
288
      then {
289 290
        conf_question high need_root \
         "Aborting install. Try again as root to generate a system wine.conf."
291 292
        exit 1
      }
293
      fi
294
      echo
295 296 297 298
    }
    fi
  }
  else {
299
    mkdir -p $sysconfdir
300 301 302 303 304 305
    DOCONF=yes
  }
  fi
}
fi

306 307 308 309 310
# generate wine.conf from existing windows install, if any
if [ "$DOCONF" = 'yes' ]
then {
  if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
  then {
311 312
    echo
    echo -n "Searching for an existing Windows installation..."
313
    if ! $WINECONF -inifile "$WINEINI" > $CONF 2>/dev/null
314 315
    then {
      rm -f $CONF
316 317
      echo " not found."
      conf_question low do_without_windows \
318 319
       "Windows was not found on your system, so I assume you want" \
       "a Wine-only installation. Am I correct?"
320 321
      conf_yesno_answer "(yes/no) "
      if [ "$ANSWER" = 'no' ]
322
      then {
323 324 325
        conf_question high windows_not_found \
         "Aborting install. Make sure your Windows partition is mounted and try again," \
         "or create $CONF manually by copying from $WINEINI and adapting the drive paths."
326 327 328
        exit 1
      }
      fi
329
      DOWINE=yes
330 331
    }
    else {
332
      echo " found."
333
      conf_reset_question windows_found
334 335 336
      conf_question low windows_found \
       "Created $CONF using your existing Windows installation." \
       "You probably want to review the file, though."
337 338 339 340 341 342 343 344 345 346 347 348
      DOWINE=no
    }
    fi
  }
  elif [ "$DOWINE" = 'auto' ]
  then DOWINE=yes
  fi
}
elif [ "$DOWINE" = 'auto' ]
then DOWINE=no
fi

349
# setup a no-windows installation, if necessary
350 351 352 353 354 355
if [ "$DOWINE" = 'yes' ]
then {
  if [ `whoami` != 'root' ]
  then DCROOT=~/c
  else DCROOT=/c
  fi
356
  conf_question low drivec_path \
357 358 359 360
   "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 oyu like your fake C drive to be placed?"
361 362
  while [ -z "$CROOT" ]
  do {
363
    conf_string_answer "(default is $DCROOT) "
364
    if [ -z "$ANSWER" ]
365
    then CROOT="$DCROOT"
366
    elif ! [ -d "$ANSWER" ]
367
    then {
368 369
      if mkdir -p "$ANSWER"
      then CROOT="$ANSWER"
370
      else conf_reset_question drivec_path
371 372
      fi
    }
373
    else CROOT="$ANSWER"
374 375 376 377
    fi
  }
  done
  echo "Configuring Wine for a no-windows install in $CROOT..."
378 379 380 381
  for tdir in "$CROOT/windows" "$CROOT/windows/system" \
              "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
              "$CROOT/Common Files" "$CROOT/Program Files" \
              "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator"
382 383 384 385 386 387
  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 {
Ove Kaaven's avatar
Ove Kaaven committed
388
    sed "s|Path=/c\$|Path=${CROOT}|" $WINEINI > $CONF
389
    conf_reset_question default_config
390 391 392
    conf_question low default_config \
     "Created $CONF using default Wine configuration." \
     "You probably want to review the file, though."
393 394
  }
  fi
Ove Kaaven's avatar
Ove Kaaven committed
395 396 397 398
  # now we really should install the registry
  if [ "$DOREG" = 'auto' ]
  then DOREG=yes
  fi
399 400 401
}
elif [ -z "$CROOT" ]
then {
402
  echo
403 404 405 406 407 408 409 410
  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

# fixup EXTRA_LD_LIBRARY_PATH
411 412
if [ "$DOCONF" = 'yes' ]
then {
413
  echo "Setting EXTRA_LD_LIBRARY_PATH in .winerc to $DLLPATH..."
Ove Kaaven's avatar
Ove Kaaven committed
414
  sed "s|EXTRA_LD_LIBRARY_PATH=.*|EXTRA_LD_LIBRARY_PATH=${DLLPATH}|" $CONF > $CONF.new
415
  mv -f $CONF.new $CONF
416
  echo
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
}
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
435 436 437 438 439 440 441
  echo
}
fi

# install default registry entries
if [ "$DOREG" = 'yes' ]
then {
442 443 444 445 446 447 448 449
  if [ "$BINDIST" = 'no' ]
  then {
    echo "Compiling regapi..."
    echo
    (cd programs/regapi; make)
    echo
  }
  fi
450 451 452 453 454 455 456
  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
457
  $DEFCAT $DEFREG | sed "s|debugger/winedbg|${DEBUGGER}|" > $TMPREG
458

459
  echo "Installing default Wine registry entries..."
460
  echo
461
  if ! $REGAPI --config $TMPCONF setValue < $TMPREG > /dev/null
462
  then {
463 464
    rm -f $TMPCONF $TMPREG
    echo "Registry install failed."
465
    conf_reset_question regapi_error
466
    conf_question high regapi_error
467
    exit 1
468
  }
469 470
  else echo "Registry entries successfully installed."
  fi
471
  rm -f $TMPCONF $TMPREG
472 473 474 475 476 477 478 479 480
  if [ "$SYSREG" = 'auto' ]
  then SYSREG=yes
  fi
}
fi

# make root's registry global, if desired
if [ `whoami` = 'root' ] && [ "$SYSREG" = 'yes' ]
then {
Ove Kaaven's avatar
Ove Kaaven committed
481
  [ -d ~/.wine ] || mkdir ~/.wine
482 483 484
  if ! [ -f $sysconfdir/wine.userreg ]
  then {
    echo "Linking root's user registry hive to the global registry..."
485
    [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
486 487 488 489 490 491
    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..."
492
    [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
493 494
    ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
  }
495 496 497
  fi
}
fi
498 499

# it's a wrap
500 501
echo
echo "Installation complete for now. Good luck (this is still alpha software)."
502 503
echo "If you have problems with WINE, please read the documentation first,"
echo "as many kinds of potential problems are explained there."
504 505

exit 0