Service files for factory reset change - clear instead of delete

This commit adds a new service file to the build which will clear the
contents of a specified UBI volume. It's intended as the backend for the
host factory reset.

Additionally, the service file obmc-flash-bios-ubiumount-prsv.service is
removed. This file removes the volume pnor-prsv. Its only use case - the
factory reset - is changing in this issue, openbmc/openbmc#2322, to
clear that volume instead of deleting it, so there's no reason to keep
the service file around anymore.

Change-Id: I577291e3511bf5234ffb87084a082255dac3dbae
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
index f82e6fb..948c6ec 100644
--- a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -263,6 +263,13 @@
   fi
 }
 
+clear_ubi() {
+  mountdir="/media/${name}"
+  if is_mounted "${name}"; then
+    rm -rf $mountdir/..?* $mountdir/.[!.]* $mountdir/*
+  fi
+}
+
 case "$1" in
   ubiattach)
     attach_ubi
@@ -286,6 +293,10 @@
   updatesymlinks)
     update_symlinks
     ;;
+  ubiclear)
+    name="$2"
+    clear_ubi
+    ;;
   *)
     echo "Invalid argument"
     exit 1
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiclear@.service b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiclear@.service
new file mode 100644
index 0000000..b84035f
--- /dev/null
+++ b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiclear@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Clear UBIFS volume %i
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/usr/bin/env obmc-flash-bios ubiclear %i
+SyslogIdentifier=obmc-flash-bios
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service
deleted file mode 100644
index 1c3939e..0000000
--- a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Remove UBIFS volume pnor-prsv
-Wants=obmc-flash-bios-ubiattach.service
-After=obmc-flash-bios-ubiattach.service
-
-[Service]
-Type=oneshot
-RemainAfterExit=no
-ExecStart=/usr/bin/env obmc-flash-bios ubiumount pnor-prsv
-SyslogIdentifier=obmc-flash-bios