| Index: src/platform/update_engine/generate_delta_main.cc
|
| diff --git a/src/platform/update_engine/generate_delta_main.cc b/src/platform/update_engine/generate_delta_main.cc
|
| index 551c6ef07b644ba9f77c415ec1a2f071ffabbb1a..2f21b2a561a756bd37496290b7ce480997ae49c6 100644
|
| --- a/src/platform/update_engine/generate_delta_main.cc
|
| +++ b/src/platform/update_engine/generate_delta_main.cc
|
| @@ -8,13 +8,23 @@
|
| #include <unistd.h>
|
| #include <set>
|
| #include <string>
|
| +#include <gflags/gflags.h>
|
| #include <glib.h>
|
| +#include "base/command_line.h"
|
| #include "chromeos/obsolete_logging.h"
|
| #include "update_engine/delta_diff_generator.h"
|
| #include "update_engine/subprocess.h"
|
| #include "update_engine/update_metadata.pb.h"
|
| #include "update_engine/utils.h"
|
|
|
| +DEFINE_string(old_dir, "",
|
| + "Directory where the old rootfs is loop mounted read-only");
|
| +DEFINE_string(new_dir, "",
|
| + "Directory where the new rootfs is loop mounted read-only");
|
| +DEFINE_string(old_image, "", "Path to the old rootfs");
|
| +DEFINE_string(new_image, "", "Path to the new rootfs");
|
| +DEFINE_string(out_file, "", "Path to output file");
|
| +
|
| // This file contains a simple program that takes an old path, a new path,
|
| // and an output file as arguments and the path to an output file and
|
| // generates a delta that can be sent to Chrome OS clients.
|
| @@ -26,11 +36,6 @@ namespace chromeos_update_engine {
|
|
|
| namespace {
|
|
|
| -void usage(const char* argv0) {
|
| - printf("usage: %s old_dir new_dir out_file\n", argv0);
|
| - exit(1);
|
| -}
|
| -
|
| bool IsDir(const char* path) {
|
| struct stat stbuf;
|
| TEST_AND_RETURN_FALSE_ERRNO(lstat(path, &stbuf) == 0);
|
| @@ -39,21 +44,27 @@ bool IsDir(const char* path) {
|
|
|
| int Main(int argc, char** argv) {
|
| g_thread_init(NULL);
|
| + google::ParseCommandLineFlags(&argc, &argv, true);
|
| + CommandLine::Init(argc, argv);
|
| Subprocess::Init();
|
| - if (argc != 4) {
|
| - usage(argv[0]);
|
| - }
|
| - logging::InitLogging("",
|
| + logging::InitLogging("delta_generator.log",
|
| logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
|
| logging::DONT_LOCK_LOG_FILE,
|
| logging::APPEND_TO_OLD_LOG_FILE);
|
| - const char* old_dir = argv[1];
|
| - const char* new_dir = argv[2];
|
| - if ((!IsDir(old_dir)) || (!IsDir(new_dir))) {
|
| - usage(argv[0]);
|
| + if (FLAGS_old_dir.empty() || FLAGS_new_dir.empty() ||
|
| + FLAGS_old_image.empty() || FLAGS_new_image.empty() ||
|
| + FLAGS_out_file.empty()) {
|
| + LOG(FATAL) << "Missing required argument(s)";
|
| + }
|
| + if ((!IsDir(FLAGS_old_dir.c_str())) || (!IsDir(FLAGS_new_dir.c_str()))) {
|
| + LOG(FATAL) << "old_dir or new_dir not directory";
|
| }
|
|
|
| - // TODO(adlr): generate delta file
|
| + DeltaDiffGenerator::GenerateDeltaUpdateFile(FLAGS_old_dir,
|
| + FLAGS_old_image,
|
| + FLAGS_new_dir,
|
| + FLAGS_new_image,
|
| + FLAGS_out_file);
|
|
|
| return 0;
|
| }
|
|
|