Remove IMGDIFF operation application support.
Remove support for applying IMGDIFF operations as this will be replaced
with PUFFIN.
Bug: None
Test: Unittests still build.
Change-Id: Idd8151a4fc772c70359afdd2da8d4a2f05bbd293
diff --git a/Android.mk b/Android.mk
index cc68d8c..cff7081 100644
--- a/Android.mk
+++ b/Android.mk
@@ -100,11 +100,7 @@
update_metadata-protos \
libxz \
libbz \
- libimgpatch \
libbspatch \
- libbase \
- liblog \
- libz \
$(ue_update_metadata_protos_exported_static_libraries)
ue_libpayload_consumer_exported_shared_libraries := \
libcrypto \
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index ab0a99e..e442441 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -26,7 +26,6 @@
#include <string>
#include <vector>
-#include <applypatch/imgpatch.h>
#include <base/files/file_util.h>
#include <base/format_macros.h>
#include <base/strings/string_number_conversions.h>
@@ -733,10 +732,11 @@
op_result = PerformSourceBsdiffOperation(op, error);
break;
case InstallOperation::IMGDIFF:
- op_result = PerformImgdiffOperation(op, error);
+ // TODO(deymo): Replace with PUFFIN operation.
+ op_result = false;
break;
default:
- op_result = false;
+ op_result = false;
}
if (!HandleOpResult(op_result, InstallOperationTypeName(op.type()), error))
return false;
@@ -1263,53 +1263,6 @@
return true;
}
-bool DeltaPerformer::PerformImgdiffOperation(const InstallOperation& operation,
- ErrorCode* error) {
- // Since we delete data off the beginning of the buffer as we use it,
- // the data we need should be exactly at the beginning of the buffer.
- TEST_AND_RETURN_FALSE(buffer_offset_ == operation.data_offset());
- TEST_AND_RETURN_FALSE(buffer_.size() >= operation.data_length());
-
- uint64_t src_blocks = GetBlockCount(operation.src_extents());
- brillo::Blob src_data(src_blocks * block_size_);
-
- ssize_t bytes_read = 0;
- for (const Extent& extent : operation.src_extents()) {
- ssize_t bytes_read_this_iteration = 0;
- ssize_t bytes_to_read = extent.num_blocks() * block_size_;
- TEST_AND_RETURN_FALSE(utils::PReadAll(source_fd_,
- &src_data[bytes_read],
- bytes_to_read,
- extent.start_block() * block_size_,
- &bytes_read_this_iteration));
- TEST_AND_RETURN_FALSE(bytes_read_this_iteration == bytes_to_read);
- bytes_read += bytes_read_this_iteration;
- }
-
- if (operation.has_src_sha256_hash()) {
- brillo::Blob src_hash;
- TEST_AND_RETURN_FALSE(HashCalculator::RawHashOfData(src_data, &src_hash));
- TEST_AND_RETURN_FALSE(ValidateSourceHash(src_hash, operation, error));
- }
-
- vector<Extent> target_extents(operation.dst_extents().begin(),
- operation.dst_extents().end());
- DirectExtentWriter writer;
- TEST_AND_RETURN_FALSE(writer.Init(target_fd_, target_extents, block_size_));
- TEST_AND_RETURN_FALSE(
- ApplyImagePatch(src_data.data(),
- src_data.size(),
- buffer_.data(),
- operation.data_length(),
- [&writer](const unsigned char* data, size_t len) {
- return writer.Write(data, len) ? len : 0;
- }) == 0);
- TEST_AND_RETURN_FALSE(writer.End());
-
- DiscardBuffer(true, buffer_.size());
- return true;
-}
-
bool DeltaPerformer::ExtractSignatureMessageFromOperation(
const InstallOperation& operation) {
if (operation.type() != InstallOperation::REPLACE ||
diff --git a/payload_consumer/delta_performer.h b/payload_consumer/delta_performer.h
index 74143e0..71d7178 100644
--- a/payload_consumer/delta_performer.h
+++ b/payload_consumer/delta_performer.h
@@ -254,8 +254,6 @@
ErrorCode* error);
bool PerformSourceBsdiffOperation(const InstallOperation& operation,
ErrorCode* error);
- bool PerformImgdiffOperation(const InstallOperation& operation,
- ErrorCode* error);
// Extracts the payload signature message from the blob on the |operation| if
// the offset matches the one specified by the manifest. Returns whether the
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index 53e4ed0..18481a7 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -87,60 +87,6 @@
0x00, 0x00, 0x59, 0x5a,
};
-// Gzipped 'abc', generated with:
-// echo -n abc | minigzip | hexdump -v -e '" " 12/1 "0x%02x, " "\n"'
-const uint8_t kSourceGzippedData[] = {
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4b, 0x4c,
- 0x4a, 0x06, 0x00, 0xc2, 0x41, 0x24, 0x35, 0x03, 0x00, 0x00, 0x00,
-};
-
-// Gzipped 'def', generated with:
-// echo -n def | minigzip | hexdump -v -e '" " 12/1 "0x%02x, " "\n"'
-const uint8_t kTargetGzippedData[] = {
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4b, 0x49,
- 0x4d, 0x03, 0x00, 0x61, 0xe1, 0xc4, 0x0c, 0x03, 0x00, 0x00, 0x00,
-};
-
-// Imgdiff data, generated with:
-// echo -n abc | minigzip > abc && truncate -s 4096 abc
-// echo -n def | minigzip > def && truncate -s 4096 def
-// imgdiff abc def patch && hexdump -v -e '" " 12/1 "0x%02x, " "\n"' patch
-const uint8_t kImgdiffData[] = {
- 0x49, 0x4d, 0x47, 0x44, 0x49, 0x46, 0x46, 0x32, 0x03, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf1, 0xff,
- 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x0f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34, 0x30, 0x2a, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x5a,
- 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xc3, 0xc8, 0xfb, 0x1f,
- 0x00, 0x00, 0x01, 0x40, 0x00, 0x5c, 0x00, 0x20, 0x00, 0x30, 0xcd, 0x34,
- 0x12, 0x34, 0x54, 0x60, 0x5c, 0xce, 0x2e, 0xe4, 0x8a, 0x70, 0xa1, 0x21,
- 0x87, 0x91, 0xf6, 0x3e, 0x42, 0x5a, 0x68, 0x39, 0x17, 0x72, 0x45, 0x38,
- 0x50, 0x90, 0x00, 0x00, 0x00, 0x00, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41,
- 0x59, 0x26, 0x53, 0x59, 0x42, 0x3c, 0xb0, 0xf9, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x07, 0x00, 0x20, 0x00, 0x21, 0x98, 0x19, 0x84, 0x61, 0x77, 0x24,
- 0x53, 0x85, 0x09, 0x04, 0x23, 0xcb, 0x0f, 0x90, 0x42, 0x53, 0x44, 0x49,
- 0x46, 0x46, 0x34, 0x30, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x0f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26,
- 0x53, 0x59, 0x6f, 0x02, 0x77, 0xf3, 0x00, 0x00, 0x07, 0x40, 0x41, 0xe0,
- 0x10, 0xc0, 0x00, 0x00, 0x02, 0x20, 0x00, 0x20, 0x00, 0x21, 0x29, 0xa3,
- 0x10, 0x86, 0x03, 0x84, 0x04, 0xae, 0x5f, 0x17, 0x72, 0x45, 0x38, 0x50,
- 0x90, 0x6f, 0x02, 0x77, 0xf3, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59,
- 0x26, 0x53, 0x59, 0x71, 0x62, 0xbd, 0xa7, 0x00, 0x00, 0x20, 0x40, 0x32,
- 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x80, 0x00, 0x48, 0x20, 0x00,
- 0x30, 0xc0, 0x02, 0xa5, 0x19, 0xa5, 0x92, 0x6f, 0xc2, 0x5d, 0xac, 0x0e,
- 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x71, 0x62, 0xbd, 0xa7, 0x42, 0x5a,
- 0x68, 0x39, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x00, 0x00, 0x00, 0x00,
-};
-
} // namespace
class DeltaPerformerTest : public ::testing::Test {
@@ -534,33 +480,6 @@
EXPECT_EQ(expected_data, ApplyPayload(payload_data, source_path, true));
}
-TEST_F(DeltaPerformerTest, ImgdiffOperationTest) {
- brillo::Blob imgdiff_data(std::begin(kImgdiffData), std::end(kImgdiffData));
-
- AnnotatedOperation aop;
- *(aop.op.add_src_extents()) = ExtentForRange(0, 1);
- *(aop.op.add_dst_extents()) = ExtentForRange(0, 1);
- aop.op.set_data_offset(0);
- aop.op.set_data_length(imgdiff_data.size());
- aop.op.set_type(InstallOperation::IMGDIFF);
-
- brillo::Blob payload_data = GeneratePayload(imgdiff_data, {aop}, false);
-
- string source_path;
- EXPECT_TRUE(utils::MakeTempFile("Source-XXXXXX", &source_path, nullptr));
- ScopedPathUnlinker path_unlinker(source_path);
- brillo::Blob source_data(std::begin(kSourceGzippedData),
- std::end(kSourceGzippedData));
- source_data.resize(4096); // block size
- EXPECT_TRUE(utils::WriteFile(
- source_path.c_str(), source_data.data(), source_data.size()));
-
- brillo::Blob target_data(std::begin(kTargetGzippedData),
- std::end(kTargetGzippedData));
- target_data.resize(4096); // block size
- EXPECT_EQ(target_data, ApplyPayload(payload_data, source_path, true));
-}
-
TEST_F(DeltaPerformerTest, SourceHashMismatchTest) {
brillo::Blob expected_data = {'f', 'o', 'o'};
brillo::Blob actual_data = {'b', 'a', 'r'};
diff --git a/update_engine.gyp b/update_engine.gyp
index 9f63f01..c80c988 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -131,7 +131,6 @@
'variables': {
'exported_deps': [
'libcrypto',
- 'libimgpatch',
'xz-embedded',
],
'deps': ['<@(exported_deps)'],