- Make MTA dynamically allocated so that proxies and other resources
[wine] / tools / wineprefixcreate.in
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
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 #
23
24 usage()
25 {
26     echo "Usage: $0 [options]"
27     echo ""
28     echo "Options:"
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"
32     echo "  -u, --update               Update the prefix directory if it already exists"
33     echo "      --use-wine-tree <dir>  Run from the Wine source tree <dir>"
34     echo ""
35 }
36
37 set -e
38
39 dlldir="@dlldir@"
40 datadir="@datadir@/wine"
41
42 do_update=0
43 quiet=0
44
45 while [ $# -gt 0 ]
46 do
47     case "$1" in
48         -h|--help)
49             usage
50             exit 0
51             ;;
52         --prefix)
53             WINEPREFIX="$2"
54             shift 2
55             ;;
56         -u|--update)
57             do_update=1
58             shift
59             ;;
60         -q|--quiet)
61             quiet=1
62             shift
63             ;;
64         --use-wine-tree)
65             topdir=`cd "$2" && pwd`
66             if [ -x "$topdir/server/wineserver" ]
67             then
68                 WINELOADER="$topdir/wine"
69                 WINESERVER="$topdir/server/wineserver"
70                 if [ -n "$LD_LIBRARY_PATH" ]
71                 then
72                     LD_LIBRARY_PATH="$topdir/libs:$LD_LIBRARY_PATH"
73                 else
74                     LD_LIBRARY_PATH="$topdir/libs"
75                 fi
76                 export LD_LIBRARY_PATH
77                 dlldir="$topdir/programs"
78                 datadir="$topdir/tools"
79             else
80                 echo "$2 is not a valid Wine source tree"
81                 exit 1
82             fi
83             shift 2
84             ;;
85         *)
86             echo "Unknown option $1"
87             usage
88             exit 1
89             ;;
90   esac
91 done
92
93 WINEPREFIX="${WINEPREFIX:-$HOME/.wine}"
94
95 if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then :
96 else
97     echo "Could not create $WINEPREFIX, aborting"
98     exit 1
99 fi
100
101 WINEPREFIX=`cd "$WINEPREFIX" && pwd`
102
103 # Create the drive symlinks
104
105 if [ ! -d "$WINEPREFIX/dosdevices" ]
106 then
107     mkdir "$WINEPREFIX/dosdevices"
108     [ -d "$WINEPREFIX/drive_c" ] || mkdir "$WINEPREFIX/drive_c"
109     ln -s "../drive_c" "$WINEPREFIX/dosdevices/c:"
110     ln -s "/" "$WINEPREFIX/dosdevices/z:"
111 fi
112
113 CROOT="$WINEPREFIX/dosdevices/c:"
114
115 # Create the directory tree
116
117 for i in \
118     "$CROOT/My Documents" \
119     "$CROOT/My Documents/My Music" \
120     "$CROOT/My Documents/My Pictures" \
121     "$CROOT/My Documents/My Video" \
122     "$CROOT/Program Files" \
123     "$CROOT/Program Files/Common Files" \
124     "$CROOT/windows" \
125     "$CROOT/windows/command" \
126     "$CROOT/windows/fonts" \
127     "$CROOT/windows/inf" \
128     "$CROOT/windows/profiles" \
129     "$CROOT/windows/profiles/Administrator" \
130     "$CROOT/windows/Start Menu" \
131     "$CROOT/windows/Application Data" \
132     "$CROOT/windows/Start Menu/Programs" \
133     "$CROOT/windows/Start Menu/Programs/Startup" \
134     "$CROOT/windows/system" \
135     "$CROOT/windows/temp"
136 do
137     [ -d "$i" ] || mkdir "$i"
138 done
139
140 # Create the application symlinks
141
142 link_app()
143 {
144    rm -f "$2" && ln -s "$dlldir/$1.exe.so" "$2" || echo "Warning: failed to create $2"
145 }
146
147 link_app start        "$CROOT/windows/command/start.exe"
148 link_app notepad      "$CROOT/windows/notepad.exe"
149 link_app regedit      "$CROOT/windows/regedit.exe"
150 link_app rundll32     "$CROOT/windows/rundll32.exe"
151 link_app wcmd         "$CROOT/windows/system/wcmd.exe"
152 link_app control      "$CROOT/windows/system/control.exe"
153 link_app winhelp      "$CROOT/windows/system/help.exe"
154 link_app notepad      "$CROOT/windows/system/notepad.exe"
155 link_app progman      "$CROOT/windows/system/progman.exe"
156 link_app regsvr32     "$CROOT/windows/system/regsvr32.exe"
157 link_app winemine     "$CROOT/windows/system/winmine.exe"
158 link_app winver       "$CROOT/windows/system/winver.exe"
159 link_app uninstaller  "$CROOT/windows/uninstall.exe"
160 link_app winhelp      "$CROOT/windows/winhelp.exe"
161 link_app winhelp      "$CROOT/windows/winhlp32.exe"
162 link_app winebrowser  "$CROOT/windows/winebrowser.exe"
163
164 # Copy the .inf script and run it
165
166 cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf"
167 export WINEPREFIX
168 ${WINELOADER:-wine} rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
169
170 # Wait for the wineserver to finish
171
172 if [ $do_update = 0 ]
173 then
174     ${WINESERVER:-wineserver} -w
175     if [ $quiet = 0 ]
176     then
177         echo "$WINEPREFIX created successfully."
178     fi
179 else
180     if [ $quiet = 0 ]
181     then
182         echo "$WINEPREFIX updated successfully."
183     fi
184 fi