update_engine: Remove copy from source to destination partition.

Removes the copy of the old rootfs and kernel to the new rootfs and
kernel. This was initially done in FilesystemCopierAction, which is now
called FilesystemVerifierAction.

When FilesystemVerifierAction is given a source rootfs or kernel, it
calculates the hashes. When asked to verify the new rootfs or kernel, it
computes the hashes and compares them against the values in the manifest.

BUG=chromium:463562
TEST=Updates using `cros flash --src-image-to-delta` and unit tests.
CQ-DEPEND=CL:267360

Change-Id: I3c9ba60fa4af0c5381ba8a10883bd47dc40adb8c
Reviewed-on: https://chromium-review.googlesource.com/267554
Reviewed-by: Allie Wood <alliewood@chromium.org>
Commit-Queue: Allie Wood <alliewood@chromium.org>
Trybot-Ready: Allie Wood <alliewood@chromium.org>
Tested-by: Allie Wood <alliewood@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 139aaf2..678f38c 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -32,7 +32,7 @@
 #include "update_engine/dbus_service.h"
 #include "update_engine/dbus_wrapper_interface.h"
 #include "update_engine/download_action.h"
-#include "update_engine/filesystem_copier_action.h"
+#include "update_engine/filesystem_verifier_action.h"
 #include "update_engine/glib_utils.h"
 #include "update_engine/hardware_interface.h"
 #include "update_engine/libcurl_http_fetcher.h"
@@ -110,7 +110,7 @@
 }
 
 // Turns a generic ErrorCode::kError to a generic error code specific
-// to |action| (e.g., ErrorCode::kFilesystemCopierError). If |code| is
+// to |action| (e.g., ErrorCode::kFilesystemVerifierError). If |code| is
 // not ErrorCode::kError, or the action is not matched, returns |code|
 // unchanged.
 ErrorCode GetErrorCodeForAction(AbstractAction* action,
@@ -123,8 +123,8 @@
     return ErrorCode::kOmahaRequestError;
   if (type == OmahaResponseHandlerAction::StaticType())
     return ErrorCode::kOmahaResponseHandlerError;
-  if (type == FilesystemCopierAction::StaticType())
-    return ErrorCode::kFilesystemCopierError;
+  if (type == FilesystemVerifierAction::StaticType())
+    return ErrorCode::kFilesystemVerifierError;
   if (type == PostinstallRunnerAction::StaticType())
     return ErrorCode::kPostinstallRunnerError;
 
@@ -604,11 +604,12 @@
                              false));
   shared_ptr<OmahaResponseHandlerAction> response_handler_action(
       new OmahaResponseHandlerAction(system_state_));
-  // We start with the kernel so it's marked as invalid more quickly.
-  shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action(
-      new FilesystemCopierAction(system_state_, true, false));
-  shared_ptr<FilesystemCopierAction> filesystem_copier_action(
-      new FilesystemCopierAction(system_state_, false, false));
+  shared_ptr<FilesystemVerifierAction> src_filesystem_verifier_action(
+      new FilesystemVerifierAction(system_state_,
+                                   PartitionType::kSourceRootfs));
+  shared_ptr<FilesystemVerifierAction> src_kernel_filesystem_verifier_action(
+      new FilesystemVerifierAction(system_state_,
+                                   PartitionType::kSourceKernel));
 
   shared_ptr<OmahaRequestAction> download_started_action(
       new OmahaRequestAction(system_state_,
@@ -632,10 +633,10 @@
                              new LibcurlHttpFetcher(GetProxyResolver(),
                                                     system_state_),
                              false));
-  shared_ptr<FilesystemCopierAction> filesystem_verifier_action(
-      new FilesystemCopierAction(system_state_, false, true));
-  shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action(
-      new FilesystemCopierAction(system_state_, true, true));
+  shared_ptr<FilesystemVerifierAction> dst_filesystem_verifier_action(
+      new FilesystemVerifierAction(system_state_, PartitionType::kRootfs));
+  shared_ptr<FilesystemVerifierAction> dst_kernel_filesystem_verifier_action(
+      new FilesystemVerifierAction(system_state_, PartitionType::kKernel));
   shared_ptr<OmahaRequestAction> update_complete_action(
       new OmahaRequestAction(system_state_,
                              new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
@@ -649,32 +650,34 @@
 
   actions_.push_back(shared_ptr<AbstractAction>(update_check_action));
   actions_.push_back(shared_ptr<AbstractAction>(response_handler_action));
-  actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action));
   actions_.push_back(shared_ptr<AbstractAction>(
-      kernel_filesystem_copier_action));
+      src_filesystem_verifier_action));
+  actions_.push_back(shared_ptr<AbstractAction>(
+      src_kernel_filesystem_verifier_action));
   actions_.push_back(shared_ptr<AbstractAction>(download_started_action));
   actions_.push_back(shared_ptr<AbstractAction>(download_action));
   actions_.push_back(shared_ptr<AbstractAction>(download_finished_action));
-  actions_.push_back(shared_ptr<AbstractAction>(filesystem_verifier_action));
-    actions_.push_back(shared_ptr<AbstractAction>(
-        kernel_filesystem_verifier_action));
+  actions_.push_back(shared_ptr<AbstractAction>(
+      dst_filesystem_verifier_action));
+  actions_.push_back(shared_ptr<AbstractAction>(
+      dst_kernel_filesystem_verifier_action));
 
   // Bond them together. We have to use the leaf-types when calling
   // BondActions().
   BondActions(update_check_action.get(),
               response_handler_action.get());
   BondActions(response_handler_action.get(),
-              filesystem_copier_action.get());
-  BondActions(filesystem_copier_action.get(),
-              kernel_filesystem_copier_action.get());
-  BondActions(kernel_filesystem_copier_action.get(),
+              src_filesystem_verifier_action.get());
+  BondActions(src_filesystem_verifier_action.get(),
+              src_kernel_filesystem_verifier_action.get());
+  BondActions(src_kernel_filesystem_verifier_action.get(),
               download_action.get());
   BondActions(download_action.get(),
-              filesystem_verifier_action.get());
-  BondActions(filesystem_verifier_action.get(),
-              kernel_filesystem_verifier_action.get());
+              dst_filesystem_verifier_action.get());
+  BondActions(dst_filesystem_verifier_action.get(),
+              dst_kernel_filesystem_verifier_action.get());
 
-  BuildPostInstallActions(kernel_filesystem_verifier_action.get());
+  BuildPostInstallActions(dst_kernel_filesystem_verifier_action.get());
 
   actions_.push_back(shared_ptr<AbstractAction>(update_complete_action));