Skip to content

Commit 8555cd4

Browse files
authored
support customizing install directory with $DPATH
This introduces the $DPATH environment variable to override the user's home directory just for D tools. This is also intended to be used by DUB (dlang/dub#2281) when there is not the more explicit `$DUB_HOME` variable set on the system. This allows users who install their D compiler through the install.sh script to both have the compiler installations as well as the dub packages be stored elsewhere in the system than in their home folder. In case we have other tools that download their dependencies into the user's home directory, we should also make them support the same $DPATH environment variable.
1 parent 194c9c8 commit 8555cd4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

script/install.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,21 @@ GET_PATH_AUTO_INSTALL=0
176176
GET_PATH_COMPILER=dc
177177
# Set a default install path depending on the POSIX/Windows environment.
178178
if posix_terminal; then
179-
ROOT=~/dlang
179+
if [ -z "$DPATH" ]; then
180+
ROOT=~/dlang
181+
else
182+
ROOT="$DPATH/dlang"
183+
fi
180184
else
181-
# Default to a ROOT that is outside the POSIX-like environment.
182-
if [ -z "$USERPROFILE" ]; then
183-
fatal '%USERPROFILE% should not be empty on Windows.';
185+
if [ -z "$DPATH" ]; then
186+
# Default to a ROOT that is outside the POSIX-like environment.
187+
if [ -z "$USERPROFILE" ]; then
188+
fatal '%USERPROFILE% should not be empty on Windows.';
189+
fi
190+
ROOT=$(posix_path "$USERPROFILE")/dlang
191+
else
192+
ROOT=$(posix_path "$DPATH")/dlang
184193
fi
185-
ROOT=$(posix_path "$USERPROFILE")/dlang
186194
fi
187195
TMP_ROOT=
188196
DUB_VERSION=

0 commit comments

Comments
 (0)