Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Script to create the initial WINEPREFIX directory |
| 4 | # |
| 5 | # Copyright 1999 Ove Kåven |
| 6 | # Copyright 2004 Chris Morgan |
| 7 | # Copyright 2004 Alexandre Julliard |
| 8 | # |
| 9 | # This library is free software; you can redistribute it and/or |
| 10 | # modify it under the terms of the GNU Lesser General Public |
| 11 | # License as published by the Free Software Foundation; either |
| 12 | # version 2.1 of the License, or (at your option) any later version. |
| 13 | # |
| 14 | # This library is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | # Lesser General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU Lesser General Public |
| 20 | # License along with this library; if not, write to the Free Software |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 22 | # |
| 23 | |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 24 | usage() |
| 25 | { |
| 26 | echo "Usage: $0 [options]" |
| 27 | echo "" |
| 28 | echo "Options:" |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 29 | echo " -h, --help Display this message" |
| 30 | echo " --prefix <dir> Directory to create (default: \$WINEPREFIX or ~/.wine)" |
| 31 | echo " -q, --quiet Don't print status messages" |
Alexandre Julliard | 3b5875e | 2005-04-20 13:12:14 +0000 | [diff] [blame] | 32 | echo " -w, --wait Wait for the wineserver to exit before returning" |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 33 | echo "" |
| 34 | } |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 35 | |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 36 | set -e |
| 37 | |
Pierre d'Herbemont | b1be724 | 2006-03-11 21:12:11 +0100 | [diff] [blame] | 38 | bindir="" |
| 39 | case "$0" in |
| 40 | */*) |
| 41 | # $0 contains a path, use it |
| 42 | bindir=`dirname "$0"` |
| 43 | ;; |
| 44 | *) |
| 45 | # no directory in $0, search in PATH |
| 46 | saved_ifs=$IFS |
| 47 | IFS=: |
| 48 | for d in $PATH |
| 49 | do |
| 50 | IFS=$saved_ifs |
| 51 | if [ -x "$d/$0" ] |
| 52 | then |
| 53 | bindir="$d" |
| 54 | break |
| 55 | fi |
| 56 | done |
| 57 | ;; |
| 58 | esac |
| 59 | |
| 60 | bindir=`cd "$bindir" && pwd` |
| 61 | dlldir="$bindir/@bintodlldir@" |
| 62 | datadir="$bindir/@bintodatadir@" |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 63 | |
Alexandre Julliard | 3b5875e | 2005-04-20 13:12:14 +0000 | [diff] [blame] | 64 | do_wait=0 |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 65 | quiet=0 |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 66 | |
Alexandre Julliard | c33fbc0 | 2006-03-17 12:34:50 +0100 | [diff] [blame] | 67 | if [ ! -f "$dlldir/ntdll.dll.so" -a \ |
| 68 | -x "$bindir/../server/wineserver" -a \ |
| 69 | -f "$bindir/../dlls/ntdll/ntdll.dll.so" ] |
| 70 | then |
| 71 | # running from the wine source tree |
| 72 | topdir=`cd "$bindir/.." && pwd` |
| 73 | WINELOADER="$topdir/wine" |
| 74 | WINESERVER="$topdir/server/wineserver" |
| 75 | if [ -n "$LD_LIBRARY_PATH" ] |
| 76 | then |
Srivatsa Kanchi, R | ff82ce2 | 2006-10-11 14:51:13 +0530 | [diff] [blame] | 77 | LD_LIBRARY_PATH="$topdir/libs/wine:$LD_LIBRARY_PATH" |
Alexandre Julliard | c33fbc0 | 2006-03-17 12:34:50 +0100 | [diff] [blame] | 78 | else |
Srivatsa Kanchi, R | ff82ce2 | 2006-10-11 14:51:13 +0530 | [diff] [blame] | 79 | LD_LIBRARY_PATH="$topdir/libs/wine" |
Alexandre Julliard | c33fbc0 | 2006-03-17 12:34:50 +0100 | [diff] [blame] | 80 | fi |
| 81 | export LD_LIBRARY_PATH |
| 82 | |
| 83 | # find the source directory |
| 84 | link=`readlink "$WINELOADER"` |
| 85 | if [ -z "$link" ] |
| 86 | then |
| 87 | topsrcdir="$topdir" |
| 88 | else |
| 89 | link=`dirname "$link"` |
| 90 | case "$link" in |
| 91 | /*) topsrcdir=`cd "$link/.." && pwd` ;; |
| 92 | *) topsrcdir=`cd "$topdir/$link/.." && pwd` ;; |
| 93 | esac |
| 94 | fi |
| 95 | dlldir="$topdir/programs" |
| 96 | datadir="$topsrcdir/tools" |
| 97 | fi |
| 98 | |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 99 | while [ $# -gt 0 ] |
| 100 | do |
| 101 | case "$1" in |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 102 | -h|--help) |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 103 | usage |
| 104 | exit 0 |
| 105 | ;; |
| 106 | --prefix) |
| 107 | WINEPREFIX="$2" |
| 108 | shift 2 |
| 109 | ;; |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 110 | -q|--quiet) |
| 111 | quiet=1 |
| 112 | shift |
| 113 | ;; |
Alexandre Julliard | 3b5875e | 2005-04-20 13:12:14 +0000 | [diff] [blame] | 114 | -w|--wait) |
| 115 | do_wait=1 |
| 116 | shift |
| 117 | ;; |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 118 | --use-wine-tree) |
Alexandre Julliard | c33fbc0 | 2006-03-17 12:34:50 +0100 | [diff] [blame] | 119 | # ignored, autodetected now |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 120 | shift 2 |
| 121 | ;; |
| 122 | *) |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 123 | echo "Unknown option $1" |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 124 | usage |
| 125 | exit 1 |
| 126 | ;; |
| 127 | esac |
| 128 | done |
| 129 | |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 130 | WINEPREFIX="${WINEPREFIX:-$HOME/.wine}" |
| 131 | |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 132 | if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then : |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 133 | else |
Alexandre Julliard | 04869eb | 2004-05-11 04:29:18 +0000 | [diff] [blame] | 134 | echo "Could not create $WINEPREFIX, aborting" |
| 135 | exit 1 |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 136 | fi |
| 137 | |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 138 | WINEPREFIX=`cd "$WINEPREFIX" && pwd` |
Alexandre Julliard | 1c5b8b1 | 2004-05-14 00:43:50 +0000 | [diff] [blame] | 139 | |
| 140 | # Create the drive symlinks |
| 141 | |
| 142 | if [ ! -d "$WINEPREFIX/dosdevices" ] |
| 143 | then |
| 144 | mkdir "$WINEPREFIX/dosdevices" |
| 145 | [ -d "$WINEPREFIX/drive_c" ] || mkdir "$WINEPREFIX/drive_c" |
| 146 | ln -s "../drive_c" "$WINEPREFIX/dosdevices/c:" |
| 147 | ln -s "/" "$WINEPREFIX/dosdevices/z:" |
| 148 | fi |
| 149 | |
| 150 | CROOT="$WINEPREFIX/dosdevices/c:" |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 151 | |
| 152 | # Create the directory tree |
| 153 | |
| 154 | for i in \ |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 155 | "$CROOT/windows" \ |
| 156 | "$CROOT/windows/command" \ |
| 157 | "$CROOT/windows/fonts" \ |
| 158 | "$CROOT/windows/inf" \ |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 159 | "$CROOT/windows/system" \ |
Alexandre Julliard | 19c1af5 | 2005-08-15 14:53:35 +0000 | [diff] [blame] | 160 | "$CROOT/windows/system32" \ |
| 161 | "$CROOT/windows/system32/drivers" \ |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 162 | "$CROOT/windows/temp" |
| 163 | do |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 164 | [ -d "$i" ] || mkdir "$i" |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 165 | done |
| 166 | |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 167 | # Copy the .inf script and run it |
| 168 | |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 169 | cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf" |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 170 | export WINEPREFIX |
Pierre d'Herbemont | 6997ce7 | 2006-05-25 15:20:59 +0200 | [diff] [blame] | 171 | "${WINELOADER:-$bindir/wine}" rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf |
Alexandre Julliard | bd60364 | 2004-04-01 05:03:27 +0000 | [diff] [blame] | 172 | |
| 173 | # Wait for the wineserver to finish |
| 174 | |
Alexandre Julliard | 3b5875e | 2005-04-20 13:12:14 +0000 | [diff] [blame] | 175 | if [ $do_wait = 1 ] |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 176 | then |
Pierre d'Herbemont | 6997ce7 | 2006-05-25 15:20:59 +0200 | [diff] [blame] | 177 | "${WINESERVER:-$bindir/wineserver}" -w |
Alexandre Julliard | 3b5875e | 2005-04-20 13:12:14 +0000 | [diff] [blame] | 178 | fi |
| 179 | |
| 180 | if [ $quiet = 0 ] |
| 181 | then |
| 182 | echo "$WINEPREFIX updated successfully." |
Alexandre Julliard | 5f27ca2 | 2004-05-05 22:09:09 +0000 | [diff] [blame] | 183 | fi |