obmc-phosphor-initfs: persist rwfs-purged on init

In obmc-init.sh, when /var/google/do-rwfs-purge triggers an RWFS wipe
(rm -rf $upper), also persist rwfs-purged directly into
$upper/var/google/rwfs-purged immediately (with sync) in addition to
/run/initramfs/rwfs-purged.

Previously, rwfs-purged was only copied into /var/google by
49-purge-rwfs.sh during the subsequent netboot. If that subsequent boot
does not run 49-purge-rwfs.sh or reboots before reaching it, the trip_id
in /run/initramfs/rwfs-purged (tmpfs) is lost and the next netboot
triggers a redundant second RWFS purge and hard reset cycle.

Tested:
- Verified obmc-init.sh persists $upper/var/google/rwfs-purged across
  reboots immediately after wiping $upper.

Google-Bug-Id: 502759705
Google-Bug-Id: 549688820
Change-Id: I0f5102f4aee31383434e06a9b00c9c74f72a90e4
Signed-off-by: Mohamed Elbadry <elbadrym@google.com>
diff --git a/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/0001-obmc-phosphor-initfs-Add-support-for-purging-RWFS.patch b/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/0001-obmc-phosphor-initfs-Add-support-for-purging-RWFS.patch
index 176f108..3cf363f 100644
--- a/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/0001-obmc-phosphor-initfs-Add-support-for-purging-RWFS.patch
+++ b/recipes-phosphor/initrdscripts/obmc-phosphor-initfs/0001-obmc-phosphor-initfs-Add-support-for-purging-RWFS.patch
@@ -16,17 +16,17 @@
 Signed-off-by: Nan Zhou <nanzhou@google.com>
 Signed-off-by: Mo Elbadry <elbadrym@google.com>
 ---
- obmc-init.sh | 6 ++++++
- 1 file changed, 6 insertions(+)
+ obmc-init.sh | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
 
 diff --git a/obmc-init.sh b/obmc-init.sh
 index c493160..2bb0964 100644
 --- a/obmc-init.sh
 +++ b/obmc-init.sh
-@@ -418,6 +418,12 @@ then
+@@ -454,8 +454,19 @@ then
      find $work -maxdepth 1 -mindepth 1 -exec rm -rf '{}' +
  fi
-
+ 
 +if [ -e $upper/var/google/do-rwfs-purge ]; then
 +       echo 'Purging RWFS'
 +       cp $upper/var/google/do-rwfs-purge run/initramfs/rwfs-purged
@@ -34,8 +34,14 @@
 +fi
 +
  mkdir -p $upper $work
-
+ 
++if [ -e run/initramfs/rwfs-purged ]; then
++       mkdir -p $upper/var/google
++       cp run/initramfs/rwfs-purged $upper/var/google/rwfs-purged
++fi
++
  # Opportunisticly set a sane BMC date based on a file that gets
+ # written right before rebooting or powercycling. If none exists,
+ # use the image build date.
 --
 2.37.1.595.g718a3a8f04-goog
-