summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-05-03 00:48:54 +0200
committerTao Bao <tbao@google.com>2017-05-08 21:16:45 +0200
commit00d5757186c279ba5e8a52a6f5209be3e7152025 (patch)
treeef219b66bb8ac8f7a20a182a91292213131505aa /install.cpp
parentMerge "recovery: update mkfs.f2fs args to match f2fs-tools 1.8.0" (diff)
downloadandroid_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.tar
android_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.tar.gz
android_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.tar.bz2
android_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.tar.lz
android_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.tar.xz
android_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.tar.zst
android_bootable_recovery-00d5757186c279ba5e8a52a6f5209be3e7152025.zip
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/install.cpp b/install.cpp
index 689f4a0c6..a1f2e4fbd 100644
--- a/install.cpp
+++ b/install.cpp
@@ -51,6 +51,7 @@
#include "error_code.h"
#include "otautil/SysUtil.h"
#include "otautil/ThermalUtil.h"
+#include "private/install.h"
#include "roots.h"
#include "ui.h"
#include "verifier.h"
@@ -125,12 +126,6 @@ static void read_source_target_build(ZipArchiveHandle zip, std::vector<std::stri
}
}
-// Extract the update binary from the open zip archive |zip| located at |path| and store into |cmd|
-// the command line that should be called. The |status_fd| is the file descriptor the child process
-// should use to report back the progress of the update.
-int update_binary_command(const std::string& path, ZipArchiveHandle zip, int retry_count,
- int status_fd, std::vector<std::string>* cmd);
-
#ifdef AB_OTA_UPDATER
// Parses the metadata of the OTA package in |zip| and checks whether we are
@@ -211,8 +206,9 @@ static int check_newer_ab_build(ZipArchiveHandle zip) {
return 0;
}
-int update_binary_command(const std::string& path, ZipArchiveHandle zip, int /* retry_count */,
- int status_fd, std::vector<std::string>* cmd) {
+int update_binary_command(const std::string& package, ZipArchiveHandle zip,
+ const std::string& binary_path, int /* retry_count */, int status_fd,
+ std::vector<std::string>* cmd) {
CHECK(cmd != nullptr);
int ret = check_newer_ab_build(zip);
if (ret != 0) {
@@ -246,8 +242,8 @@ int update_binary_command(const std::string& path, ZipArchiveHandle zip, int /*
}
long payload_offset = payload_entry.offset;
*cmd = {
- "/sbin/update_engine_sideload",
- "--payload=file://" + path,
+ binary_path,
+ "--payload=file://" + package,
android::base::StringPrintf("--offset=%ld", payload_offset),
"--headers=" + std::string(payload_properties.begin(), payload_properties.end()),
android::base::StringPrintf("--status_fd=%d", status_fd),
@@ -257,8 +253,9 @@ int update_binary_command(const std::string& path, ZipArchiveHandle zip, int /*
#else // !AB_OTA_UPDATER
-int update_binary_command(const std::string& path, ZipArchiveHandle zip, int retry_count,
- int status_fd, std::vector<std::string>* cmd) {
+int update_binary_command(const std::string& package, ZipArchiveHandle zip,
+ const std::string& binary_path, int retry_count, int status_fd,
+ std::vector<std::string>* cmd) {
CHECK(cmd != nullptr);
// On traditional updates we extract the update binary from the package.
@@ -270,11 +267,10 @@ int update_binary_command(const std::string& path, ZipArchiveHandle zip, int ret
return INSTALL_CORRUPT;
}
- const char* binary = "/tmp/update_binary";
- unlink(binary);
- int fd = creat(binary, 0755);
+ unlink(binary_path.c_str());
+ int fd = creat(binary_path.c_str(), 0755);
if (fd == -1) {
- PLOG(ERROR) << "Failed to create " << binary;
+ PLOG(ERROR) << "Failed to create " << binary_path;
return INSTALL_ERROR;
}
@@ -286,10 +282,10 @@ int update_binary_command(const std::string& path, ZipArchiveHandle zip, int ret
}
*cmd = {
- binary,
+ binary_path,
EXPAND(RECOVERY_API_VERSION), // defined in Android.mk
std::to_string(status_fd),
- path,
+ package,
};
if (retry_count > 0) {
cmd->push_back("retry");
@@ -308,7 +304,7 @@ static void log_max_temperature(int* max_temperature) {
}
// If the package contains an update binary, extract it and run it.
-static int try_update_binary(const std::string& path, ZipArchiveHandle zip, bool* wipe_cache,
+static int try_update_binary(const std::string& package, ZipArchiveHandle zip, bool* wipe_cache,
std::vector<std::string>* log_buffer, int retry_count,
int* max_temperature) {
read_source_target_build(zip, log_buffer);
@@ -317,7 +313,13 @@ static int try_update_binary(const std::string& path, ZipArchiveHandle zip, bool
pipe(pipefd);
std::vector<std::string> args;
- int ret = update_binary_command(path, zip, retry_count, pipefd[1], &args);
+#ifdef AB_OTA_UPDATER
+ int ret = update_binary_command(package, zip, "/sbin/update_engine_sideload", retry_count,
+ pipefd[1], &args);
+#else
+ int ret = update_binary_command(package, zip, "/tmp/update-binary", retry_count, pipefd[1],
+ &args);
+#endif
if (ret) {
close(pipefd[0]);
close(pipefd[1]);
@@ -472,7 +474,7 @@ static int try_update_binary(const std::string& path, ZipArchiveHandle zip, bool
return INSTALL_RETRY;
}
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
- LOG(ERROR) << "Error in " << path << " (Status " << WEXITSTATUS(status) << ")";
+ LOG(ERROR) << "Error in " << package << " (Status " << WEXITSTATUS(status) << ")";
return INSTALL_ERROR;
}