AU: Many minor cleanup changes
postinstall: Run postinst twice, once for pre-commit (ie, before we
mark the install partition bootable in the partition table), and
post-commit (for after we do). This behavior is needed for specific
types of firmware update.
download action: flush caches, as we found was necessary in
memento_updater.sh
omaha request prep action: update the names of keys we look for in
lsb-release, also get the AU server url from a file, rather than
hard-code it.
set bootable flag action: GPT support.
also, some misc utility functions.
BUG=None
TEST=attached unittests
Review URL: http://codereview.chromium.org/1881001
diff --git a/omaha_request_prep_action.cc b/omaha_request_prep_action.cc
index 9e144a0..6ee2c24 100644
--- a/omaha_request_prep_action.cc
+++ b/omaha_request_prep_action.cc
@@ -28,9 +28,11 @@
ScopedActionCompleter completer(processor_, this);
string machine_id;
TEST_AND_RETURN(GetMachineId(&machine_id));
- const string version(GetLsbValue("GOOGLE_RELEASE"));
+ const string version(GetLsbValue("CHROMEOS_RELEASE_VERSION", ""));
const string sp(version + "_" + GetMachineType());
- const string track(GetLsbValue("GOOGLE_TRACK"));
+ const string track(GetLsbValue("CHROMEOS_RELEASE_TRACK", ""));
+ const string update_url(GetLsbValue("CHROMEOS_AUSERVER",
+ UpdateCheckParams::kUpdateUrl));
UpdateCheckParams out(machine_id, // machine_id
machine_id, // user_id (use machine_id)
@@ -39,8 +41,9 @@
sp, // e.g. 0.2.3.3_i686
UpdateCheckParams::kAppId,
version, // app version (from lsb-release)
- "en-US", //lang
- track); // track
+ "en-US", // lang
+ track, // track
+ UpdateCheckParams::kUpdateUrl);
CHECK(HasOutputPipe());
SetOutputObject(out);
@@ -89,10 +92,13 @@
return true;
}
-std::string OmahaRequestPrepAction::GetLsbValue(const std::string& key) const {
+string OmahaRequestPrepAction::GetLsbValue(
+ const string& key, const string& default_value) const {
string files[] = {string(utils::kStatefulPartition) + "/etc/lsb-release",
"/etc/lsb-release"};
for (unsigned int i = 0; i < arraysize(files); i++) {
+ // TODO(adlr): make sure files checked are owned as root (and all
+ // their parents are recursively, too).
string file_data;
if (!utils::ReadFileToString(root_ + files[i], &file_data))
continue;
@@ -111,10 +117,10 @@
return file_data.substr(pos, length);
}
// not found
- return "";
+ return default_value;
}
-std::string OmahaRequestPrepAction::GetMachineType() const {
+string OmahaRequestPrepAction::GetMachineType() const {
struct utsname buf;
string ret;
if (uname(&buf) == 0)