blob: d5d76dd70d286048896eab7e7daa9eb31ff22850 [file] [log] [blame]
Alexandre Julliardbd603642004-04-01 05:03:27 +00001#!/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 Ernst360a3f92006-05-18 14:49:52 +020021# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliardbd603642004-04-01 05:03:27 +000022#
23
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000024usage()
25{
26 echo "Usage: $0 [options]"
27 echo ""
28 echo "Options:"
Alexandre Julliard04869eb2004-05-11 04:29:18 +000029 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 Julliard3b5875e2005-04-20 13:12:14 +000032 echo " -w, --wait Wait for the wineserver to exit before returning"
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000033 echo ""
34}
Alexandre Julliardbd603642004-04-01 05:03:27 +000035
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000036set -e
37
Pierre d'Herbemontb1be7242006-03-11 21:12:11 +010038bindir=""
39case "$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 ;;
58esac
59
60bindir=`cd "$bindir" && pwd`
61dlldir="$bindir/@bintodlldir@"
62datadir="$bindir/@bintodatadir@"
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000063
Alexandre Julliard3b5875e2005-04-20 13:12:14 +000064do_wait=0
Alexandre Julliard04869eb2004-05-11 04:29:18 +000065quiet=0
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000066
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010067if [ ! -f "$dlldir/ntdll.dll.so" -a \
68 -x "$bindir/../server/wineserver" -a \
69 -f "$bindir/../dlls/ntdll/ntdll.dll.so" ]
70then
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, Rff82ce22006-10-11 14:51:13 +053077 LD_LIBRARY_PATH="$topdir/libs/wine:$LD_LIBRARY_PATH"
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010078 else
Srivatsa Kanchi, Rff82ce22006-10-11 14:51:13 +053079 LD_LIBRARY_PATH="$topdir/libs/wine"
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010080 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"
97fi
98
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000099while [ $# -gt 0 ]
100do
101 case "$1" in
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000102 -h|--help)
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000103 usage
104 exit 0
105 ;;
106 --prefix)
107 WINEPREFIX="$2"
108 shift 2
109 ;;
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000110 -q|--quiet)
111 quiet=1
112 shift
113 ;;
Alexandre Julliard3b5875e2005-04-20 13:12:14 +0000114 -w|--wait)
115 do_wait=1
116 shift
117 ;;
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000118 --use-wine-tree)
Alexandre Julliardc33fbc02006-03-17 12:34:50 +0100119 # ignored, autodetected now
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000120 shift 2
121 ;;
122 *)
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000123 echo "Unknown option $1"
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000124 usage
125 exit 1
126 ;;
127 esac
128done
129
Alexandre Julliardbd603642004-04-01 05:03:27 +0000130WINEPREFIX="${WINEPREFIX:-$HOME/.wine}"
131
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000132if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then :
Alexandre Julliardbd603642004-04-01 05:03:27 +0000133else
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000134 echo "Could not create $WINEPREFIX, aborting"
135 exit 1
Alexandre Julliardbd603642004-04-01 05:03:27 +0000136fi
137
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000138WINEPREFIX=`cd "$WINEPREFIX" && pwd`
Alexandre Julliard1c5b8b12004-05-14 00:43:50 +0000139
140# Create the drive symlinks
141
142if [ ! -d "$WINEPREFIX/dosdevices" ]
143then
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:"
148fi
149
150CROOT="$WINEPREFIX/dosdevices/c:"
Alexandre Julliardbd603642004-04-01 05:03:27 +0000151
152# Create the directory tree
153
154for i in \
Alexandre Julliardbd603642004-04-01 05:03:27 +0000155 "$CROOT/windows" \
156 "$CROOT/windows/command" \
157 "$CROOT/windows/fonts" \
158 "$CROOT/windows/inf" \
Alexandre Julliardbd603642004-04-01 05:03:27 +0000159 "$CROOT/windows/system" \
Alexandre Julliard19c1af52005-08-15 14:53:35 +0000160 "$CROOT/windows/system32" \
161 "$CROOT/windows/system32/drivers" \
Alexandre Julliardbd603642004-04-01 05:03:27 +0000162 "$CROOT/windows/temp"
163do
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000164 [ -d "$i" ] || mkdir "$i"
Alexandre Julliardbd603642004-04-01 05:03:27 +0000165done
166
Alexandre Julliardbd603642004-04-01 05:03:27 +0000167# Copy the .inf script and run it
168
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000169cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf"
Alexandre Julliardbd603642004-04-01 05:03:27 +0000170export WINEPREFIX
Pierre d'Herbemont6997ce72006-05-25 15:20:59 +0200171"${WINELOADER:-$bindir/wine}" rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
Alexandre Julliardbd603642004-04-01 05:03:27 +0000172
173# Wait for the wineserver to finish
174
Alexandre Julliard3b5875e2005-04-20 13:12:14 +0000175if [ $do_wait = 1 ]
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000176then
Pierre d'Herbemont6997ce72006-05-25 15:20:59 +0200177 "${WINESERVER:-$bindir/wineserver}" -w
Alexandre Julliard3b5875e2005-04-20 13:12:14 +0000178fi
179
180if [ $quiet = 0 ]
181then
182 echo "$WINEPREFIX updated successfully."
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000183fi