Setup a temporary directory for update_engine_sideload.

When running update_engine_sideload from recovery, the default temp
directory (/data/misc/update_engine/tmp) is not available. This
directory is currently used to store a blob when applying a bspatch
from a child process. This patch uses /tmp/update_engine_sideload as
a temporary directory when running update_engine_sideload from recovery.

Bug: 27178350
TEST=`adb sideload` an incremental update.

Change-Id: Iec9f4ec8314e8dae4f6b1e78402dd39ca49c4fa4
diff --git a/sideload_main.cc b/sideload_main.cc
index 46e8f35..d02af0e 100644
--- a/sideload_main.cc
+++ b/sideload_main.cc
@@ -43,6 +43,11 @@
 using std::vector;
 using update_engine::UpdateStatus;
 
+namespace {
+// The root directory used for temporary files in update_engine_sideload.
+const char kSideloadRootTempDir[] = "/tmp/update_engine_sideload";
+}  // namespace
+
 namespace chromeos_update_engine {
 namespace {
 
@@ -206,6 +211,10 @@
   // xz-embedded requires to initialize its CRC-32 table once on startup.
   xz_crc32_init();
 
+  // When called from recovery, /data is not accessible, so we need to use
+  // /tmp for temporary files.
+  chromeos_update_engine::utils::SetRootTempDir(kSideloadRootTempDir);
+
   vector<string> headers = base::SplitString(
       FLAGS_headers, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);