From 8555cd4002ccb8164ffa4b270be175654476da5c Mon Sep 17 00:00:00 2001 From: Jan Jurzitza Date: Tue, 28 Jun 2022 14:28:51 +0200 Subject: [PATCH] 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 (https://github.com/dlang/dub/pull/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. --- script/install.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/script/install.sh b/script/install.sh index 81970369..b534b325 100755 --- a/script/install.sh +++ b/script/install.sh @@ -176,13 +176,21 @@ GET_PATH_AUTO_INSTALL=0 GET_PATH_COMPILER=dc # Set a default install path depending on the POSIX/Windows environment. if posix_terminal; then - ROOT=~/dlang + if [ -z "$DPATH" ]; then + ROOT=~/dlang + else + ROOT="$DPATH/dlang" + fi else - # Default to a ROOT that is outside the POSIX-like environment. - if [ -z "$USERPROFILE" ]; then - fatal '%USERPROFILE% should not be empty on Windows.'; + if [ -z "$DPATH" ]; then + # Default to a ROOT that is outside the POSIX-like environment. + if [ -z "$USERPROFILE" ]; then + fatal '%USERPROFILE% should not be empty on Windows.'; + fi + ROOT=$(posix_path "$USERPROFILE")/dlang + else + ROOT=$(posix_path "$DPATH")/dlang fi - ROOT=$(posix_path "$USERPROFILE")/dlang fi TMP_ROOT= DUB_VERSION=