Unify to different pieces of code that handle sandbox considerations for
authorZac Medico <zmedico@gentoo.org>
Fri, 3 Sep 2010 01:54:47 +0000 (18:54 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 3 Sep 2010 01:54:47 +0000 (18:54 -0700)
TEMP, TMP, and TMPDIR variables.

bin/ebuild.sh

index f17e63b3efd5f6396ff4461cd56f406c90675ae7..6627c898d47e483421ff7e6eb8c004d32b8763b4 100755 (executable)
@@ -19,12 +19,6 @@ fi
 # environment by modifying our PATH.
 unset BASH_ENV
 
-# Avoid sandbox violations in temporary directories.
-for x in TEMP TMP TMPDIR ; do
-       [[ -n ${!x} ]] && export SANDBOX_WRITE="${SANDBOX_WRITE:+${SANDBOX_WRITE}:}${!x}"
-done
-unset x
-
 ROOTPATH=${ROOTPATH##:}
 ROOTPATH=${ROOTPATH%%:}
 PREROOTPATH=${PREROOTPATH##:}
@@ -107,6 +101,18 @@ addwrite "${PORTAGE_TMPDIR}"
 addread "/:${PORTAGE_TMPDIR}"
 [[ -n ${PORTAGE_GPG_DIR} ]] && addpredict "${PORTAGE_GPG_DIR}"
 
+# Avoid sandbox violations in temporary directories.
+if [[ -w $T ]] ; then
+       export TEMP=$T
+       export TMP=$T
+       export TMPDIR=$T
+else
+       for x in TEMP TMP TMPDIR ; do
+               [[ -n ${!x} ]] && addwrite "${!x}"
+       done
+       unset x
+fi
+
 lchown() {
        chown -h "$@"
 }
@@ -2079,12 +2085,6 @@ fi
 #a reasonable default for $S
 [[ -z ${S} ]] && export S=${WORKDIR}/${P}
 
-#some users have $TMP/$TMPDIR to a custom dir in their home ...
-#this will cause sandbox errors with some ./configure
-#scripts, so set it to $T.
-export TMP="${T}"
-export TMPDIR="${T}"
-
 # Note: readonly variables interfere with preprocess_ebuild_env(), so
 # declare them only after it has already run.
 if [ "${EBUILD_PHASE}" != "depend" ] ; then