wineprefixcreate.in 4.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/sh
#
# Script to create the initial WINEPREFIX directory
#
# Copyright 1999 Ove Kven
# Copyright 2004 Chris Morgan
# Copyright 2004 Alexandre Julliard
#
# 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
21
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 23
#

24 25 26 27 28
usage()
{
    echo "Usage: $0 [options]"
    echo ""
    echo "Options:"
29 30 31
    echo "  -h, --help                 Display this message"
    echo "      --prefix <dir>         Directory to create (default: \$WINEPREFIX or ~/.wine)"
    echo "  -q, --quiet                Don't print status messages"
32
    echo "  -w, --wait                 Wait for the wineserver to exit before returning"
33 34 35 36 37
    echo ""
}

set -e

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
bindir=""
case "$0" in
  */*)
    # $0 contains a path, use it
    bindir=`dirname "$0"`
    ;;
  *)
    # no directory in $0, search in PATH
    saved_ifs=$IFS
    IFS=:
    for d in $PATH
    do
      IFS=$saved_ifs
      if [ -x "$d/$0" ]
      then
        bindir="$d"
        break
      fi
    done
    ;;
esac

bindir=`cd "$bindir" && pwd`
dlldir="$bindir/@bintodlldir@"
datadir="$bindir/@bintodatadir@"
63

64
do_wait=0
65
quiet=0
66

67 68 69 70 71 72 73 74 75 76
if [ ! -f "$dlldir/ntdll.dll.so" -a \
     -x "$bindir/../server/wineserver" -a \
     -f "$bindir/../dlls/ntdll/ntdll.dll.so" ]
then
    # running from the wine source tree
    topdir=`cd "$bindir/.." && pwd`
    WINELOADER="$topdir/wine"
    WINESERVER="$topdir/server/wineserver"
    if [ -n "$LD_LIBRARY_PATH" ]
    then
77
        LD_LIBRARY_PATH="$topdir/libs/wine:$LD_LIBRARY_PATH"
78
    else
79
        LD_LIBRARY_PATH="$topdir/libs/wine"
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    fi
    export LD_LIBRARY_PATH

    # find the source directory
    link=`readlink "$WINELOADER"`
    if [ -z "$link" ]
    then
        topsrcdir="$topdir"
    else
        link=`dirname "$link"`
        case "$link" in
            /*) topsrcdir=`cd "$link/.." && pwd` ;;
             *) topsrcdir=`cd "$topdir/$link/.." && pwd` ;;
        esac
    fi
    dlldir="$topdir/programs"
    datadir="$topsrcdir/tools"
fi

99 100 101
while [ $# -gt 0 ]
do
    case "$1" in
102
        -h|--help)
103 104 105 106 107 108 109
            usage
            exit 0
            ;;
        --prefix)
            WINEPREFIX="$2"
            shift 2
            ;;
110 111 112 113
        -q|--quiet)
            quiet=1
            shift
            ;;
114 115 116 117
        -w|--wait)
            do_wait=1
            shift
            ;;
118
        --use-wine-tree)
119
            # ignored, autodetected now
120 121 122
            shift 2
            ;;
        *)
123
            echo "Unknown option $1"
124 125 126 127 128
            usage
            exit 1
            ;;
  esac
done
129 130 131

WINEPREFIX="${WINEPREFIX:-$HOME/.wine}"

132
if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then :
133
else
134 135
    echo "Could not create $WINEPREFIX, aborting"
    exit 1
136 137
fi

138
WINEPREFIX=`cd "$WINEPREFIX" && pwd`
139 140 141 142 143 144 145 146 147 148 149 150

# Create the drive symlinks

if [ ! -d "$WINEPREFIX/dosdevices" ]
then
    mkdir "$WINEPREFIX/dosdevices"
    [ -d "$WINEPREFIX/drive_c" ] || mkdir "$WINEPREFIX/drive_c"
    ln -s "../drive_c" "$WINEPREFIX/dosdevices/c:"
    ln -s "/" "$WINEPREFIX/dosdevices/z:"
fi

CROOT="$WINEPREFIX/dosdevices/c:"
151 152 153 154 155 156 157 158 159

# Create the directory tree

for i in \
    "$CROOT/windows" \
    "$CROOT/windows/command" \
    "$CROOT/windows/fonts" \
    "$CROOT/windows/inf" \
    "$CROOT/windows/system" \
160 161
    "$CROOT/windows/system32" \
    "$CROOT/windows/system32/drivers" \
162 163
    "$CROOT/windows/system32/spool" \
    "$CROOT/windows/system32/spool/drivers" \
164 165
    "$CROOT/windows/temp"
do
166
    [ -d "$i" ] || mkdir "$i"
167 168 169 170
done

# Copy the .inf script and run it

171
cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf"
172
export WINEPREFIX
173
"${WINELOADER:-$bindir/wine}" rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
174 175 176

# Wait for the wineserver to finish

177
if [ $do_wait = 1 ]
178
then
179
    "${WINESERVER:-$bindir/wineserver}" -w
180 181 182 183 184
fi

if [ $quiet = 0 ]
then
    echo "$WINEPREFIX updated successfully."
185
fi