Remove disk firmware upgrade check file

During postinstll, remove the check file to force a disk
firmware check at first reboot.
This change allows removing a cksum call at boot in disk firmware conf
file.

TEST=Install image with cros flash, check the file is removed and
recreated at boot.
TEST=Install image with USB key. Check sda1 partition does not
contain the check file anymore.

BUG=chromium:340883

Change-Id: I556291f8b74c50cef395ce3026e1aa7f2f8f6b6b
Reviewed-on: https://chromium-review.googlesource.com/186172
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
diff --git a/chromeos_postinst.cc b/chromeos_postinst.cc
index c4033e4..7ea4f71 100644
--- a/chromeos_postinst.cc
+++ b/chromeos_postinst.cc
@@ -150,10 +150,13 @@
   return result;
 }
 
-// Matches commandline arguments of chrome-chroot-postinst
+// Do post install stuff.
 //
+// Install kernel, set up the proper bootable partition in
+// GPT table, update firmware if necessary and possible.
+//
+// install_config defines the root, kernel and boot partitions.
 // src_version of the form "10.2.3.4" or "12.3.2"
-// install_dev of the form "/dev/sda3"
 //
 bool ChromeosChrootPostinst(const InstallConfig& install_config,
                             string src_version,
@@ -270,12 +273,20 @@
   // Create a file indicating that the install is completed. The file
   // will be used in /sbin/chromeos_startup to run tasks on the next boot.
   // See comments above about removing ureadahead files.
-  if (!Touch("/mnt/stateful_partition/.install_completed")) {
-    printf("Touch(/mnt/stateful_partition/.install_completed) FAILED\n");
+  string stateful_mnt = "/mnt/stateful_partition";
+  string install_completed = stateful_mnt + "/.install_completed";
+  if (!Touch(install_completed)) {
+    printf("Touch(%s) FAILED\n", install_completed.c_str());
     if (is_factory_install)
       return false;
   }
 
+  // If present, remove firmware checking completion file to force a disk
+  // firmware check at reboot.
+  string disk_fw_check_complete = stateful_mnt +
+      "/unencrypted/cache/.disk_firmware_upgrade_completed";
+  unlink(disk_fw_check_complete.c_str());
+
   // In postinst in future, we may provide an option (ex, --update_firmware).
   string firmware_tag_file = (install_config.root.mount() +
                               "/root/.force_update_firmware");