OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <string> | 5 #include <string> |
6 #include <tr1/memory> | 6 #include <tr1/memory> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
10 #include <glib.h> | 10 #include <glib.h> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/string_util.h" |
14 #include "metrics/metrics_library.h" | 15 #include "metrics/metrics_library.h" |
15 #include "update_engine/dbus_constants.h" | 16 #include "update_engine/dbus_constants.h" |
16 #include "update_engine/dbus_service.h" | 17 #include "update_engine/dbus_service.h" |
17 #include "update_engine/prefs.h" | 18 #include "update_engine/prefs.h" |
| 19 #include "update_engine/subprocess.h" |
18 #include "update_engine/update_attempter.h" | 20 #include "update_engine/update_attempter.h" |
19 #include "update_engine/utils.h" | 21 #include "update_engine/utils.h" |
20 | 22 |
21 extern "C" { | 23 extern "C" { |
22 #include "update_engine/update_engine.dbusserver.h" | 24 #include "update_engine/update_engine.dbusserver.h" |
23 } | 25 } |
24 | 26 |
25 DEFINE_bool(logtostderr, false, | 27 DEFINE_bool(logtostderr, false, |
26 "Write logs to stderr instead of to a file in log_dir."); | 28 "Write logs to stderr instead of to a file in log_dir."); |
27 DEFINE_bool(foreground, false, | 29 DEFINE_bool(foreground, false, |
28 "Don't daemon()ize; run in foreground."); | 30 "Don't daemon()ize; run in foreground."); |
29 | 31 |
30 using std::string; | 32 using std::string; |
31 using std::tr1::shared_ptr; | 33 using std::tr1::shared_ptr; |
32 using std::vector; | 34 using std::vector; |
33 | 35 |
34 namespace chromeos_update_engine { | 36 namespace chromeos_update_engine { |
35 | 37 |
| 38 gboolean UpdateBootFlags(void* arg) { |
| 39 // This purely best effort. Failures should be logged by Subprocess. |
| 40 int unused = 0; |
| 41 vector<string> cmd(1, "/usr/sbin/chromeos-setgoodkernel"); |
| 42 Subprocess::SynchronousExec(cmd, &unused); |
| 43 return FALSE; // Don't call this callback again |
| 44 } |
| 45 |
36 namespace { | 46 namespace { |
37 | 47 |
38 gboolean UpdateOnce(void* arg) { | 48 gboolean UpdateOnce(void* arg) { |
39 UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg); | 49 UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg); |
40 update_attempter->Update("", ""); | 50 update_attempter->Update("", ""); |
41 return FALSE; | 51 return FALSE; |
42 } | 52 } |
43 | 53 |
44 gboolean UpdatePeriodically(void* arg) { | 54 gboolean UpdatePeriodically(void* arg) { |
45 UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg); | 55 UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, | 150 dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, |
141 &dbus_glib_update_engine_service_object_info); | 151 &dbus_glib_update_engine_service_object_info); |
142 UpdateEngineService* service = | 152 UpdateEngineService* service = |
143 UPDATE_ENGINE_SERVICE(g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL)); | 153 UPDATE_ENGINE_SERVICE(g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL)); |
144 service->update_attempter_ = &update_attempter; | 154 service->update_attempter_ = &update_attempter; |
145 update_attempter.set_dbus_service(service); | 155 update_attempter.set_dbus_service(service); |
146 chromeos_update_engine::SetupDbusService(service); | 156 chromeos_update_engine::SetupDbusService(service); |
147 | 157 |
148 chromeos_update_engine::SchedulePeriodicUpdateChecks(&update_attempter); | 158 chromeos_update_engine::SchedulePeriodicUpdateChecks(&update_attempter); |
149 | 159 |
| 160 // Update boot flags after 45 seconds |
| 161 g_timeout_add_seconds(45, &chromeos_update_engine::UpdateBootFlags, NULL); |
| 162 |
150 // Run the main loop until exit time: | 163 // Run the main loop until exit time: |
151 g_main_loop_run(loop); | 164 g_main_loop_run(loop); |
152 | 165 |
153 // Cleanup: | 166 // Cleanup: |
154 g_main_loop_unref(loop); | 167 g_main_loop_unref(loop); |
155 update_attempter.set_dbus_service(NULL); | 168 update_attempter.set_dbus_service(NULL); |
156 g_object_unref(G_OBJECT(service)); | 169 g_object_unref(G_OBJECT(service)); |
157 | 170 |
158 LOG(INFO) << "Chrome OS Update Engine terminating"; | 171 LOG(INFO) << "Chrome OS Update Engine terminating"; |
159 return 0; | 172 return 0; |
160 } | 173 } |
OLD | NEW |