update_engine: Log the rootfs and stateful partition's lsb-release
postinst cannot not do this anymore, so we need to log it in the UE itself.
BUG=chromium:786225
TEST=cros_flash two times and made sure they are logged.
Change-Id: I2fbc593f55e6425127de283c78e4170460bac0d9
Reviewed-on: https://chromium-review.googlesource.com/791515
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Alex Deymo <deymo@google.com>
diff --git a/image_properties.h b/image_properties.h
index ba6ce44..e03b8dc 100644
--- a/image_properties.h
+++ b/image_properties.h
@@ -68,8 +68,8 @@
// value may be returned instead.
ImageProperties LoadImageProperties(SystemState* system_state);
-// Loads the mutable image properties from the stateful partition if found or the
-// system image otherwise.
+// Loads the mutable image properties from the stateful partition if found or
+// the system image otherwise.
MutableImageProperties LoadMutableImageProperties(SystemState* system_state);
// Stores the mutable image properties in the stateful partition. Returns
@@ -77,6 +77,9 @@
bool StoreMutableImageProperties(SystemState* system_state,
const MutableImageProperties& properties);
+// Logs the image properties.
+void LogImageProperties();
+
// Sets the root_prefix used to load files from during unittests to
// |test_root_prefix|. Passing a nullptr value resets it to the default.
namespace test {
diff --git a/image_properties_android.cc b/image_properties_android.cc
index e3b7616..765b4ba 100644
--- a/image_properties_android.cc
+++ b/image_properties_android.cc
@@ -123,4 +123,8 @@
properties.is_powerwash_allowed));
}
+void LogImageProperties() {
+ // TODO(*): Implement this.
+}
+
} // namespace chromeos_update_engine
diff --git a/image_properties_chromeos.cc b/image_properties_chromeos.cc
index 6bab63f..39ddeb3 100644
--- a/image_properties_chromeos.cc
+++ b/image_properties_chromeos.cc
@@ -26,6 +26,7 @@
#include "update_engine/common/constants.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/platform_constants.h"
+#include "update_engine/common/utils.h"
#include "update_engine/system_state.h"
namespace {
@@ -149,4 +150,17 @@
return lsb_release.Save(path);
}
+void LogImageProperties() {
+ std::string lsb_release;
+ if (utils::ReadFile(kLsbRelease, &lsb_release)) {
+ LOG(INFO) << "lsb-release inside the old rootfs:\n" << lsb_release;
+ }
+
+ std::string stateful_lsb_release;
+ if (utils::ReadFile(std::string(kStatefulPartition) + kLsbRelease,
+ &stateful_lsb_release)) {
+ LOG(INFO) << "stateful lsb-release:\n" << stateful_lsb_release;
+ }
+}
+
} // namespace chromeos_update_engine
diff --git a/update_attempter.cc b/update_attempter.cc
index f8161a4..4fef9ce 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1032,6 +1032,15 @@
SetStatusAndNotify(UpdateStatus::UPDATE_AVAILABLE);
} else if (type == DownloadAction::StaticType()) {
SetStatusAndNotify(UpdateStatus::FINALIZING);
+ } else if (type == FilesystemVerifierAction::StaticType()) {
+ // Log the system properties before the postinst and after the file system
+ // is verified. It used to be done in the postinst itself. But postinst
+ // cannot do this anymore. On the other hand, these logs are frequently
+ // looked at and it is preferable not to scatter them in random location in
+ // the log and rather log it right before the postinst. The reason not do
+ // this in the |PostinstallRunnerAction| is to prevent dependency from
+ // libpayload_consumer to libupdate_engine.
+ LogImageProperties();
}
}