blob: 5612dfdb78df1b419f21ce8dc1e4a2b817d4da9f [file] [log] [blame]
Alexandre Julliardbd603642004-04-01 05:03:27 +00001#!/bin/sh
2#
3# Script to create the initial WINEPREFIX directory
4#
Alexandre Julliardf80cd0d2008-10-18 19:22:54 +02005# Copyright 1999 Ove Kåven
Alexandre Julliardbd603642004-04-01 05:03:27 +00006# 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@"
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000062
Alexandre Julliard3b5875e2005-04-20 13:12:14 +000063do_wait=0
Alexandre Julliard04869eb2004-05-11 04:29:18 +000064quiet=0
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000065
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010066if [ ! -f "$dlldir/ntdll.dll.so" -a \
67 -x "$bindir/../server/wineserver" -a \
68 -f "$bindir/../dlls/ntdll/ntdll.dll.so" ]
69then
70 # running from the wine source tree
71 topdir=`cd "$bindir/.." && pwd`
72 WINELOADER="$topdir/wine"
73 WINESERVER="$topdir/server/wineserver"
74 if [ -n "$LD_LIBRARY_PATH" ]
75 then
Srivatsa Kanchi, Rff82ce22006-10-11 14:51:13 +053076 LD_LIBRARY_PATH="$topdir/libs/wine:$LD_LIBRARY_PATH"
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010077 else
Srivatsa Kanchi, Rff82ce22006-10-11 14:51:13 +053078 LD_LIBRARY_PATH="$topdir/libs/wine"
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010079 fi
80 export LD_LIBRARY_PATH
Alexandre Julliardc33fbc02006-03-17 12:34:50 +010081fi
82
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000083while [ $# -gt 0 ]
84do
85 case "$1" in
Alexandre Julliard04869eb2004-05-11 04:29:18 +000086 -h|--help)
Alexandre Julliard5f27ca22004-05-05 22:09:09 +000087 usage
88 exit 0
89 ;;
90 --prefix)
91 WINEPREFIX="$2"
92 shift 2
93 ;;
Alexandre Julliard04869eb2004-05-11 04:29:18 +000094 -q|--quiet)
95 quiet=1
96 shift
97 ;;
Alexandre Julliard3b5875e2005-04-20 13:12:14 +000098 -w|--wait)
99 do_wait=1
100 shift
101 ;;
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000102 --use-wine-tree)
Alexandre Julliardc33fbc02006-03-17 12:34:50 +0100103 # ignored, autodetected now
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000104 shift 2
105 ;;
106 *)
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000107 echo "Unknown option $1"
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000108 usage
109 exit 1
110 ;;
111 esac
112done
113
Alexandre Julliardd869bd62008-05-14 12:24:14 +0200114echo "Note: wineprefixcreate is deprecated and shouldn't be needed anymore." 1>&2
115echo " WINEPREFIX creation and updates now happen automatically when needed." 1>&2
116echo 1>&2
117
Alexandre Julliardbd603642004-04-01 05:03:27 +0000118WINEPREFIX="${WINEPREFIX:-$HOME/.wine}"
119
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000120if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then :
Alexandre Julliardbd603642004-04-01 05:03:27 +0000121else
Alexandre Julliard04869eb2004-05-11 04:29:18 +0000122 echo "Could not create $WINEPREFIX, aborting"
123 exit 1
Alexandre Julliardbd603642004-04-01 05:03:27 +0000124fi
125
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000126WINEPREFIX=`cd "$WINEPREFIX" && pwd`
Alexandre Julliardbd603642004-04-01 05:03:27 +0000127export WINEPREFIX
Alexandre Julliardbab67d32008-04-21 15:47:47 +0200128
Alexandre Julliard87ec7ec2008-05-14 12:23:22 +0200129if [ -d "$WINEPREFIX/dosdevices" ]
130then
131 "${WINELOADER:-$bindir/wine}" wineboot.exe --update
132else
133 "${WINELOADER:-$bindir/wine}" wineboot.exe
134fi
Alexandre Julliardbd603642004-04-01 05:03:27 +0000135
136# Wait for the wineserver to finish
137
Alexandre Julliard3b5875e2005-04-20 13:12:14 +0000138if [ $do_wait = 1 ]
Alexandre Julliard5f27ca22004-05-05 22:09:09 +0000139then
Pierre d'Herbemont6997ce72006-05-25 15:20:59 +0200140 "${WINESERVER:-$bindir/wineserver}" -w
Alexandre Julliard3b5875e2005-04-20 13:12:14 +0000141fi