adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <sys/types.h> |
| 6 | #include <sys/stat.h> |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 7 | #include <errno.h> |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 8 | #include <unistd.h> |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 9 | #include <set> |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 10 | #include <string> |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 11 | #include <glib.h> |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 12 | #include "chromeos/obsolete_logging.h" |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 13 | #include "update_engine/delta_diff_generator.h" |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 14 | #include "update_engine/subprocess.h" |
| 15 | #include "update_engine/update_metadata.pb.h" |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 16 | #include "update_engine/utils.h" |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 17 | |
| 18 | // 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 |
| 20 | // generates a delta that can be sent to Chrome OS clients. |
| 21 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 22 | using std::set; |
| 23 | using std::string; |
| 24 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 25 | namespace chromeos_update_engine { |
| 26 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 27 | namespace { |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 28 | |
| 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) { |
| 35 | struct stat stbuf; |
| 36 | TEST_AND_RETURN_FALSE_ERRNO(lstat(path, &stbuf) == 0); |
| 37 | return S_ISDIR(stbuf.st_mode); |
| 38 | } |
| 39 | |
| 40 | int Main(int argc, char** argv) { |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 41 | g_thread_init(NULL); |
| 42 | Subprocess::Init(); |
| 43 | if (argc != 4) { |
| 44 | usage(argv[0]); |
| 45 | } |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 46 | logging::InitLogging("", |
| 47 | logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
| 48 | logging::DONT_LOCK_LOG_FILE, |
| 49 | logging::APPEND_TO_OLD_LOG_FILE); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 50 | const char* old_dir = argv[1]; |
| 51 | const char* new_dir = argv[2]; |
| 52 | if ((!IsDir(old_dir)) || (!IsDir(new_dir))) { |
| 53 | usage(argv[0]); |
| 54 | } |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 55 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame^] | 56 | // TODO(adlr): generate delta file |
| 57 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 58 | return 0; |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | } // namespace {} |
| 62 | |
| 63 | } // namespace chromeos_update_engine |
| 64 | |
| 65 | int main(int argc, char** argv) { |
| 66 | return chromeos_update_engine::Main(argc, argv); |
| 67 | } |