aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2024-03-26 12:56:08 -0700
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-03-26 23:51:46 +0000
commitfab31ad0dc783c889c140a1aa4567f14c2f88402 (patch)
tree23ac0053accb10a8351db03be17311e59c99872e
parent018bcd79f17bd42e580e66ce10279bf5c4a8dd2a (diff)
downloadupdate_engine-fab31ad0dc783c889c140a1aa4567f14c2f88402.tar.gz
Make update_engine use /data/misc/update_engine/cache as tmpdir
update_engine doesn't have access to android's default tmpdir, /data/local/tmp . So use /data/misc/update_engine/cache/ Test: th Bug: 320443894 Change-Id: Ibbbe8019c276fe0fa3f9ea197815ed6daac912fc
-rw-r--r--common/utils.cc3
-rw-r--r--common/utils.h2
-rw-r--r--main.cc10
3 files changed, 13 insertions, 2 deletions
diff --git a/common/utils.cc b/common/utils.cc
index f0c045f2..1fa2d416 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -86,6 +86,7 @@ const int kGetFileFormatMaxHeaderSize = 32;
// The path to the kernel's boot_id.
const char kBootIdPath[] = "/proc/sys/kernel/random/boot_id";
+} // namespace
// If |path| is absolute, or explicit relative to the current working directory,
// leaves it as is. Otherwise, uses the system's temp directory, as defined by
// base::GetTempDir() and prepends it to |path|. On success stores the full
@@ -110,8 +111,6 @@ bool GetTempName(const string& path, base::FilePath* template_path) {
return true;
}
-} // namespace
-
namespace utils {
bool WriteFile(const char* path, const void* data, size_t data_len) {
diff --git a/common/utils.h b/common/utils.h
index 6bb89f1e..ae07b07e 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -559,6 +559,8 @@ constexpr std::string_view ToStringView(
[[nodiscard]] std::string_view ToStringView(const void* data,
size_t size) noexcept;
+bool GetTempName(const std::string& path, base::FilePath* template_path);
+
} // namespace chromeos_update_engine
#define TEST_AND_RETURN_FALSE_ERRNO(_x) \
diff --git a/main.cc b/main.cc
index 103e1a10..ac2f5bcc 100644
--- a/main.cc
+++ b/main.cc
@@ -14,6 +14,7 @@
// limitations under the License.
//
+#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <xz.h>
@@ -27,6 +28,7 @@
#include "update_engine/common/logging.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/terminator.h"
+#include "update_engine/common/utils.h"
using std::string;
DEFINE_bool(logtofile, false, "Write logs to a file in log_dir.");
@@ -48,6 +50,14 @@ int main(int argc, char** argv) {
bool log_to_system = FLAGS_logtostderr;
bool log_to_file = FLAGS_logtofile || !FLAGS_logtostderr;
chromeos_update_engine::SetupLogging(log_to_system, log_to_file);
+ base::FilePath tmpdir;
+ if (chromeos_update_engine::GetTempName("", &tmpdir)) {
+ LOG(INFO) << "Using temp dir " << tmpdir;
+ setenv("TMPDIR", tmpdir.value().c_str(), true);
+ } else {
+ PLOG(ERROR) << "Failed to create temporary directory, puffdiff will run "
+ "w/o on disk cache, updates might take longer.";
+ }
if (!FLAGS_foreground)
PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed";