blob: 3d07290647f1c252c4a40b3a77de59fa72db1569 [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"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080040#include "roots.h"
Doug Zongker10e418d2011-10-28 10:33:05 -070041#include "ui.h"
Mattias Nissler452df6d2016-04-04 16:17:01 +020042#include "verifier.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080043
Doug Zongker74406302011-10-28 15:13:10 -070044extern RecoveryUI* ui;
45
Doug Zongkerb2ee9202009-06-04 10:24:53 -070046#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
Doug Zongkerd1b19b92009-04-01 15:48:46 -070047#define PUBLIC_KEYS_FILE "/res/keys"
Tianjie Xub0ddae52016-06-08 14:30:04 -070048static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080049
Doug Zongker74406302011-10-28 15:13:10 -070050// Default allocation of progress bar segments to operations
51static const int VERIFICATION_PROGRESS_TIME = 60;
52static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
53static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
54static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
55
Tianjie Xub0ddae52016-06-08 14:30:04 -070056// This function parses and returns the build.version.incremental
57static int parse_build_number(std::string str) {
58 size_t pos = str.find("=");
59 if (pos != std::string::npos) {
60 std::string num_string = android::base::Trim(str.substr(pos+1));
61 int build_number;
62 if (android::base::ParseInt(num_string.c_str(), &build_number, 0)) {
63 return build_number;
64 }
65 }
66
67 LOGE("Failed to parse build number in %s.\n", str.c_str());
68 return -1;
69}
70
71// Read the build.version.incremental of src/tgt from the metadata and log it to last_install.
72static void read_source_target_build(ZipArchive* zip, std::vector<std::string>& log_buffer) {
73 const ZipEntry* meta_entry = mzFindZipEntry(zip, METADATA_PATH);
74 if (meta_entry == nullptr) {
75 LOGE("Failed to find %s in update package.\n", METADATA_PATH);
76 return;
77 }
78
79 std::string meta_data(meta_entry->uncompLen, '\0');
80 if (!mzReadZipEntry(zip, meta_entry, &meta_data[0], meta_entry->uncompLen)) {
81 LOGE("Failed to read metadata in update package.\n");
82 return;
83 }
84
85 // Examples of the pre-build and post-build strings in metadata:
86 // pre-build-incremental=2943039
87 // post-build-incremental=2951741
88 std::vector<std::string> lines = android::base::Split(meta_data, "\n");
89 for (const std::string& line : lines) {
90 std::string str = android::base::Trim(line);
91 if (android::base::StartsWith(str, "pre-build-incremental")){
92 int source_build = parse_build_number(str);
93 if (source_build != -1) {
94 log_buffer.push_back(android::base::StringPrintf("source_build: %d",
95 source_build));
96 }
97 } else if (android::base::StartsWith(str, "post-build-incremental")) {
98 int target_build = parse_build_number(str);
99 if (target_build != -1) {
100 log_buffer.push_back(android::base::StringPrintf("target_build: %d",
101 target_build));
102 }
103 }
104 }
105}
106
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700107// If the package contains an update binary, extract it and run it.
108static int
Tianjie Xudd874b12016-05-13 12:13:15 -0700109try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache,
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700110 std::vector<std::string>& log_buffer, int retry_count)
Tianjie Xudd874b12016-05-13 12:13:15 -0700111{
Tianjie Xub0ddae52016-06-08 14:30:04 -0700112 read_source_target_build(zip, log_buffer);
113
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700114 const ZipEntry* binary_entry =
115 mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);
116 if (binary_entry == NULL) {
Doug Zongker8e5e4da2010-09-14 18:06:55 -0700117 mzCloseZipArchive(zip);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700118 return INSTALL_CORRUPT;
119 }
120
Doug Zongker10e418d2011-10-28 10:33:05 -0700121 const char* binary = "/tmp/update_binary";
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700122 unlink(binary);
123 int fd = creat(binary, 0755);
124 if (fd < 0) {
Doug Zongker8e5e4da2010-09-14 18:06:55 -0700125 mzCloseZipArchive(zip);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700126 LOGE("Can't make %s\n", binary);
Doug Zongkerd0181b82011-10-19 10:51:12 -0700127 return INSTALL_ERROR;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700128 }
129 bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd);
130 close(fd);
Doug Zongker8e5e4da2010-09-14 18:06:55 -0700131 mzCloseZipArchive(zip);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700132
133 if (!ok) {
134 LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME);
Doug Zongkerd0181b82011-10-19 10:51:12 -0700135 return INSTALL_ERROR;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700136 }
137
138 int pipefd[2];
139 pipe(pipefd);
140
141 // When executing the update binary contained in the package, the
142 // arguments passed are:
143 //
Doug Zongkerfb2e3af2009-06-17 17:29:40 -0700144 // - the version number for this interface
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700145 //
146 // - an fd to which the program can write in order to update the
147 // progress bar. The program can write single-line commands:
148 //
149 // progress <frac> <secs>
Doug Zongkerfbf3c102009-06-24 09:36:20 -0700150 // fill up the next <frac> part of of the progress bar
151 // over <secs> seconds. If <secs> is zero, use
152 // set_progress commands to manually control the
Tao Baob07e1f32015-04-10 16:14:52 -0700153 // progress of this segment of the bar.
Doug Zongkerfbf3c102009-06-24 09:36:20 -0700154 //
155 // set_progress <frac>
156 // <frac> should be between 0.0 and 1.0; sets the
157 // progress bar within the segment defined by the most
158 // recent progress command.
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700159 //
160 // firmware <"hboot"|"radio"> <filename>
161 // arrange to install the contents of <filename> in the
Doug Zongkere08991e2010-02-02 13:09:52 -0800162 // given partition on reboot.
163 //
164 // (API v2: <filename> may start with "PACKAGE:" to
165 // indicate taking a file from the OTA package.)
166 //
167 // (API v3: this command no longer exists.)
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700168 //
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700169 // ui_print <string>
170 // display <string> on the screen.
171 //
Tao Baob07e1f32015-04-10 16:14:52 -0700172 // wipe_cache
173 // a wipe of cache will be performed following a successful
174 // installation.
175 //
176 // clear_display
177 // turn off the text display.
178 //
179 // enable_reboot
180 // packages can explicitly request that they want the user
181 // to be able to reboot during installation (useful for
182 // debugging packages that don't exit).
183 //
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700184 // - the name of the package zip file.
185 //
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700186 // - an optional argument "retry" if this update is a retry of a failed
187 // update attempt.
188 //
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700189
Tianjie Xu64f46fb2016-06-03 15:44:52 -0700190 const char* args[6];
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700191 args[0] = binary;
Doug Zongkerfb2e3af2009-06-17 17:29:40 -0700192 args[1] = EXPAND(RECOVERY_API_VERSION); // defined in Android.mk
Yabin Cui4425c1d2016-02-10 13:47:32 -0800193 char temp[16];
194 snprintf(temp, sizeof(temp), "%d", pipefd[1]);
Doug Zongker10e418d2011-10-28 10:33:05 -0700195 args[2] = temp;
Yabin Cui4425c1d2016-02-10 13:47:32 -0800196 args[3] = path;
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700197 args[4] = retry_count > 0 ? "retry" : NULL;
198 args[5] = NULL;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700199
200 pid_t pid = fork();
201 if (pid == 0) {
Alistair Strachan027429a2013-07-17 10:41:49 -0700202 umask(022);
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700203 close(pipefd[0]);
Yabin Cui4425c1d2016-02-10 13:47:32 -0800204 execv(binary, const_cast<char**>(args));
Doug Zongker56c51052010-07-01 09:18:44 -0700205 fprintf(stdout, "E:Can't run %s (%s)\n", binary, strerror(errno));
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700206 _exit(-1);
207 }
208 close(pipefd[1]);
209
Tao Bao145d8612015-03-25 15:51:15 -0700210 *wipe_cache = false;
Tianjie Xu3c62b672016-02-05 18:25:58 -0800211 bool retry_update = false;
Doug Zongkerd0181b82011-10-19 10:51:12 -0700212
Doug Zongker64893cc2009-07-14 16:31:56 -0700213 char buffer[1024];
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700214 FILE* from_child = fdopen(pipefd[0], "r");
215 while (fgets(buffer, sizeof(buffer), from_child) != NULL) {
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700216 char* command = strtok(buffer, " \n");
217 if (command == NULL) {
218 continue;
219 } else if (strcmp(command, "progress") == 0) {
220 char* fraction_s = strtok(NULL, " \n");
221 char* seconds_s = strtok(NULL, " \n");
222
223 float fraction = strtof(fraction_s, NULL);
224 int seconds = strtol(seconds_s, NULL, 10);
225
Doug Zongker74406302011-10-28 15:13:10 -0700226 ui->ShowProgress(fraction * (1-VERIFICATION_PROGRESS_FRACTION), seconds);
Doug Zongkerfbf3c102009-06-24 09:36:20 -0700227 } else if (strcmp(command, "set_progress") == 0) {
228 char* fraction_s = strtok(NULL, " \n");
229 float fraction = strtof(fraction_s, NULL);
Doug Zongker74406302011-10-28 15:13:10 -0700230 ui->SetProgress(fraction);
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700231 } else if (strcmp(command, "ui_print") == 0) {
232 char* str = strtok(NULL, "\n");
233 if (str) {
Tao Baob6918c72015-05-19 17:02:16 -0700234 ui->PrintOnScreenOnly("%s", str);
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700235 } else {
Tao Baob6918c72015-05-19 17:02:16 -0700236 ui->PrintOnScreenOnly("\n");
Doug Zongkerd9c9d102009-06-12 12:24:39 -0700237 }
Doug Zongkerfafc85b2013-07-09 12:29:45 -0700238 fflush(stdout);
Doug Zongkerd0181b82011-10-19 10:51:12 -0700239 } else if (strcmp(command, "wipe_cache") == 0) {
Tao Bao145d8612015-03-25 15:51:15 -0700240 *wipe_cache = true;
Doug Zongkere5d5ac72012-04-12 11:01:22 -0700241 } else if (strcmp(command, "clear_display") == 0) {
242 ui->SetBackground(RecoveryUI::NONE);
Doug Zongkerc704e062014-05-23 08:40:35 -0700243 } else if (strcmp(command, "enable_reboot") == 0) {
244 // packages can explicitly request that they want the user
245 // to be able to reboot during installation (useful for
246 // debugging packages that don't exit).
247 ui->SetEnableReboot(true);
Tianjie Xu3c62b672016-02-05 18:25:58 -0800248 } else if (strcmp(command, "retry_update") == 0) {
249 retry_update = true;
Tianjie Xudd874b12016-05-13 12:13:15 -0700250 } else if (strcmp(command, "log") == 0) {
251 // Save the logging request from updater and write to
252 // last_install later.
253 log_buffer.push_back(std::string(strtok(NULL, "\n")));
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700254 } else {
255 LOGE("unknown command [%s]\n", command);
256 }
257 }
258 fclose(from_child);
259
260 int status;
261 waitpid(pid, &status, 0);
Tianjie Xu3c62b672016-02-05 18:25:58 -0800262 if (retry_update) {
263 return INSTALL_RETRY;
264 }
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700265 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
Doug Zongker9931f7f2009-06-10 14:11:53 -0700266 LOGE("Error in %s\n(Status %d)\n", path, WEXITSTATUS(status));
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700267 return INSTALL_ERROR;
268 }
269
Doug Zongkere08991e2010-02-02 13:09:52 -0800270 return INSTALL_SUCCESS;
Doug Zongkerb2ee9202009-06-04 10:24:53 -0700271}
272
Doug Zongker469243e2011-04-12 09:28:10 -0700273static int
Tianjie Xudd874b12016-05-13 12:13:15 -0700274really_install_package(const char *path, bool* wipe_cache, bool needs_mount,
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700275 std::vector<std::string>& log_buffer, int retry_count)
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800276{
Doug Zongker02ec6b82012-08-22 17:26:40 -0700277 ui->SetBackground(RecoveryUI::INSTALLING_UPDATE);
Doug Zongker74406302011-10-28 15:13:10 -0700278 ui->Print("Finding update package...\n");
Doug Zongker239ac6a2013-08-20 16:03:25 -0700279 // Give verification half the progress bar...
280 ui->SetProgressType(RecoveryUI::DETERMINATE);
281 ui->ShowProgress(VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME);
Doug Zongkercc8cd3f2010-09-20 12:16:13 -0700282 LOGI("Update location: %s\n", path);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800283
Doug Zongker99916f02014-01-13 14:16:58 -0800284 // Map the update package into memory.
285 ui->Print("Opening update package...\n");
286
Doug Zongker075ad802014-06-26 15:35:51 -0700287 if (path && needs_mount) {
Doug Zongker99916f02014-01-13 14:16:58 -0800288 if (path[0] == '@') {
289 ensure_path_mounted(path+1);
290 } else {
291 ensure_path_mounted(path);
292 }
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800293 }
294
Doug Zongker99916f02014-01-13 14:16:58 -0800295 MemMapping map;
296 if (sysMapFile(path, &map) != 0) {
297 LOGE("failed to map file\n");
298 return INSTALL_CORRUPT;
299 }
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800300
Elliott Hughes8febafa2016-04-13 16:39:56 -0700301 // Load keys.
Tao Bao71e3e092016-02-02 14:02:27 -0800302 std::vector<Certificate> loadedKeys;
303 if (!load_keys(PUBLIC_KEYS_FILE, loadedKeys)) {
Doug Zongkerd1b19b92009-04-01 15:48:46 -0700304 LOGE("Failed to load keys\n");
305 return INSTALL_CORRUPT;
306 }
Tao Bao71e3e092016-02-02 14:02:27 -0800307 LOGI("%zu key(s) loaded from %s\n", loadedKeys.size(), PUBLIC_KEYS_FILE);
Doug Zongkerd1b19b92009-04-01 15:48:46 -0700308
Elliott Hughes8febafa2016-04-13 16:39:56 -0700309 // Verify package.
Doug Zongker74406302011-10-28 15:13:10 -0700310 ui->Print("Verifying update package...\n");
Elliott Hughes8febafa2016-04-13 16:39:56 -0700311 auto t0 = std::chrono::system_clock::now();
Tao Bao71e3e092016-02-02 14:02:27 -0800312 int err = verify_file(map.addr, map.length, loadedKeys);
Elliott Hughes8febafa2016-04-13 16:39:56 -0700313 std::chrono::duration<double> duration = std::chrono::system_clock::now() - t0;
314 ui->Print("Update package verification took %.1f s (result %d).\n", duration.count(), err);
Doug Zongker60151a22009-08-12 18:30:03 -0700315 if (err != VERIFY_SUCCESS) {
316 LOGE("signature verification failed\n");
Tianjie Xu16255832016-04-30 11:49:59 -0700317 log_buffer.push_back(android::base::StringPrintf("error: %d", kZipVerificationFailure));
318
Doug Zongker99916f02014-01-13 14:16:58 -0800319 sysReleaseMap(&map);
Doug Zongker60151a22009-08-12 18:30:03 -0700320 return INSTALL_CORRUPT;
321 }
322
Elliott Hughes8febafa2016-04-13 16:39:56 -0700323 // Try to open the package.
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800324 ZipArchive zip;
Doug Zongker99916f02014-01-13 14:16:58 -0800325 err = mzOpenZipArchive(map.addr, map.length, &zip);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800326 if (err != 0) {
327 LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad");
Tianjie Xu16255832016-04-30 11:49:59 -0700328 log_buffer.push_back(android::base::StringPrintf("error: %d", kZipOpenFailure));
329
Doug Zongker99916f02014-01-13 14:16:58 -0800330 sysReleaseMap(&map);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800331 return INSTALL_CORRUPT;
332 }
333
Elliott Hughes8febafa2016-04-13 16:39:56 -0700334 // Verify and install the contents of the package.
Doug Zongker74406302011-10-28 15:13:10 -0700335 ui->Print("Installing update...\n");
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700336 if (retry_count > 0) {
337 ui->Print("Retry attempt: %d\n", retry_count);
338 }
Doug Zongkerc704e062014-05-23 08:40:35 -0700339 ui->SetEnableReboot(false);
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700340 int result = try_update_binary(path, &zip, wipe_cache, log_buffer, retry_count);
Doug Zongkerc704e062014-05-23 08:40:35 -0700341 ui->SetEnableReboot(true);
Doug Zongker075ad802014-06-26 15:35:51 -0700342 ui->Print("\n");
Doug Zongker99916f02014-01-13 14:16:58 -0800343
344 sysReleaseMap(&map);
345
346 return result;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800347}
Doug Zongker469243e2011-04-12 09:28:10 -0700348
349int
Tao Bao145d8612015-03-25 15:51:15 -0700350install_package(const char* path, bool* wipe_cache, const char* install_file,
Tianjie Xu16255832016-04-30 11:49:59 -0700351 bool needs_mount, int retry_count)
Doug Zongker469243e2011-04-12 09:28:10 -0700352{
Tao Bao682c34b2015-04-07 17:16:35 -0700353 modified_flash = true;
Tianjie Xudd874b12016-05-13 12:13:15 -0700354 auto start = std::chrono::system_clock::now();
Tao Bao682c34b2015-04-07 17:16:35 -0700355
Doug Zongkerd0181b82011-10-19 10:51:12 -0700356 FILE* install_log = fopen_path(install_file, "w");
Doug Zongker469243e2011-04-12 09:28:10 -0700357 if (install_log) {
358 fputs(path, install_log);
359 fputc('\n', install_log);
360 } else {
361 LOGE("failed to open last_install: %s\n", strerror(errno));
362 }
Doug Zongker239ac6a2013-08-20 16:03:25 -0700363 int result;
Tianjie Xudd874b12016-05-13 12:13:15 -0700364 std::vector<std::string> log_buffer;
Doug Zongker239ac6a2013-08-20 16:03:25 -0700365 if (setup_install_mounts() != 0) {
366 LOGE("failed to set up expected mounts for install; aborting\n");
367 result = INSTALL_ERROR;
368 } else {
Tianjie Xu7ce287d2016-05-31 09:29:49 -0700369 result = really_install_package(path, wipe_cache, needs_mount, log_buffer, retry_count);
Doug Zongker239ac6a2013-08-20 16:03:25 -0700370 }
Tianjie Xu16255832016-04-30 11:49:59 -0700371 if (install_log != nullptr) {
Doug Zongker469243e2011-04-12 09:28:10 -0700372 fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log);
373 fputc('\n', install_log);
Tianjie Xudd874b12016-05-13 12:13:15 -0700374 std::chrono::duration<double> duration = std::chrono::system_clock::now() - start;
375 int count = static_cast<int>(duration.count());
376 // Report the time spent to apply OTA update in seconds.
377 fprintf(install_log, "time_total: %d\n", count);
Tianjie Xu16255832016-04-30 11:49:59 -0700378 fprintf(install_log, "retry: %d\n", retry_count);
Tianjie Xudd874b12016-05-13 12:13:15 -0700379
380 for (const auto& s : log_buffer) {
381 fprintf(install_log, "%s\n", s.c_str());
382 }
383
Doug Zongker469243e2011-04-12 09:28:10 -0700384 fclose(install_log);
Doug Zongker469243e2011-04-12 09:28:10 -0700385 }
386 return result;
387}