Use ${TMPDIR} as the default working directory.

This patch uses ${TMPDIR} as the default working directory, falling back
to the old behaviour is /tmp was not set. This also passes the desired
working directory to delta_generator as a TMPDIR env variable.

Bug: 34250932
Test: `strace -e trace=open -f -- brillo_update_payload generate --payload pay.bin --target_image tf.zip --work_dir /tmp/foobar 2>&1 | grep tmp` only shows access to /tmp/foobar, not /tmp
Change-Id: I4972a4010d7eed73b2fd1cc9c782b0775509b50c
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index fb6b862..ebb2e3a 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -175,13 +175,18 @@
 be used."
 fi
 
-DEFINE_string work_dir "/tmp" "Where to dump temporary files."
+DEFINE_string work_dir "${TMPDIR:-/tmp}" "Where to dump temporary files."
 
 # Parse command line flag arguments
 FLAGS "$@" || exit 1
 eval set -- "${FLAGS_ARGV}"
 set -e
 
+# Override the TMPDIR with the passed work_dir flags, which anyway defaults to
+# ${TMPDIR}.
+TMPDIR="${FLAGS_work_dir}"
+export TMPDIR
+
 # Associative arrays from partition name to file in the source and target
 # images. The size of the updated area must be the size of the file.
 declare -A SRC_PARTITIONS