Reland: Pass apex_info.pb file to delta_generator
target_files contain META/apex_info.pb, which contains metadata about
compressed apexes. Extract this file from target_file.zip, and pass it
to delta_generator. delta_generator will then copy these data to
update_metadata
Test: generate an OTA, make sure a device running an older build can
install the OTA
Bug: 172911822
Change-Id: If0e185a32262a849d533c3316ffdf205cb6628b6
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 5e2e555..7288eca 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -425,6 +425,8 @@
disable_vabc,
false,
"Whether to disable Virtual AB Compression when installing the OTA");
+ DEFINE_string(
+ apex_info_file, "", "Path to META/apex_info.pb found in target build");
brillo::FlagHelper::Init(
argc,
@@ -532,6 +534,15 @@
return 1;
}
+ if (!FLAGS_apex_info_file.empty()) {
+ // apex_info_file should point to a regular file(or symlink to a regular
+ // file)
+ CHECK(utils::FileExists(FLAGS_apex_info_file.c_str()));
+ CHECK(utils::IsRegFile(FLAGS_apex_info_file.c_str()) ||
+ utils::IsSymlink(FLAGS_apex_info_file.c_str()));
+ payload_config.apex_info_file = FLAGS_apex_info_file;
+ }
+
if (!FLAGS_new_partitions.empty()) {
LOG_IF(FATAL, !FLAGS_new_image.empty() || !FLAGS_new_kernel.empty())
<< "--new_image and --new_kernel are deprecated, please use "
diff --git a/payload_generator/payload_file.cc b/payload_generator/payload_file.cc
index 1174597..4334066 100644
--- a/payload_generator/payload_file.cc
+++ b/payload_generator/payload_file.cc
@@ -25,6 +25,7 @@
#include <base/strings/stringprintf.h>
#include "update_engine/common/hash_calculator.h"
+#include "update_engine/common/utils.h"
#include "update_engine/payload_consumer/delta_performer.h"
#include "update_engine/payload_consumer/file_writer.h"
#include "update_engine/payload_consumer/payload_constants.h"
@@ -77,6 +78,20 @@
if (config.is_partial_update) {
manifest_.set_partial_update(true);
}
+
+ if (!config.apex_info_file.empty()) {
+ ApexMetadata apex_metadata;
+ int fd = open(config.apex_info_file.c_str(), O_RDONLY);
+ if (fd < 0) {
+ PLOG(FATAL) << "Failed to open " << config.apex_info_file << " for read.";
+ }
+ ScopedFdCloser closer{&fd};
+ CHECK(apex_metadata.ParseFromFileDescriptor(fd));
+ if (apex_metadata.apex_info_size() > 0) {
+ *manifest_.mutable_apex_info() =
+ std::move(*apex_metadata.mutable_apex_info());
+ }
+ }
return true;
}
diff --git a/payload_generator/payload_generation_config.h b/payload_generator/payload_generation_config.h
index 64733e1..f7d0b6b 100644
--- a/payload_generator/payload_generation_config.h
+++ b/payload_generator/payload_generation_config.h
@@ -235,6 +235,9 @@
// support VABC in order to use it. If this is set to false, device must not
// use VABC regardless.
bool disable_vabc = false;
+
+ // Path to apex_info.pb, extracted from target_file.zip
+ std::string apex_info_file;
};
} // namespace chromeos_update_engine