omniti-labs / omnios-build

Build system for OmniOS - Note, this is a quasi-private archive for OmniTI, you probably want https://omniosce.org
Other
39 stars 136 forks source link

`$TMPDIR` should be honoured #79

Closed richlowe closed 8 years ago

richlowe commented 8 years ago

Not all of us can put arbitrary build trees in /tmp successfully due to memory constraints. The build should honour $TMPDIR so that we can use /var/tmp or wherever else.

Unfortunately the obvious diff

diff --git a/lib/config.sh b/lib/config.sh
index e1715d8..4caf138 100644
--- a/lib/config.sh
+++ b/lib/config.sh
@@ -43,7 +43,7 @@ PREFIX=/usr
 #    to avoid collision on shared build systems,
 #    TMPDIR includes a username
 # DTMPDIR is used for constructing the DESTDIR path
-TMPDIR=/tmp/build_$USER
+TMPDIR=${TMPDIR:-/tmp}/build_$USER
 DTMPDIR=$TMPDIR

 # Log file for all output

Doesn't work flawlessly, because config.sh is evaluated twice, so we end up with /foo/build_richlowe/build_richlowe.

danmcd commented 8 years ago

The "buildctl" script sources functions.sh (which sources config.sh). Each "build.sh" script ALSO sources functions.sh (which ALSO sources config.sh).

I've had similar problems before (look at the history of kayak's build.sh, e.g.), and I've addressed them this way:

if [[ -z $TMPDIR ]]; then
    TMPDIR=/tmp/build_$USER
fi
danmcd commented 8 years ago

Solving this way:

bloody(omnios-build/build)[1]% git diff
diff --git a/lib/config.sh b/lib/config.sh
index e1715d8..d68f229 100644
--- a/lib/config.sh
+++ b/lib/config.sh
@@ -43,7 +43,10 @@ PREFIX=/usr
 #    to avoid collision on shared build systems,
 #    TMPDIR includes a username
 # DTMPDIR is used for constructing the DESTDIR path
-TMPDIR=/tmp/build_$USER
+# Let the environment override TMPDIR.
+if [[ -z $TMPDIR ]]; then
+       TMPDIR=/tmp/build_$USER
+fi
 DTMPDIR=$TMPDIR

 # Log file for all output
bloody(omnios-build/build)[0]%