aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2018-03-03 05:25:00 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-03-03 05:25:00 +0000
commit8679c142bbbc58c1ac20c1fbef14641fc3cdc049 (patch)
treedf47b54adb613dca7d68dda33472bfd7692ba709
parent2ca39d03a91d468cf700a7774a3d500025a7aaa3 (diff)
parentde1685fd76c0742df848985bf448388583e1299e (diff)
downloadupdate_engine-8679c142bbbc58c1ac20c1fbef14641fc3cdc049.tar.gz
Enable brotli_bsdiff in update package generation
am: de1685fd76 Change-Id: I0e0267048097499a385cfecc22581e35f81e1eb0
-rw-r--r--payload_generator/delta_diff_utils.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index bcbc3a54..877e13fd 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -40,6 +40,7 @@
#include <base/threading/simple_thread.h>
#include <brillo/data_encoding.h>
#include <bsdiff/bsdiff.h>
+#include <bsdiff/patch_writer_factory.h>
#include "update_engine/common/hash_calculator.h"
#include "update_engine/common/subprocess.h"
@@ -73,6 +74,8 @@ const uint64_t kMaxBsdiffDestinationSize = 200 * 1024 * 1024; // bytes
// memory intensive, so we limit these operations to 150 MiB.
const uint64_t kMaxPuffdiffDestinationSize = 150 * 1024 * 1024; // bytes
+const int kBrotliCompressionQuality = 11;
+
// Process a range of blocks from |range_start| to |range_end| in the extent at
// position |*idx_p| of |extents|. If |do_remove| is true, this range will be
// removed, which may cause the extent to be trimmed, split or removed entirely.
@@ -740,21 +743,33 @@ bool ReadExtentsToDiff(const string& old_part,
TEST_AND_RETURN_FALSE(base::CreateTemporaryFile(&patch));
ScopedPathUnlinker unlinker(patch.value());
+ std::unique_ptr<bsdiff::PatchWriterInterface> bsdiff_patch_writer;
+ InstallOperation_Type operation_type = InstallOperation::BSDIFF;
+ if (version.OperationAllowed(InstallOperation::BROTLI_BSDIFF)) {
+ bsdiff_patch_writer =
+ bsdiff::CreateBSDF2PatchWriter(patch.value(),
+ bsdiff::CompressorType::kBrotli,
+ kBrotliCompressionQuality);
+ operation_type = InstallOperation::BROTLI_BSDIFF;
+ } else {
+ bsdiff_patch_writer = bsdiff::CreateBsdiffPatchWriter(patch.value());
+ if (version.OperationAllowed(InstallOperation::SOURCE_BSDIFF)) {
+ operation_type = InstallOperation::SOURCE_BSDIFF;
+ }
+ }
+
brillo::Blob bsdiff_delta;
TEST_AND_RETURN_FALSE(0 == bsdiff::bsdiff(old_data.data(),
old_data.size(),
new_data.data(),
new_data.size(),
- patch.value().c_str(),
+ bsdiff_patch_writer.get(),
nullptr));
TEST_AND_RETURN_FALSE(utils::ReadFile(patch.value(), &bsdiff_delta));
CHECK_GT(bsdiff_delta.size(), static_cast<brillo::Blob::size_type>(0));
if (bsdiff_delta.size() < data_blob.size()) {
- operation.set_type(
- version.OperationAllowed(InstallOperation::SOURCE_BSDIFF)
- ? InstallOperation::SOURCE_BSDIFF
- : InstallOperation::BSDIFF);
+ operation.set_type(operation_type);
data_blob = std::move(bsdiff_delta);
}
}