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

Side by Side Diff: generate_delta_main.cc

Issue 4042004: AU: When applying delta locally, get source checksums (Closed) Base URL: http://git.chromium.org/git/update_engine.git
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <sys/types.h> 5 #include <sys/types.h>
6 #include <sys/stat.h> 6 #include <sys/stat.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 logging::DONT_LOCK_LOG_FILE, 69 logging::DONT_LOCK_LOG_FILE,
70 logging::APPEND_TO_OLD_LOG_FILE); 70 logging::APPEND_TO_OLD_LOG_FILE);
71 if (!FLAGS_apply_delta.empty()) { 71 if (!FLAGS_apply_delta.empty()) {
72 if (FLAGS_old_image.empty()) { 72 if (FLAGS_old_image.empty()) {
73 LOG(FATAL) << "Must pass --old_image with --apply_delta."; 73 LOG(FATAL) << "Must pass --old_image with --apply_delta.";
74 } 74 }
75 Prefs prefs; 75 Prefs prefs;
76 LOG(INFO) << "Setting up preferences under: " << FLAGS_prefs_dir; 76 LOG(INFO) << "Setting up preferences under: " << FLAGS_prefs_dir;
77 LOG_IF(ERROR, !prefs.Init(FilePath(FLAGS_prefs_dir))) 77 LOG_IF(ERROR, !prefs.Init(FilePath(FLAGS_prefs_dir)))
78 << "Failed to initialize preferences."; 78 << "Failed to initialize preferences.";
79 // Get original checksums
80 LOG(INFO) << "Calculating original checksums";
81 PartitionInfo kern_info, root_info;
82 CHECK(InitializePartitionInfo(true, // is_kernel
83 FLAGS_old_kernel,
84 &kern_info));
85 CHECK(InitializePartitionInfo(false, // is_kernel
86 FLAGS_old_image,
87 &root_info));
88 vector<char> kern_hash(kern_info.hash().begin(),
89 kern_info.hash().end());
90 vector<char> root_hash(root_info.hash().begin(),
91 root_info.hash().end());
petkov 2010/10/22 20:15:16 indent is off.
adlr 2010/10/22 20:40:18 Done.
79 DeltaPerformer performer(&prefs); 92 DeltaPerformer performer(&prefs);
93 performer.set_current_kernel_hash(&kern_hash);
94 performer.set_current_rootfs_hash(&root_hash);
80 CHECK_EQ(performer.Open(FLAGS_old_image.c_str(), 0, 0), 0); 95 CHECK_EQ(performer.Open(FLAGS_old_image.c_str(), 0, 0), 0);
81 CHECK(performer.OpenKernel(FLAGS_old_kernel.c_str())); 96 CHECK(performer.OpenKernel(FLAGS_old_kernel.c_str()));
82 vector<char> buf(1024 * 1024); 97 vector<char> buf(1024 * 1024);
83 int fd = open(FLAGS_apply_delta.c_str(), O_RDONLY, 0); 98 int fd = open(FLAGS_apply_delta.c_str(), O_RDONLY, 0);
84 CHECK_GE(fd, 0); 99 CHECK_GE(fd, 0);
85 ScopedFdCloser fd_closer(&fd); 100 ScopedFdCloser fd_closer(&fd);
86 for (off_t offset = 0;; offset += buf.size()) { 101 for (off_t offset = 0;; offset += buf.size()) {
87 ssize_t bytes_read; 102 ssize_t bytes_read;
88 CHECK(utils::PReadAll(fd, &buf[0], buf.size(), offset, &bytes_read)); 103 CHECK(utils::PReadAll(fd, &buf[0], buf.size(), offset, &bytes_read));
89 if (bytes_read == 0) 104 if (bytes_read == 0)
(...skipping 30 matching lines...) Expand all
120 return 0; 135 return 0;
121 } 136 }
122 137
123 } // namespace {} 138 } // namespace {}
124 139
125 } // namespace chromeos_update_engine 140 } // namespace chromeos_update_engine
126 141
127 int main(int argc, char** argv) { 142 int main(int argc, char** argv) {
128 return chromeos_update_engine::Main(argc, argv); 143 return chromeos_update_engine::Main(argc, argv);
129 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698