wineinstall 8.22 KB
Newer Older
1 2
#!/bin/bash
# WINE Installation script
3
# Can do almost everything from compiling to configuring...
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
# 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
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20
#
21

22
#--- defaults (change these if you are a packager)
23
CONFARGS=""                   # configure args, e.g. --prefix=/usr
24
prefix=/usr/local             # installation prefix
25
bindir=$prefix/bin            # where winelib apps will be (or are) installed
26
libdir=$prefix/lib            # where libwine.so will be (or is) installed
27
BINDIST=no                    # whether called from a binary package config script
28

29 30
# functions

31 32 33 34
function std_sleep {
  sleep 1
}

35 36 37 38 39 40 41
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"
42
  while [ $# -gt 0 ] && shift
43 44 45 46 47 48 49
  do {
    echo "$LINE"
    LINE="$1"
  }
  done
}

50 51 52 53 54 55
function conf_reset_question {
  # parameters: $1 = question-id
  # this is used to flush any cached answers and "already-displayed" flags
  shift # dummy command
}

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
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
}

71 72
# startup...

73
echo "WINE Installer v0.75"
74
echo
75 76 77 78

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

79 80
  if ! [ -f configure ]
  then {
81 82 83 84 85 86 87 88 89 90
    if [ -f ../configure ]
    then {
      pushd ..
    }
    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
91 92
  }
  fi
93

94
  if [ `whoami` = 'root' ]
95 96 97 98 99 100
  then {
    echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
    echo "Aborting."
    exit 1
  }
  fi
101

102 103 104 105 106 107 108 109
  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

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  # check whether RPM installed, and if it is, remove any old wine rpm.
  hash rpm &>/dev/null
  RET=$?
  if [ $RET -eq 0 ]; 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
128
      else
129 130 131 132 133
        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
134
      fi
135
    fi
136 137
  fi

138 139 140 141 142
  # 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."
143 144
    echo "(If you previously tried to install from source manually, "
    echo "run 'make uninstall' from the wine root directory)"
145 146
    std_sleep
  fi
Andreas Mohr's avatar
Andreas Mohr committed
147

148
  # run the configure script, if necessary
149

150
  if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
151 152
  then {
    echo
153 154 155 156
    echo "I see that WINE has already been configured, so I'll skip that."
    std_sleep
    # load configure results
    . ./config.cache
157
  }
158 159 160
  else {
    echo "Running configure..."
    echo
161
    if ! ./configure -C $CONFARGS --prefix=$prefix
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    then {
      echo
      echo "Configure failed, aborting install."
      rm -f config.cache
      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
    }
    fi
180 181
  }
  fi
182

183 184 185
  # 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' ]
186
  then {
187 188 189 190 191
    # ask the user if they want to build and install wine
    echo
    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) "
192
    ROOTINSTALL="$ANSWER"
193

194
    if [ "$ROOTINSTALL" = "yes" ]
195 196 197 198 199 200 201 202
    then {
      # start out with the basic command
      sucommand="make install"

      # 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
203
        if ! grep -s "$libdir" /etc/ld.so.conf >/dev/null 2>&1
204 205 206 207 208 209 210
        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
211
        # run ldconfig always just in case some updated files don't get linked
212 213
        sucommand="$sucommand;$ac_cv_path_LDCONFIG"
      fi
214 215
    }
    fi # [ "$ROOTINSTALL" = "yes" ]
216

217
    echo
218

219 220 221 222
    echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
    echo "in the meantime..."
    echo
    std_sleep
223

224 225 226 227
    # try to just make wine, if this fails 'make depend' and try to remake
    if ! { make; }
    then {
      if ! { make depend && make; }
228
      then {
229 230 231
        echo
        echo "Compilation failed, aborting install."
        exit 1
232 233
      }
      fi
234 235 236 237 238
    }
    fi

    if [ "$ROOTINSTALL" = "yes" ]
    then {
239
      echo
240

241
      echo "Performing 'make install' as root to install binaries, enter root password"
242

243
      std_sleep
244

245
      if ! su root -c "$sucommand"
246
      then {
247 248 249 250
	echo
	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"
251
        then {
252
	     echo
253 254 255 256
             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"
257
             echo "http://bugs.winehq.org/"
258 259 260 261 262 263
             echo
             echo "Installation failed, aborting."
             exit 1
         }
         fi
       }
264 265
      fi

266
      echo
267

268 269 270 271 272 273 274 275 276 277
      # 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
278 279

      WINEINSTALLED=yes
280 281
    }
    else {
282
      WINEINSTALLED=no
283
    }
284
    fi # [ "$ROOTINSTALL" = "yes" ]
285
  }
286
  fi # [ `whoami` != 'root' ]
287

288 289 290
}
fi # BINDIST

291 292 293 294 295
if [ "$WINEINSTALLED" = 'no' ]
then
    tools/wineprefixcreate --use-wine-tree .
else
    wineprefixcreate
296
fi
297
echo
298 299


300
# it's a wrap
301
echo
302
echo "Installation complete for now. Good luck (this is still beta software)."
303 304
echo "If you have problems with WINE, please read the documentation first,"
echo "as many kinds of potential problems are explained there."
305 306

exit 0