aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Micay2017-06-23 07:33:24 -0500
committerDaniel Micay2017-06-26 09:53:03 -0500
commita29d8d69d23b2ed2ead83c67f84c9c474dd563cb (patch)
treeac0edb9d6f9172344443b6dcb77018e8b1569356 /install.cpp
parent5efe2bca2282dd8aa613ae85b267780f6c1d1307 (diff)
downloadplatform-bootable-recovery-a29d8d69d23b2ed2ead83c67f84c9c474dd563cb.tar.gz
platform-bootable-recovery-a29d8d69d23b2ed2ead83c67f84c9c474dd563cb.tar.xz
platform-bootable-recovery-a29d8d69d23b2ed2ead83c67f84c9c474dd563cb.zip
avoid assuming build number is a 32-bit integer
The install logging currently assumes that the build number is a 32-bit integer and prints an error when that doesn't hold true. However, that's only a convention used by Google builds. From build/core/version_defaults.mk: ifeq "" "$(BUILD_NUMBER)" # BUILD_NUMBER should be set to the source control value that # represents the current state of the source code. E.g., a # perforce changelist number or a git hash. Can be an arbitrary string # (to allow for source control that uses something other than numbers), # but must be a single word and a valid file name. # # If no BUILD_NUMBER is set, create a useful "I am an engineering build # from this date/time" value. Make it start with a non-digit so that # anyone trying to parse it as an integer will probably get "0". BUILD_NUMBER := eng.$(shell echo $${USER:0:6}).$(shell $(DATE) +%Y%m%d.%H%M%S) endif Change-Id: I8e7cec0618783f69545ba76d0dce2bbc1681784c
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/install.cpp b/install.cpp
index db4ba937..7ba8f013 100644
--- a/install.cpp
+++ b/install.cpp
@@ -66,18 +66,14 @@ static constexpr float VERIFICATION_PROGRESS_FRACTION = 0.25;
66static std::condition_variable finish_log_temperature; 66static std::condition_variable finish_log_temperature;
67 67
68// This function parses and returns the build.version.incremental 68// This function parses and returns the build.version.incremental
69static int parse_build_number(const std::string& str) { 69static std::string parse_build_number(const std::string& str) {
70 size_t pos = str.find('='); 70 size_t pos = str.find('=');
71 if (pos != std::string::npos) { 71 if (pos != std::string::npos) {
72 std::string num_string = android::base::Trim(str.substr(pos+1)); 72 return android::base::Trim(str.substr(pos+1));
73 int build_number;
74 if (android::base::ParseInt(num_string.c_str(), &build_number, 0)) {
75 return build_number;
76 }
77 } 73 }
78 74
79 LOG(ERROR) << "Failed to parse build number in " << str; 75 LOG(ERROR) << "Failed to parse build number in " << str;
80 return -1; 76 return "";
81} 77}
82 78
83bool read_metadata_from_package(ZipArchiveHandle zip, std::string* metadata) { 79bool read_metadata_from_package(ZipArchiveHandle zip, std::string* metadata) {
@@ -114,14 +110,14 @@ static void read_source_target_build(ZipArchiveHandle zip, std::vector<std::stri
114 for (const std::string& line : lines) { 110 for (const std::string& line : lines) {
115 std::string str = android::base::Trim(line); 111 std::string str = android::base::Trim(line);
116 if (android::base::StartsWith(str, "pre-build-incremental")) { 112 if (android::base::StartsWith(str, "pre-build-incremental")) {
117 int source_build = parse_build_number(str); 113 std::string source_build = parse_build_number(str);
118 if (source_build != -1) { 114 if (!source_build.empty()) {
119 log_buffer->push_back(android::base::StringPrintf("source_build: %d", source_build)); 115 log_buffer->push_back("source_build: " + source_build);
120 } 116 }
121 } else if (android::base::StartsWith(str, "post-build-incremental")) { 117 } else if (android::base::StartsWith(str, "post-build-incremental")) {
122 int target_build = parse_build_number(str); 118 std::string target_build = parse_build_number(str);
123 if (target_build != -1) { 119 if (!target_build.empty()) {
124 log_buffer->push_back(android::base::StringPrintf("target_build: %d", target_build)); 120 log_buffer->push_back("target_build: " + target_build);
125 } 121 }
126 } 122 }
127 } 123 }