Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Side by Side Diff: delta_diff_generator.cc

Issue 3325009: AU: when making a delta update, don't delta compress kernel partition. (Closed) Base URL: ssh://git@chromiumos-git/update_engine.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/delta_diff_generator.h" 5 #include "update_engine/delta_diff_generator.h"
6 #include <sys/stat.h> 6 #include <sys/stat.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 off_t* blobs_length) { 424 off_t* blobs_length) {
425 // For now, just bsdiff the kernel partition as a whole. 425 // For now, just bsdiff the kernel partition as a whole.
426 // TODO(adlr): Use knowledge of how the kernel partition is laid out 426 // TODO(adlr): Use knowledge of how the kernel partition is laid out
427 // to more efficiently compress it. 427 // to more efficiently compress it.
428 428
429 LOG(INFO) << "Delta compressing kernel partition..."; 429 LOG(INFO) << "Delta compressing kernel partition...";
430 430
431 // Add a new install operation 431 // Add a new install operation
432 ops->resize(1); 432 ops->resize(1);
433 DeltaArchiveManifest_InstallOperation* op = &(*ops)[0]; 433 DeltaArchiveManifest_InstallOperation* op = &(*ops)[0];
434 op->set_type(DeltaArchiveManifest_InstallOperation_Type_BSDIFF); 434 op->set_type(DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ);
435 op->set_data_offset(*blobs_length); 435 op->set_data_offset(*blobs_length);
436 436
437 // Do the actual compression 437 // Do the actual compression
438 vector<char> data; 438 vector<char> data;
439 TEST_AND_RETURN_FALSE(BsdiffFiles(old_kernel_part, new_kernel_part, &data)); 439 TEST_AND_RETURN_FALSE(utils::ReadFile(new_kernel_part, &data));
440 TEST_AND_RETURN_FALSE(utils::WriteAll(blobs_fd, &data[0], data.size())); 440 TEST_AND_RETURN_FALSE(!data.empty());
441 *blobs_length += data.size();
442 441
443 off_t old_part_size = utils::FileSize(old_kernel_part); 442 vector<char> data_bz;
444 TEST_AND_RETURN_FALSE(old_part_size >= 0); 443 TEST_AND_RETURN_FALSE(BzipCompress(data, &data_bz));
444 CHECK(!data_bz.empty());
445
446 TEST_AND_RETURN_FALSE(utils::WriteAll(blobs_fd, &data_bz[0], data_bz.size()));
447 *blobs_length += data_bz.size();
448
445 off_t new_part_size = utils::FileSize(new_kernel_part); 449 off_t new_part_size = utils::FileSize(new_kernel_part);
446 TEST_AND_RETURN_FALSE(new_part_size >= 0); 450 TEST_AND_RETURN_FALSE(new_part_size >= 0);
447 451
448 op->set_data_length(data.size()); 452 op->set_data_length(data_bz.size());
449 453
450 op->set_src_length(old_part_size);
451 op->set_dst_length(new_part_size); 454 op->set_dst_length(new_part_size);
452 455
453 // Theres a single src/dest extent for each 456 // Theres a single dest extent
Daniel Erat 2010/09/03 05:43:22 nit: s/Theres/There's/
454 Extent* src_extent = op->add_src_extents();
455 src_extent->set_start_block(0);
456 src_extent->set_num_blocks((old_part_size + kBlockSize - 1) / kBlockSize);
457
458 Extent* dst_extent = op->add_dst_extents(); 457 Extent* dst_extent = op->add_dst_extents();
459 dst_extent->set_start_block(0); 458 dst_extent->set_start_block(0);
460 dst_extent->set_num_blocks((new_part_size + kBlockSize - 1) / kBlockSize); 459 dst_extent->set_num_blocks((new_part_size + kBlockSize - 1) / kBlockSize);
461 460
462 LOG(INFO) << "Done delta compressing kernel partition."; 461 LOG(INFO) << "Done compressing kernel partition.";
463 return true; 462 return true;
464 } 463 }
465 464
466 } // namespace {} 465 } // namespace {}
467 466
468 bool DeltaDiffGenerator::ReadFileToDiff( 467 bool DeltaDiffGenerator::ReadFileToDiff(
469 const string& old_filename, 468 const string& old_filename,
470 const string& new_filename, 469 const string& new_filename,
471 vector<char>* out_data, 470 vector<char>* out_data,
472 DeltaArchiveManifest_InstallOperation* out_op) { 471 DeltaArchiveManifest_InstallOperation* out_op) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 980
982 LOG(INFO) << "All done. Successfully created delta file."; 981 LOG(INFO) << "All done. Successfully created delta file.";
983 return true; 982 return true;
984 } 983 }
985 984
986 const char* const kBsdiffPath = "/usr/bin/bsdiff"; 985 const char* const kBsdiffPath = "/usr/bin/bsdiff";
987 const char* const kBspatchPath = "/usr/bin/bspatch"; 986 const char* const kBspatchPath = "/usr/bin/bspatch";
988 const char* const kDeltaMagic = "CrAU"; 987 const char* const kDeltaMagic = "CrAU";
989 988
990 }; // namespace chromeos_update_engine 989 }; // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698