factory_installer: Abort when postinst script failed

This change aborts the installation when the postinst script failed, so
the we can have time to check the error log.  Also, the postinst script
is run before we update the firmware.  Thus if the postinst script
failed while running netboot, the netboot firmware is not replaced and
we can re-run the netboot by simplt reboot the device.

BUG=b:175936265
TEST=Run RMA install shim
TEST=Make postinst script fail and then run RMA install shim

Change-Id: I5e28aa1903f2b9ec3cb3a6e1f4f1bf01b02aaa5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory_installer/+/2603209
Reviewed-by: Cheng-Han Yang <chenghan@chromium.org>
Commit-Queue: Pin-yen Lin <treapking@chromium.org>
Tested-by: Pin-yen Lin <treapking@chromium.org>
diff --git a/factory_install.sh b/factory_install.sh
index 7d624ba..861f083 100644
--- a/factory_install.sh
+++ b/factory_install.sh
@@ -816,7 +816,8 @@
 
   # Disable release partition and activate factory partition
   disable_release_partition
-  run_postinst "$(make_partition_dev "${DST_DRIVE}" "${DST_FACTORY_PART}")"
+  run_postinst "$(make_partition_dev "${DST_DRIVE}" "${DST_FACTORY_PART}")" ||
+    die "Failed running postinst script."
   stateful_postinst "$(make_partition_dev "${DST_DRIVE}" "${DST_STATE_PART}")"
 
   if [ -s "${tmp_dir}/firmware" ]; then