wineprefixcreate.in 5.24 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

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 "      --use-wine-tree <dir>  Run from the Wine build tree <dir>"
33
    echo "  -w, --wait                 Wait for the wineserver to exit before returning"
34 35 36 37 38 39 40 41
    echo ""
}

set -e

dlldir="@dlldir@"
datadir="@datadir@/wine"

42
do_wait=0
43
quiet=0
44 45 46 47

while [ $# -gt 0 ]
do
    case "$1" in
48
        -h|--help)
49 50 51 52 53 54 55
            usage
            exit 0
            ;;
        --prefix)
            WINEPREFIX="$2"
            shift 2
            ;;
56 57 58 59
        -q|--quiet)
            quiet=1
            shift
            ;;
60 61 62 63
        -w|--wait)
            do_wait=1
            shift
            ;;
64 65 66 67 68
        --use-wine-tree)
            topdir=`cd "$2" && pwd`
            if [ -x "$topdir/server/wineserver" ]
            then
                WINELOADER="$topdir/wine"
69 70 71 72 73 74 75 76
                WINESERVER="$topdir/server/wineserver"
                if [ -n "$LD_LIBRARY_PATH" ]
                then
                    LD_LIBRARY_PATH="$topdir/libs:$LD_LIBRARY_PATH"
                else
                    LD_LIBRARY_PATH="$topdir/libs"
                fi
                export LD_LIBRARY_PATH
77 78 79 80 81 82 83 84 85 86 87 88 89 90

                # 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

91
                dlldir="$topdir/programs"
92
                datadir="$topsrcdir/tools"
93
            else
94
                echo "$2 is not a valid Wine build tree"
95 96 97 98 99
                exit 1
            fi
            shift 2
            ;;
        *)
100
            echo "Unknown option $1"
101 102 103 104 105
            usage
            exit 1
            ;;
  esac
done
106 107 108

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

109
if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then :
110
else
111 112
    echo "Could not create $WINEPREFIX, aborting"
    exit 1
113 114
fi

115
WINEPREFIX=`cd "$WINEPREFIX" && pwd`
116 117 118 119 120 121 122 123 124 125 126 127

# 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:"
128 129 130 131 132 133 134 135 136

# Create the directory tree

for i in \
    "$CROOT/windows" \
    "$CROOT/windows/command" \
    "$CROOT/windows/fonts" \
    "$CROOT/windows/inf" \
    "$CROOT/windows/system" \
137 138
    "$CROOT/windows/system32" \
    "$CROOT/windows/system32/drivers" \
139 140
    "$CROOT/windows/temp"
do
141
    [ -d "$i" ] || mkdir "$i"
142 143 144 145 146 147
done

# Create the application symlinks

link_app()
{
148
   rm -f "$2" && ln -s "$dlldir/$1.exe.so" "$2" || echo "Warning: failed to create $2"
149 150 151 152 153 154
}

link_app start        "$CROOT/windows/command/start.exe"
link_app notepad      "$CROOT/windows/notepad.exe"
link_app regedit      "$CROOT/windows/regedit.exe"
link_app rundll32     "$CROOT/windows/rundll32.exe"
155 156 157 158 159 160 161 162 163
link_app wcmd         "$CROOT/windows/system32/wcmd.exe"
link_app control      "$CROOT/windows/system32/control.exe"
link_app winhelp      "$CROOT/windows/system32/help.exe"
link_app msiexec      "$CROOT/windows/system32/msiexec.exe"
link_app notepad      "$CROOT/windows/system32/notepad.exe"
link_app progman      "$CROOT/windows/system32/progman.exe"
link_app regsvr32     "$CROOT/windows/system32/regsvr32.exe"
link_app winemine     "$CROOT/windows/system32/winmine.exe"
link_app winver       "$CROOT/windows/system32/winver.exe"
164 165 166 167 168 169 170
link_app uninstaller  "$CROOT/windows/uninstall.exe"
link_app winhelp      "$CROOT/windows/winhelp.exe"
link_app winhelp      "$CROOT/windows/winhlp32.exe"
link_app winebrowser  "$CROOT/windows/winebrowser.exe"

# Copy the .inf script and run it

171
cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf"
172
export WINEPREFIX
173
"${WINELOADER:-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 180 181 182 183 184
    "${WINESERVER:-wineserver}" -w
fi

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