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/download_action.cc b/download_action.cc
index 5387821..eee25cc 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -5,10 +5,15 @@
#include "update_engine/download_action.h"
#include <errno.h>
#include <algorithm>
+#include <string>
+#include <vector>
#include <glib.h>
#include "update_engine/action_pipe.h"
+#include "update_engine/subprocess.h"
using std::min;
+using std::string;
+using std::vector;
namespace chromeos_update_engine {
@@ -84,6 +89,22 @@
omaha_hash_calculator_.Update(bytes, length);
}
+namespace {
+void FlushLinuxCaches() {
+ vector<string> command;
+ command.push_back("/bin/sync");
+ int rc;
+ LOG(INFO) << "FlushLinuxCaches/sync...";
+ Subprocess::SynchronousExec(command, &rc);
+ LOG(INFO) << "FlushLinuxCaches/drop_caches...";
+
+ const char* const drop_cmd = "3\n";
+ utils::WriteFile("/proc/sys/vm/drop_caches", drop_cmd, strlen(drop_cmd));
+
+ LOG(INFO) << "FlushLinuxCaches done.";
+}
+}
+
void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) {
if (writer_) {
CHECK_EQ(writer_->Close(), 0) << errno;
@@ -99,6 +120,8 @@
successful = false;
}
}
+
+ FlushLinuxCaches();
// Write the path to the output pipe if we're successful
if (successful && HasOutputPipe())