Add option to enable zucchini
Test: th
Bug: 194237829
Change-Id: Ie3ddf889e6b02165039eb155c457832e0eb7c13a
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index 92cfe9e..321795a 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -217,9 +217,8 @@
CHECK(aop);
CHECK(data_blob);
if (!old_block_info_.blocks.empty() && !new_block_info_.blocks.empty() &&
- config_.enable_lz4diff &&
- config_.version.OperationAllowed(InstallOperation::LZ4DIFF_BSDIFF) &&
- config_.version.OperationAllowed(InstallOperation::LZ4DIFF_PUFFDIFF)) {
+ config_.OperationEnabled(InstallOperation::LZ4DIFF_BSDIFF) &&
+ config_.OperationEnabled(InstallOperation::LZ4DIFF_PUFFDIFF)) {
brillo::Blob patch;
InstallOperation::Type op_type;
if (Lz4Diff(old_data_,
@@ -236,13 +235,12 @@
}
}
- const auto& version = config_.version;
const uint64_t input_bytes = std::max(utils::BlocksInExtents(src_extents_),
utils::BlocksInExtents(dst_extents_)) *
kBlockSize;
for (auto [op_type, limit] : diff_candidates) {
- if (!version.OperationAllowed(op_type)) {
+ if (!config_.OperationEnabled(op_type)) {
continue;
}
@@ -255,7 +253,7 @@
// Prefer BROTLI_BSDIFF as it gives smaller patch size.
if (op_type == InstallOperation::SOURCE_BSDIFF &&
- version.OperationAllowed(InstallOperation::BROTLI_BSDIFF)) {
+ config_.OperationEnabled(InstallOperation::BROTLI_BSDIFF)) {
op_type = InstallOperation::BROTLI_BSDIFF;
}
@@ -567,7 +565,7 @@
&new_visited_blocks,
&old_zero_blocks));
- bool puffdiff_allowed = version.OperationAllowed(InstallOperation::PUFFDIFF);
+ bool puffdiff_allowed = config.OperationEnabled(InstallOperation::PUFFDIFF);
map<string, FilesystemInterface::File> old_files_map;
if (old_part.fs_interface) {
vector<FilesystemInterface::File> old_files;
@@ -699,7 +697,6 @@
ExtentRanges* old_visited_blocks,
ExtentRanges* new_visited_blocks,
ExtentRanges* old_zero_blocks) {
- const auto& version = config.version;
vector<BlockMapping::BlockId> old_block_ids;
vector<BlockMapping::BlockId> new_block_ids;
TEST_AND_RETURN_FALSE(MapPartitionBlocks(old_part,
@@ -765,7 +762,7 @@
size_t num_ops = aops->size();
new_visited_blocks->AddExtents(new_zeros);
for (const Extent& extent : new_zeros) {
- if (version.OperationAllowed(InstallOperation::ZERO)) {
+ if (config.OperationEnabled(InstallOperation::ZERO)) {
for (uint64_t offset = 0; offset < extent.num_blocks();
offset += chunk_blocks) {
uint64_t num_blocks =
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 1ca5b9d..09fb837 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -439,6 +439,11 @@
false,
"Whether to enable LZ4diff feature when processing EROFS images.");
+ DEFINE_bool(
+ enable_zucchini,
+ true,
+ "Whether to enable zucchini feature when processing executable files.");
+
brillo::FlagHelper::Init(
argc,
argv,
@@ -556,6 +561,8 @@
payload_config.enable_vabc_xor = FLAGS_enable_vabc_xor;
payload_config.enable_lz4diff = FLAGS_enable_lz4diff;
+ payload_config.enable_zucchini = FLAGS_enable_zucchini;
+
payload_config.ParseCompressorTypes(FLAGS_compressor_types);
if (!FLAGS_new_partitions.empty()) {
diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc
index bb8f64f..8ff4999 100644
--- a/payload_generator/payload_generation_config.cc
+++ b/payload_generator/payload_generation_config.cc
@@ -357,4 +357,20 @@
}
}
+bool PayloadGenerationConfig::OperationEnabled(
+ InstallOperation::Type op) const noexcept {
+ if (!version.OperationAllowed(op)) {
+ return false;
+ }
+ switch (op) {
+ case InstallOperation::ZUCCHINI:
+ return enable_zucchini;
+ case InstallOperation::LZ4DIFF_BSDIFF:
+ case InstallOperation::LZ4DIFF_PUFFDIFF:
+ return enable_lz4diff;
+ default:
+ return true;
+ }
+}
+
} // namespace chromeos_update_engine
diff --git a/payload_generator/payload_generation_config.h b/payload_generator/payload_generation_config.h
index b3f3c74..d71649b 100644
--- a/payload_generator/payload_generation_config.h
+++ b/payload_generator/payload_generation_config.h
@@ -243,8 +243,13 @@
// Whether to enable LZ4diff ops
bool enable_lz4diff = false;
+ // Whether to enable zucchini ops
+ bool enable_zucchini = true;
+
std::vector<bsdiff::CompressorType> compressors{
bsdiff::CompressorType::kBZ2, bsdiff::CompressorType::kBrotli};
+
+ [[nodiscard]] bool OperationEnabled(InstallOperation::Type op) const noexcept;
};
} // namespace chromeos_update_engine
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index 2f5ef22..2628286 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -212,6 +212,8 @@
"Optional: Override the minor version for the delta generation."
DEFINE_string compressor_types "" \
"Optional: allowed compressor types. Colon separated, allowe values are bz2 and brotli"
+ DEFINE_string enable_zucchini "" \
+ "Optional: Whether to enable zucchini diffing"
fi
if [[ "${COMMAND}" == "hash" || "${COMMAND}" == "sign" ]]; then
DEFINE_string unsigned_payload "" "Path to the input unsigned payload."
@@ -723,6 +725,10 @@
GENERATOR_ARGS+=(
--compressor_types="${FLAGS_compressor_types}" )
fi
+ if [[ -n "${FLAGS_enable_zucchini}" ]]; then
+ GENERATOR_ARGS+=(
+ --enable_zucchini="${FLAGS_enable_zucchini}" )
+ fi
fi
if [[ -n "${FLAGS_enable_vabc_xor}" ]]; then