OLD | NEW |
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 <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 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 #include <gflags/gflags.h> | 13 #include <gflags/gflags.h> |
14 #include <glib.h> | 14 #include <glib.h> |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "chromeos/obsolete_logging.h" | 16 #include "chromeos/obsolete_logging.h" |
17 #include "update_engine/delta_diff_generator.h" | 17 #include "update_engine/delta_diff_generator.h" |
18 #include "update_engine/delta_performer.h" | 18 #include "update_engine/delta_performer.h" |
19 #include "update_engine/subprocess.h" | 19 #include "update_engine/subprocess.h" |
20 #include "update_engine/update_metadata.pb.h" | 20 #include "update_engine/update_metadata.pb.h" |
21 #include "update_engine/utils.h" | 21 #include "update_engine/utils.h" |
22 | 22 |
23 DEFINE_string(old_dir, "", | 23 DEFINE_string(old_dir, "", |
24 "Directory where the old rootfs is loop mounted read-only"); | 24 "Directory where the old rootfs is loop mounted read-only"); |
25 DEFINE_string(new_dir, "", | 25 DEFINE_string(new_dir, "", |
26 "Directory where the new rootfs is loop mounted read-only"); | 26 "Directory where the new rootfs is loop mounted read-only"); |
27 DEFINE_string(old_image, "", "Path to the old rootfs"); | 27 DEFINE_string(old_image, "", "Path to the old rootfs"); |
28 DEFINE_string(new_image, "", "Path to the new rootfs"); | 28 DEFINE_string(new_image, "", "Path to the new rootfs"); |
29 DEFINE_string(out_file, "", "Path to output file"); | 29 DEFINE_string(out_file, "", "Path to output file"); |
| 30 DEFINE_string(old_kernel, "", "Path to the old kernel partition image"); |
| 31 DEFINE_string(new_kernel, "", "Path to the new kernel partition image"); |
30 DEFINE_string(apply_delta, "", | 32 DEFINE_string(apply_delta, "", |
31 "If set, apply delta over old_image. (For debugging.)"); | 33 "If set, apply delta over old_image. (For debugging.)"); |
32 | 34 |
33 // This file contains a simple program that takes an old path, a new path, | 35 // This file contains a simple program that takes an old path, a new path, |
34 // and an output file as arguments and the path to an output file and | 36 // and an output file as arguments and the path to an output file and |
35 // generates a delta that can be sent to Chrome OS clients. | 37 // generates a delta that can be sent to Chrome OS clients. |
36 | 38 |
37 using std::set; | 39 using std::set; |
38 using std::string; | 40 using std::string; |
39 using std::vector; | 41 using std::vector; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ssize_t bytes_read; | 73 ssize_t bytes_read; |
72 CHECK(utils::PReadAll(fd, &buf[0], buf.size(), offset, &bytes_read)); | 74 CHECK(utils::PReadAll(fd, &buf[0], buf.size(), offset, &bytes_read)); |
73 if (bytes_read == 0) | 75 if (bytes_read == 0) |
74 break; | 76 break; |
75 CHECK_EQ(performer.Write(&buf[0], bytes_read), bytes_read); | 77 CHECK_EQ(performer.Write(&buf[0], bytes_read), bytes_read); |
76 } | 78 } |
77 CHECK_EQ(performer.Close(), 0); | 79 CHECK_EQ(performer.Close(), 0); |
78 LOG(INFO) << "done applying delta."; | 80 LOG(INFO) << "done applying delta."; |
79 return 0; | 81 return 0; |
80 } | 82 } |
81 if (FLAGS_old_dir.empty() || FLAGS_new_dir.empty() || | 83 CHECK(!FLAGS_old_dir.empty()); |
82 FLAGS_old_image.empty() || FLAGS_new_image.empty() || | 84 CHECK(!FLAGS_new_dir.empty()); |
83 FLAGS_out_file.empty()) { | 85 CHECK(!FLAGS_old_image.empty()); |
84 LOG(FATAL) << "Missing required argument(s)"; | 86 CHECK(!FLAGS_new_image.empty()); |
85 } | 87 CHECK(!FLAGS_out_file.empty()); |
| 88 CHECK(!FLAGS_old_kernel.empty()); |
| 89 CHECK(!FLAGS_new_kernel.empty()); |
86 if ((!IsDir(FLAGS_old_dir.c_str())) || (!IsDir(FLAGS_new_dir.c_str()))) { | 90 if ((!IsDir(FLAGS_old_dir.c_str())) || (!IsDir(FLAGS_new_dir.c_str()))) { |
87 LOG(FATAL) << "old_dir or new_dir not directory"; | 91 LOG(FATAL) << "old_dir or new_dir not directory"; |
88 } | 92 } |
89 | 93 |
90 DeltaDiffGenerator::GenerateDeltaUpdateFile(FLAGS_old_dir, | 94 DeltaDiffGenerator::GenerateDeltaUpdateFile(FLAGS_old_dir, |
91 FLAGS_old_image, | 95 FLAGS_old_image, |
92 FLAGS_new_dir, | 96 FLAGS_new_dir, |
93 FLAGS_new_image, | 97 FLAGS_new_image, |
| 98 FLAGS_old_kernel, |
| 99 FLAGS_new_kernel, |
94 FLAGS_out_file); | 100 FLAGS_out_file); |
95 | 101 |
96 return 0; | 102 return 0; |
97 } | 103 } |
98 | 104 |
99 } // namespace {} | 105 } // namespace {} |
100 | 106 |
101 } // namespace chromeos_update_engine | 107 } // namespace chromeos_update_engine |
102 | 108 |
103 int main(int argc, char** argv) { | 109 int main(int argc, char** argv) { |
104 return chromeos_update_engine::Main(argc, argv); | 110 return chromeos_update_engine::Main(argc, argv); |
105 } | 111 } |
OLD | NEW |