OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "update_engine/utils.h" | 5 #include "update_engine/utils.h" |
6 | 6 |
7 #include <sys/mount.h> | 7 #include <sys/mount.h> |
8 #include <sys/resource.h> | 8 #include <sys/resource.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "update_engine/subprocess.h" | 30 #include "update_engine/subprocess.h" |
31 | 31 |
32 using std::min; | 32 using std::min; |
33 using std::string; | 33 using std::string; |
34 using std::vector; | 34 using std::vector; |
35 | 35 |
36 namespace chromeos_update_engine { | 36 namespace chromeos_update_engine { |
37 | 37 |
38 namespace utils { | 38 namespace utils { |
39 | 39 |
| 40 static const char kOOBECompletedMarker[] = "/home/chronos/.oobe_completed"; |
| 41 |
40 bool IsOfficialBuild() { | 42 bool IsOfficialBuild() { |
41 OmahaRequestDeviceParams params; | 43 OmahaRequestDeviceParams params; |
42 if (!params.Init("", "")) { | 44 if (!params.Init("", "")) { |
43 return true; | 45 return true; |
44 } | 46 } |
45 return params.app_track != "buildbot-build" && | 47 return params.app_track != "buildbot-build" && |
46 params.app_track != "developer-build"; | 48 params.app_track != "developer-build"; |
47 } | 49 } |
48 | 50 |
| 51 bool IsOOBEComplete() { |
| 52 return file_util::PathExists(FilePath(kOOBECompletedMarker)); |
| 53 } |
| 54 |
49 bool WriteFile(const char* path, const char* data, int data_len) { | 55 bool WriteFile(const char* path, const char* data, int data_len) { |
50 DirectFileWriter writer; | 56 DirectFileWriter writer; |
51 TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path, | 57 TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path, |
52 O_WRONLY | O_CREAT | O_TRUNC, | 58 O_WRONLY | O_CREAT | O_TRUNC, |
53 0666)); | 59 0666)); |
54 ScopedFileWriterCloser closer(&writer); | 60 ScopedFileWriterCloser closer(&writer); |
55 TEST_AND_RETURN_FALSE_ERRNO(data_len == writer.Write(data, data_len)); | 61 TEST_AND_RETURN_FALSE_ERRNO(data_len == writer.Write(data, data_len)); |
56 return true; | 62 return true; |
57 } | 63 } |
58 | 64 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 int min = value - range / 2; | 460 int min = value - range / 2; |
455 int max = value + range - range / 2; | 461 int max = value + range - range / 2; |
456 return base::RandInt(min, max); | 462 return base::RandInt(min, max); |
457 } | 463 } |
458 | 464 |
459 const char* const kStatefulPartition = "/mnt/stateful_partition"; | 465 const char* const kStatefulPartition = "/mnt/stateful_partition"; |
460 | 466 |
461 } // namespace utils | 467 } // namespace utils |
462 | 468 |
463 } // namespace chromeos_update_engine | 469 } // namespace chromeos_update_engine |
OLD | NEW |