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

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

Issue 545072: AU: Gut code for old updater. New protobuf for v2 updater. (Closed)
Patch Set: better comments Created 10 years, 11 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 <glib.h> 11 #include <glib.h>
12 #include "chromeos/obsolete_logging.h" 12 #include "chromeos/obsolete_logging.h"
13 #include "update_engine/delta_diff_generator.h" 13 #include "update_engine/delta_diff_generator.h"
14 #include "update_engine/subprocess.h" 14 #include "update_engine/subprocess.h"
15 #include "update_engine/update_metadata.pb.h" 15 #include "update_engine/update_metadata.pb.h"
16 #include "update_engine/utils.h" 16 #include "update_engine/utils.h"
17 17
18 // This file contains a simple program that takes an old path, a new path, 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 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. 20 // generates a delta that can be sent to Chrome OS clients.
21 21
22 using std::set; 22 using std::set;
23 using std::string; 23 using std::string;
24 24
25 namespace chromeos_update_engine { 25 namespace chromeos_update_engine {
26 26
27 namespace { 27 namespace {
28 // These paths should never be delta diffed. They should always be transmitted
29 // in full in the update.
30 const char* kNonDiffPaths[] = {
31 "/boot/extlinux.conf"
32 };
33 28
34 void usage(const char* argv0) { 29 void usage(const char* argv0) {
35 printf("usage: %s old_dir new_dir out_file\n", argv0); 30 printf("usage: %s old_dir new_dir out_file\n", argv0);
36 exit(1); 31 exit(1);
37 } 32 }
38 33
39 bool IsDir(const char* path) { 34 bool IsDir(const char* path) {
40 struct stat stbuf; 35 struct stat stbuf;
41 TEST_AND_RETURN_FALSE_ERRNO(lstat(path, &stbuf) == 0); 36 TEST_AND_RETURN_FALSE_ERRNO(lstat(path, &stbuf) == 0);
42 return S_ISDIR(stbuf.st_mode); 37 return S_ISDIR(stbuf.st_mode);
43 } 38 }
44 39
45 int Main(int argc, char** argv) { 40 int Main(int argc, char** argv) {
46 g_thread_init(NULL); 41 g_thread_init(NULL);
47 Subprocess::Init(); 42 Subprocess::Init();
48 if (argc != 4) { 43 if (argc != 4) {
49 usage(argv[0]); 44 usage(argv[0]);
50 } 45 }
51 logging::InitLogging("", 46 logging::InitLogging("",
52 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 47 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
53 logging::DONT_LOCK_LOG_FILE, 48 logging::DONT_LOCK_LOG_FILE,
54 logging::APPEND_TO_OLD_LOG_FILE); 49 logging::APPEND_TO_OLD_LOG_FILE);
55 const char* old_dir = argv[1]; 50 const char* old_dir = argv[1];
56 const char* new_dir = argv[2]; 51 const char* new_dir = argv[2];
57 if ((!IsDir(old_dir)) || (!IsDir(new_dir))) { 52 if ((!IsDir(old_dir)) || (!IsDir(new_dir))) {
58 usage(argv[0]); 53 usage(argv[0]);
59 } 54 }
60 55
61 set<string> non_diff_paths; 56 // TODO(adlr): generate delta file
62 for (size_t i = 0; i < arraysize(kNonDiffPaths); i++) 57
63 non_diff_paths.insert(kNonDiffPaths[i]);
64
65 DeltaArchiveManifest* manifest =
66 DeltaDiffGenerator::EncodeMetadataToProtoBuffer(new_dir);
67 CHECK(manifest);
68 CHECK(DeltaDiffGenerator::EncodeDataToDeltaFile(manifest,
69 old_dir,
70 new_dir,
71 argv[3],
72 non_diff_paths,
73 ""));
74 return 0; 58 return 0;
75 } 59 }
76 60
77 } // namespace {} 61 } // namespace {}
78 62
79 } // namespace chromeos_update_engine 63 } // namespace chromeos_update_engine
80 64
81 int main(int argc, char** argv) { 65 int main(int argc, char** argv) {
82 return chromeos_update_engine::Main(argc, argv); 66 return chromeos_update_engine::Main(argc, argv);
83 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698