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

Side by Side Diff: src/platform/update_engine/generate_delta_main.cc

Issue 891002: AU: Delta Diff Generator (Closed)
Patch Set: fixes for review Created 10 years, 8 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
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 <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 <unistd.h> 8 #include <unistd.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <gflags/gflags.h>
11 #include <glib.h> 12 #include <glib.h>
13 #include "base/command_line.h"
12 #include "chromeos/obsolete_logging.h" 14 #include "chromeos/obsolete_logging.h"
13 #include "update_engine/delta_diff_generator.h" 15 #include "update_engine/delta_diff_generator.h"
14 #include "update_engine/subprocess.h" 16 #include "update_engine/subprocess.h"
15 #include "update_engine/update_metadata.pb.h" 17 #include "update_engine/update_metadata.pb.h"
16 #include "update_engine/utils.h" 18 #include "update_engine/utils.h"
17 19
20 DEFINE_string(old_dir, "",
21 "Directory where the old rootfs is loop mounted read-only");
22 DEFINE_string(new_dir, "",
23 "Directory where the new rootfs is loop mounted read-only");
24 DEFINE_string(old_image, "", "Path to the old rootfs");
25 DEFINE_string(new_image, "", "Path to the new rootfs");
26 DEFINE_string(out_file, "", "Path to output file");
27
18 // This file contains a simple program that takes an old path, a new path, 28 // This file contains a simple program that takes an old path, a new path,
19 // and an output file as arguments and the path to an output file and 29 // and an output file as arguments and the path to an output file and
20 // generates a delta that can be sent to Chrome OS clients. 30 // generates a delta that can be sent to Chrome OS clients.
21 31
22 using std::set; 32 using std::set;
23 using std::string; 33 using std::string;
24 34
25 namespace chromeos_update_engine { 35 namespace chromeos_update_engine {
26 36
27 namespace { 37 namespace {
28 38
29 void usage(const char* argv0) {
30 printf("usage: %s old_dir new_dir out_file\n", argv0);
31 exit(1);
32 }
33
34 bool IsDir(const char* path) { 39 bool IsDir(const char* path) {
35 struct stat stbuf; 40 struct stat stbuf;
36 TEST_AND_RETURN_FALSE_ERRNO(lstat(path, &stbuf) == 0); 41 TEST_AND_RETURN_FALSE_ERRNO(lstat(path, &stbuf) == 0);
37 return S_ISDIR(stbuf.st_mode); 42 return S_ISDIR(stbuf.st_mode);
38 } 43 }
39 44
40 int Main(int argc, char** argv) { 45 int Main(int argc, char** argv) {
41 g_thread_init(NULL); 46 g_thread_init(NULL);
47 google::ParseCommandLineFlags(&argc, &argv, true);
48 CommandLine::Init(argc, argv);
42 Subprocess::Init(); 49 Subprocess::Init();
43 if (argc != 4) { 50 logging::InitLogging("delta_generator.log",
44 usage(argv[0]);
45 }
46 logging::InitLogging("",
47 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 51 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
48 logging::DONT_LOCK_LOG_FILE, 52 logging::DONT_LOCK_LOG_FILE,
49 logging::APPEND_TO_OLD_LOG_FILE); 53 logging::APPEND_TO_OLD_LOG_FILE);
50 const char* old_dir = argv[1]; 54 if (FLAGS_old_dir.empty() || FLAGS_new_dir.empty() ||
51 const char* new_dir = argv[2]; 55 FLAGS_old_image.empty() || FLAGS_new_image.empty() ||
52 if ((!IsDir(old_dir)) || (!IsDir(new_dir))) { 56 FLAGS_out_file.empty()) {
53 usage(argv[0]); 57 LOG(FATAL) << "Missing required argument(s)";
58 }
59 if ((!IsDir(FLAGS_old_dir.c_str())) || (!IsDir(FLAGS_new_dir.c_str()))) {
60 LOG(FATAL) << "old_dir or new_dir not directory";
54 } 61 }
55 62
56 // TODO(adlr): generate delta file 63 DeltaDiffGenerator::GenerateDeltaUpdateFile(FLAGS_old_dir,
64 FLAGS_old_image,
65 FLAGS_new_dir,
66 FLAGS_new_image,
67 FLAGS_out_file);
57 68
58 return 0; 69 return 0;
59 } 70 }
60 71
61 } // namespace {} 72 } // namespace {}
62 73
63 } // namespace chromeos_update_engine 74 } // namespace chromeos_update_engine
64 75
65 int main(int argc, char** argv) { 76 int main(int argc, char** argv) {
66 return chromeos_update_engine::Main(argc, argv); 77 return chromeos_update_engine::Main(argc, argv);
67 } 78 }
OLDNEW
« no previous file with comments | « src/platform/update_engine/filesystem_iterator_unittest.cc ('k') | src/platform/update_engine/graph_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698