blob: faab34fbb2ce89b3cfce3a6ec559d836c76300ce [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Doug Zongkerb2ee9202009-06-04 10:24:53 -070017#include <ctype.h>
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080018#include <errno.h>
19#include <fcntl.h>
20#include <limits.h>
Elliott Hughes26dbad22015-01-28 12:09:05 -080021#include <string.h>
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080022#include <sys/stat.h>
Doug Zongkerb2ee9202009-06-04 10:24:53 -070023#include <sys/wait.h>
24#include <unistd.h>
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080025
Elliott Hughes8febafa2016-04-13 16:39:56 -070026#include <chrono>
Tianjie Xudd874b12016-05-13 12:13:15 -070027#include <string>
Tao Bao71e3e092016-02-02 14:02:27 -080028#include <vector>
29
Tianjie Xub0ddae52016-06-08 14:30:04 -070030#include <android-base/parseint.h>
Tianjie Xu16255832016-04-30 11:49:59 -070031#include <android-base/stringprintf.h>
32#include <android-base/strings.h>
33
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080034#include "common.h"
Tianjie Xu16255832016-04-30 11:49:59 -070035#include "error_code.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080036#include "install.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080037#include "minui/minui.h"
38#include "minzip/SysUtil.h"
39#include "minzip/Zip.h"
40#include "mtdutils/mounts.h"
41#include "mtdutils/mtdutils.h"
42#include "roots.h"
Doug Zongker10e418d2011-10-28 10:33:05 -070043#include "ui.h"
Mattias Nissler452df6d2016-04-04 16:17:01 +020044#include "verifier.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080045
Doug Zongker74406302011-10-28 15:13:10 -070046extern RecoveryUI* ui;
47
Doug Zongkerb2ee9202009-06-04 10:24:53 -070048#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
Doug Zongkerd1b19b92009-04-01 15:48:46 -070049#define PUBLIC_KEYS_FILE "/res/keys"
Tianjie Xub0ddae52016-06-08 14:30:04 -070050static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080051
Doug Zongker74406302011-10-28 15:13:10 -070052// Default allocation of progress bar segments to operations
53static const int VERIFICATION_PROGRESS_TIME = 60;
54static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
55static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
56static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
57
Tianjie Xub0ddae52016-06-08 14:30:04 -070058// This function parses and returns the build.version.incremental
59static int parse_build_number(std::string str) {
60 size_t pos = str.find("=");
61 if (pos != std::string::npos) {
62 std::string num_string = android::base::Trim(str.substr(pos+1));
63 int build_number;
64 if (android::base::ParseInt(num_string.c_str(), &build_number, 0)) {
65 return build_number;
66 }
67 }
68
69 LOGE("Failed to parse build number in %s.\n", str.c_str());
70 return -1;
71}
72
73// Read the build.version.incremental of src/tgt from the metadata and log it to last_install.
74static void read_source_target_build(ZipArchive* zip, std::vector<std::string>& log_buffer) {
75 const ZipEntry* meta_entry = mzFindZipEntry(zip, METADATA_PATH);
76 if (meta_entry == nullptr) {
77 LOGE("Failed to find %s in update package.\n", METADATA_PATH);
78 return;
79 }
80
81 std::string meta_data(meta_entry->uncompLen, '\0');
82 if (!mzReadZipEntry(zip, meta_entry, &meta_data[0], meta_entry->uncompLen)) {
83 LOGE("Failed to read metadata in update package.\n");
84 return;
85 }
86
87 // Examples of the pre-build and post-build strings in metadata:
88 // pre-build-incremental=2943039
89 // post-build-incremental=2951741
90 std::vector<std::string> lines = android::base::Split(meta_data, "\n");
91 for (const std::string& line : lines) {
92 std::string str = android::base::Trim(line);
93 if (android::base::StartsWith(str, "pre-build-incremental")){
94 int source_build = parse_build_number(str);
95 if (source_build != -1) {
96 log_buffer.push_back(android::base::StringPrintf("source_build: %d",
97 source_build));
98 }
99 } else if (android::base::StartsWith(str, "post-build-incremental")) {
100 int target_build = parse_build_number(str);
101 if (target_build != -1) {
102 log_buffer.push_back(android::base::StringPrintf("target_build: %d",
103 target_build));
104 }
105 }
106 }
107}
108
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700109// If the package contains an update binary, extract it and run it.
110static int
Tianjie Xudd874b12016-05-13 12:13:15 -0700111try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache,
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700112 std::vector<std::string>& log_buffer, int retry_count)
Tianjie Xudd874b12016-05-13 12:13:15 -0700113{
Tianjie Xub0ddae52016-06-08 14:30:04 -0700114 read_source_target_build(zip, log_buffer);
115
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700116 const ZipEntry* binary_entry =
117 mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);
118 if (binary_entry == NULL) {
Doug Zongker8e5e4da2010-09-14 18:06:55 -0700119 mzCloseZipArchive(zip);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700120 return INSTALL_CORRUPT;
121 }
122
Doug Zongker10e418d2011-10-28 10:33:05 -0700123 const char* binary = "/tmp/update_binary";
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700124 unlink(binary);
125 int fd = creat(binary, 0755);
126 if (fd < 0) {
Doug Zongker8e5e4da2010-09-14 18:06:55 -0700127 mzCloseZipArchive(zip);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700128 LOGE("Can't make %s\n", binary);
Doug Zongkerd0181b82011-10-19 10:51:12 -0700129 return INSTALL_ERROR;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700130 }
131 bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd);
132 close(fd);
Doug Zongker8e5e4da2010-09-14 18:06:55 -0700133 mzCloseZipArchive(zip);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700134
135 if (!ok) {
136 LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME);
Doug Zongkerd0181b82011-10-19 10:51:12 -0700137 return INSTALL_ERROR;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700138 }
139
140 int pipefd[2];
141 pipe(pipefd);
142
143 // When executing the update binary contained in the package, the
144 // arguments passed are:
145 //
Doug Zongkerfb2e3af2009-06-17 17:29:40 -0700146 // - the version number for this interface
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700147 //
148 // - an fd to which the program can write in order to update the
149 // progress bar. The program can write single-line commands:
150 //
151 // progress <frac> <secs>
Doug Zongkerfbf3c102009-06-24 09:36:20 -0700152 // fill up the next <frac> part of of the progress bar
153 // over <secs> seconds. If <secs> is zero, use
154 // set_progress commands to manually control the
Tao Baob07e1f32015-04-10 16:14:52 -0700155 // progress of this segment of the bar.
Doug Zongkerfbf3c102009-06-24 09:36:20 -0700156 //
157 // set_progress <frac>
158 // <frac> should be between 0.0 and 1.0; sets the
159 // progress bar within the segment defined by the most
160 // recent progress command.
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700161 //
162 // firmware <"hboot"|"radio"> <filename>
163 // arrange to install the contents of <filename> in the
Doug Zongkere08991e2010-02-02 13:09:52 -0800164 // given partition on reboot.
165 //
166 // (API v2: <filename> may start with "PACKAGE:" to
167 // indicate taking a file from the OTA package.)
168 //
169 // (API v3: this command no longer exists.)
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700170 //
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700171 // ui_print <string>
172 // display <string> on the screen.
173 //
Tao Baob07e1f32015-04-10 16:14:52 -0700174 // wipe_cache
175 // a wipe of cache will be performed following a successful
176 // installation.
177 //
178 // clear_display
179 // turn off the text display.
180 //
181 // enable_reboot
182 // packages can explicitly request that they want the user
183 // to be able to reboot during installation (useful for
184 // debugging packages that don't exit).
185 //
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700186 // - the name of the package zip file.
187 //
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700188 // - an optional argument "retry" if this update is a retry of a failed
189 // update attempt.
190 //
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700191
Tianjie Xu64f46fb2016-06-03 15:44:52 -0700192 const char* args[6];
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700193 args[0] = binary;
Doug Zongkerfb2e3af2009-06-17 17:29:40 -0700194 args[1] = EXPAND(RECOVERY_API_VERSION); // defined in Android.mk
Yabin Cui4425c1d2016-02-10 13:47:32 -0800195 char temp[16];
196 snprintf(temp, sizeof(temp), "%d", pipefd[1]);
Doug Zongker10e418d2011-10-28 10:33:05 -0700197 args[2] = temp;
Yabin Cui4425c1d2016-02-10 13:47:32 -0800198 args[3] = path;
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700199 args[4] = retry_count > 0 ? "retry" : NULL;
200 args[5] = NULL;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700201
202 pid_t pid = fork();
203 if (pid == 0) {
Alistair Strachan027429a2013-07-17 10:41:49 -0700204 umask(022);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700205 close(pipefd[0]);
Yabin Cui4425c1d2016-02-10 13:47:32 -0800206 execv(binary, const_cast<char**>(args));
Doug Zongker56c51052010-07-01 09:18:44 -0700207 fprintf(stdout, "E:Can't run %s (%s)\n", binary, strerror(errno));
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700208 _exit(-1);
209 }
210 close(pipefd[1]);
211
Tao Bao145d8612015-03-25 15:51:15 -0700212 *wipe_cache = false;
Tianjie Xu3c62b672016-02-05 18:25:58 -0800213 bool retry_update = false;
Doug Zongkerd0181b82011-10-19 10:51:12 -0700214
Doug Zongker64893cc2009-07-14 16:31:56 -0700215 char buffer[1024];
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700216 FILE* from_child = fdopen(pipefd[0], "r");
217 while (fgets(buffer, sizeof(buffer), from_child) != NULL) {
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700218 char* command = strtok(buffer, " \n");
219 if (command == NULL) {
220 continue;
221 } else if (strcmp(command, "progress") == 0) {
222 char* fraction_s = strtok(NULL, " \n");
223 char* seconds_s = strtok(NULL, " \n");
224
225 float fraction = strtof(fraction_s, NULL);
226 int seconds = strtol(seconds_s, NULL, 10);
227
Doug Zongker74406302011-10-28 15:13:10 -0700228 ui->ShowProgress(fraction * (1-VERIFICATION_PROGRESS_FRACTION), seconds);
Doug Zongkerfbf3c102009-06-24 09:36:20 -0700229 } else if (strcmp(command, "set_progress") == 0) {
230 char* fraction_s = strtok(NULL, " \n");
231 float fraction = strtof(fraction_s, NULL);
Doug Zongker74406302011-10-28 15:13:10 -0700232 ui->SetProgress(fraction);
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700233 } else if (strcmp(command, "ui_print") == 0) {
234 char* str = strtok(NULL, "\n");
235 if (str) {
Tao Baob6918c72015-05-19 17:02:16 -0700236 ui->PrintOnScreenOnly("%s", str);
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700237 } else {
Tao Baob6918c72015-05-19 17:02:16 -0700238 ui->PrintOnScreenOnly("\n");
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700239 }
Doug Zongkerfafc85b2013-07-09 12:29:45 -0700240 fflush(stdout);
Doug Zongkerd0181b82011-10-19 10:51:12 -0700241 } else if (strcmp(command, "wipe_cache") == 0) {
Tao Bao145d8612015-03-25 15:51:15 -0700242 *wipe_cache = true;
Doug Zongkere5d5ac72012-04-12 11:01:22 -0700243 } else if (strcmp(command, "clear_display") == 0) {
244 ui->SetBackground(RecoveryUI::NONE);
Doug Zongkerc704e062014-05-23 08:40:35 -0700245 } else if (strcmp(command, "enable_reboot") == 0) {
246 // packages can explicitly request that they want the user
247 // to be able to reboot during installation (useful for
248 // debugging packages that don't exit).
249 ui->SetEnableReboot(true);
Tianjie Xu3c62b672016-02-05 18:25:58 -0800250 } else if (strcmp(command, "retry_update") == 0) {
251 retry_update = true;
Tianjie Xudd874b12016-05-13 12:13:15 -0700252 } else if (strcmp(command, "log") == 0) {
253 // Save the logging request from updater and write to
254 // last_install later.
255 log_buffer.push_back(std::string(strtok(NULL, "\n")));
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700256 } else {
257 LOGE("unknown command [%s]\n", command);
258 }
259 }
260 fclose(from_child);
261
262 int status;
263 waitpid(pid, &status, 0);
Tianjie Xu3c62b672016-02-05 18:25:58 -0800264 if (retry_update) {
265 return INSTALL_RETRY;
266 }
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700267 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
Doug Zongker9931f7f2009-06-10 14:11:53 -0700268 LOGE("Error in %s\n(Status %d)\n", path, WEXITSTATUS(status));
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700269 return INSTALL_ERROR;
270 }
271
Doug Zongkere08991e2010-02-02 13:09:52 -0800272 return INSTALL_SUCCESS;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700273}
274
Doug Zongker469243e2011-04-12 09:28:10 -0700275static int
Tianjie Xudd874b12016-05-13 12:13:15 -0700276really_install_package(const char *path, bool* wipe_cache, bool needs_mount,
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700277 std::vector<std::string>& log_buffer, int retry_count)
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800278{
Doug Zongker02ec6b82012-08-22 17:26:40 -0700279 ui->SetBackground(RecoveryUI::INSTALLING_UPDATE);
Doug Zongker74406302011-10-28 15:13:10 -0700280 ui->Print("Finding update package...\n");
Doug Zongker239ac6a2013-08-20 16:03:25 -0700281 // Give verification half the progress bar...
282 ui->SetProgressType(RecoveryUI::DETERMINATE);
283 ui->ShowProgress(VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME);
Doug Zongkercc8cd3f2010-09-20 12:16:13 -0700284 LOGI("Update location: %s\n", path);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800285
Doug Zongker99916f02014-01-13 14:16:58 -0800286 // Map the update package into memory.
287 ui->Print("Opening update package...\n");
288
Doug Zongker075ad802014-06-26 15:35:51 -0700289 if (path && needs_mount) {
Doug Zongker99916f02014-01-13 14:16:58 -0800290 if (path[0] == '@') {
291 ensure_path_mounted(path+1);
292 } else {
293 ensure_path_mounted(path);
294 }
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800295 }
296
Doug Zongker99916f02014-01-13 14:16:58 -0800297 MemMapping map;
298 if (sysMapFile(path, &map) != 0) {
299 LOGE("failed to map file\n");
300 return INSTALL_CORRUPT;
301 }
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800302
Elliott Hughes8febafa2016-04-13 16:39:56 -0700303 // Load keys.
Tao Bao71e3e092016-02-02 14:02:27 -0800304 std::vector<Certificate> loadedKeys;
305 if (!load_keys(PUBLIC_KEYS_FILE, loadedKeys)) {
Doug Zongkerd1b19b92009-04-01 15:48:46 -0700306 LOGE("Failed to load keys\n");
307 return INSTALL_CORRUPT;
308 }
Tao Bao71e3e092016-02-02 14:02:27 -0800309 LOGI("%zu key(s) loaded from %s\n", loadedKeys.size(), PUBLIC_KEYS_FILE);
Doug Zongkerd1b19b92009-04-01 15:48:46 -0700310
Elliott Hughes8febafa2016-04-13 16:39:56 -0700311 // Verify package.
Doug Zongker74406302011-10-28 15:13:10 -0700312 ui->Print("Verifying update package...\n");
Elliott Hughes8febafa2016-04-13 16:39:56 -0700313 auto t0 = std::chrono::system_clock::now();
Tao Bao71e3e092016-02-02 14:02:27 -0800314 int err = verify_file(map.addr, map.length, loadedKeys);
Elliott Hughes8febafa2016-04-13 16:39:56 -0700315 std::chrono::duration<double> duration = std::chrono::system_clock::now() - t0;
316 ui->Print("Update package verification took %.1f s (result %d).\n", duration.count(), err);
Doug Zongker60151a22009-08-12 18:30:03 -0700317 if (err != VERIFY_SUCCESS) {
318 LOGE("signature verification failed\n");
Tianjie Xu16255832016-04-30 11:49:59 -0700319 log_buffer.push_back(android::base::StringPrintf("error: %d", kZipVerificationFailure));
320
Doug Zongker99916f02014-01-13 14:16:58 -0800321 sysReleaseMap(&map);
Doug Zongker60151a22009-08-12 18:30:03 -0700322 return INSTALL_CORRUPT;
323 }
324
Elliott Hughes8febafa2016-04-13 16:39:56 -0700325 // Try to open the package.
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800326 ZipArchive zip;
Doug Zongker99916f02014-01-13 14:16:58 -0800327 err = mzOpenZipArchive(map.addr, map.length, &zip);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800328 if (err != 0) {
329 LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad");
Tianjie Xu16255832016-04-30 11:49:59 -0700330 log_buffer.push_back(android::base::StringPrintf("error: %d", kZipOpenFailure));
331
Doug Zongker99916f02014-01-13 14:16:58 -0800332 sysReleaseMap(&map);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800333 return INSTALL_CORRUPT;
334 }
335
Elliott Hughes8febafa2016-04-13 16:39:56 -0700336 // Verify and install the contents of the package.
Doug Zongker74406302011-10-28 15:13:10 -0700337 ui->Print("Installing update...\n");
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700338 if (retry_count > 0) {
339 ui->Print("Retry attempt: %d\n", retry_count);
340 }
Doug Zongkerc704e062014-05-23 08:40:35 -0700341 ui->SetEnableReboot(false);
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700342 int result = try_update_binary(path, &zip, wipe_cache, log_buffer, retry_count);
Doug Zongkerc704e062014-05-23 08:40:35 -0700343 ui->SetEnableReboot(true);
Doug Zongker075ad802014-06-26 15:35:51 -0700344 ui->Print("\n");
Doug Zongker99916f02014-01-13 14:16:58 -0800345
346 sysReleaseMap(&map);
347
348 return result;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800349}
Doug Zongker469243e2011-04-12 09:28:10 -0700350
351int
Tao Bao145d8612015-03-25 15:51:15 -0700352install_package(const char* path, bool* wipe_cache, const char* install_file,
Tianjie Xu16255832016-04-30 11:49:59 -0700353 bool needs_mount, int retry_count)
Doug Zongker469243e2011-04-12 09:28:10 -0700354{
Tao Bao682c34b2015-04-07 17:16:35 -0700355 modified_flash = true;
Tianjie Xudd874b12016-05-13 12:13:15 -0700356 auto start = std::chrono::system_clock::now();
Tao Bao682c34b2015-04-07 17:16:35 -0700357
Doug Zongkerd0181b82011-10-19 10:51:12 -0700358 FILE* install_log = fopen_path(install_file, "w");
Doug Zongker469243e2011-04-12 09:28:10 -0700359 if (install_log) {
360 fputs(path, install_log);
361 fputc('\n', install_log);
362 } else {
363 LOGE("failed to open last_install: %s\n", strerror(errno));
364 }
Doug Zongker239ac6a2013-08-20 16:03:25 -0700365 int result;
Tianjie Xudd874b12016-05-13 12:13:15 -0700366 std::vector<std::string> log_buffer;
Doug Zongker239ac6a2013-08-20 16:03:25 -0700367 if (setup_install_mounts() != 0) {
368 LOGE("failed to set up expected mounts for install; aborting\n");
369 result = INSTALL_ERROR;
370 } else {
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700371 result = really_install_package(path, wipe_cache, needs_mount, log_buffer, retry_count);
Doug Zongker239ac6a2013-08-20 16:03:25 -0700372 }
Tianjie Xu16255832016-04-30 11:49:59 -0700373 if (install_log != nullptr) {
Doug Zongker469243e2011-04-12 09:28:10 -0700374 fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log);
375 fputc('\n', install_log);
Tianjie Xudd874b12016-05-13 12:13:15 -0700376 std::chrono::duration<double> duration = std::chrono::system_clock::now() - start;
377 int count = static_cast<int>(duration.count());
378 // Report the time spent to apply OTA update in seconds.
379 fprintf(install_log, "time_total: %d\n", count);
Tianjie Xu16255832016-04-30 11:49:59 -0700380 fprintf(install_log, "retry: %d\n", retry_count);
Tianjie Xudd874b12016-05-13 12:13:15 -0700381
382 for (const auto& s : log_buffer) {
383 fprintf(install_log, "%s\n", s.c_str());
384 }
385
Doug Zongker469243e2011-04-12 09:28:10 -0700386 fclose(install_log);
Doug Zongker469243e2011-04-12 09:28:10 -0700387 }
388 return result;
389}