wineinstall 8.23 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
  # check whether wine binary still available
139 140
  if [ -n "`wine --version 2>/dev/null`" ]
  then
141 142 143
    echo "Warning !! wine binary (still) found, which may indicate"
    echo "a (conflicting) previous installation."
    echo "You might want to abort and uninstall Wine first."
144 145
    echo "(If you previously tried to install from source manually, "
    echo "run 'make uninstall' from the wine root directory)"
146 147
    std_sleep
  fi
Andreas Mohr's avatar
Andreas Mohr committed
148

149
  # run the configure script, if necessary
150

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

184 185 186
  # 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' ]
187
  then {
188 189 190 191 192
    # 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) "
193
    ROOTINSTALL="$ANSWER"
194

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

218
    echo
219

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

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

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

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

244
      std_sleep
245

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

267
      echo
268

269 270
      # see if wine is installed on the users system, if not prompt them
      # and then exit
271
      if [ -z "`wine --version 2>/dev/null`" ]
272 273 274 275 276 277 278
      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
279 280

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

289 290 291
}
fi # BINDIST

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


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

exit 0