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

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