AU: when making a delta update, don't delta compress kernel partition.

This is an unfortunate and hopefully temporarly measure to address a
problem with the images people have in the field. People on dogfood
devices (with traditional BIOS) may have a USB-signed or a HD-signed
kernel partition. This was seen as okay since traditional BIOS doesn't
use the kernel partition. However, this is a problem for delta
updates, as when a delta from usb->usb kernel partitions is applied to
an hd-kernel partition, the resultant kernel partition is
invalid. While that may not seem like a problem (again, since
traditional BIOS doesn't use it to boot), the postinst script at the
end of update DOES look at the new kernel partition and bails if it's
malformed, thus causing the update to fail.

This CL causes delta images to send the kernel partition down in full
(bzip2 compressed), which solves the immediate problem. The rootfs is
still delta compressed.

Longer term, we need to find a way to know exactly what's installed on
the user's hard drive, including kernel partition, so that we can
create a delta from it.

BUG=chromium-os:6390
TEST=Tested update to a dogfood device with traditional BIOS.

Review URL: http://codereview.chromium.org/3325009
diff --git a/delta_diff_generator.cc b/delta_diff_generator.cc
index 10f6846..4433c1f 100644
--- a/delta_diff_generator.cc
+++ b/delta_diff_generator.cc
@@ -431,35 +431,34 @@
   // Add a new install operation
   ops->resize(1);
   DeltaArchiveManifest_InstallOperation* op = &(*ops)[0];
-  op->set_type(DeltaArchiveManifest_InstallOperation_Type_BSDIFF);
+  op->set_type(DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ);
   op->set_data_offset(*blobs_length);
 
   // Do the actual compression
   vector<char> data;
-  TEST_AND_RETURN_FALSE(BsdiffFiles(old_kernel_part, new_kernel_part, &data));
-  TEST_AND_RETURN_FALSE(utils::WriteAll(blobs_fd, &data[0], data.size()));
-  *blobs_length += data.size();
+  TEST_AND_RETURN_FALSE(utils::ReadFile(new_kernel_part, &data));
+  TEST_AND_RETURN_FALSE(!data.empty());
 
-  off_t old_part_size = utils::FileSize(old_kernel_part);
-  TEST_AND_RETURN_FALSE(old_part_size >= 0);
+  vector<char> data_bz;
+  TEST_AND_RETURN_FALSE(BzipCompress(data, &data_bz));
+  CHECK(!data_bz.empty());
+
+  TEST_AND_RETURN_FALSE(utils::WriteAll(blobs_fd, &data_bz[0], data_bz.size()));
+  *blobs_length += data_bz.size();
+
   off_t new_part_size = utils::FileSize(new_kernel_part);
   TEST_AND_RETURN_FALSE(new_part_size >= 0);
 
-  op->set_data_length(data.size());
+  op->set_data_length(data_bz.size());
 
-  op->set_src_length(old_part_size);
   op->set_dst_length(new_part_size);
 
-  // Theres a single src/dest extent for each
-  Extent* src_extent = op->add_src_extents();
-  src_extent->set_start_block(0);
-  src_extent->set_num_blocks((old_part_size + kBlockSize - 1) / kBlockSize);
-
+  // Theres a single dest extent
   Extent* dst_extent = op->add_dst_extents();
   dst_extent->set_start_block(0);
   dst_extent->set_num_blocks((new_part_size + kBlockSize - 1) / kBlockSize);
 
-  LOG(INFO) << "Done delta compressing kernel partition.";
+  LOG(INFO) << "Done compressing kernel partition.";
   return true;
 }