gbmc-bridge: purge-rwfs: Purge if any powercycle is needed

In some cases we have netboot failures that result in extra powercycles.
We should ensure that if we are taking another powercycle but the RWFS
is already clear that we keep the RWFS clear on subsequent cycles so
that future powercycles don't spuriously require another clear step.

Change-Id: I110f369e840571fae8168970699f9ccb31e9a511
Signed-off-by: William A. Kennington III <wak@google.com>
(cherry picked from commit 9acfe921efbf2a6930f182634c9421882829c05e)
Signed-off-by: Vlad Sytchenko <vsytch@google.com>
Google-Bug-Id: 278592378
diff --git a/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh b/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh
index 5c2232e..b0933fb 100644
--- a/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh
+++ b/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh
@@ -19,8 +19,9 @@
   # Ensure that we don't succeed unless it clears
   GBMC_BR_DHCP_OUTSTANDING[gbmc_purge_rwfs]=1
 
-  # Only execute this hook if we aren't already purged
-  if [ -e '/run/initramfs/rwfs-purged' ]; then
+  # Only execute this hook if we aren't already purged and we don't
+  # require a powercycle that would spuriously erase the purge status.
+  if [ -z "${gbmc_psu_hardreset_needed-}" -a -e '/run/initramfs/rwfs-purged' ]; then
     echo 'RWFS already purged' >&2
     return 0
   fi