Use ${TMPDIR} as the default working directory. am: 5fbb110c73
am: a54920bef5

Change-Id: Id332360ae9f35c66fcb48300cdcc594371178b2d
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