image_types_phosphor: Split make_rwfs()

The make_rwfs() was doing some cleanup before creating the rwfs file.
Split it into two functions clean_rwfs() and make_rwfs() for cases where
some prep work is needed before calling the rwfs command, such as when
using mkfs.ext4 that needs to have a file created before it's converted
into ext4.

(From meta-phosphor rev: e82e8bc686b0a17f29d1d296f1d52543f2bc5ae0)

Change-Id: Idebaab86bfd6ff0c02444d9c62543e97e9ba0dcd
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meta-phosphor/classes/image_types_phosphor.bbclass b/meta-phosphor/classes/image_types_phosphor.bbclass
index 3d919df..dea8c3c 100644
--- a/meta-phosphor/classes/image_types_phosphor.bbclass
+++ b/meta-phosphor/classes/image_types_phosphor.bbclass
@@ -92,6 +92,15 @@
 		| tr '\000' '\377' > $image_dst
 }
 
+clean_rwfs() {
+	type=$1
+	shift
+
+	rm -f ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type
+	rm -rf $type
+	mkdir $type
+}
+
 make_rwfs() {
 	type=$1
 	cmd=$2
@@ -99,14 +108,13 @@
 	shift
 	opts="$@"
 
-	rm -f ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type
-	rm -rf $type
-	mkdir $type
+	mkdir -p $type
 
 	$cmd $opts
 }
 
 do_generate_rwfs_static() {
+	clean_rwfs ${OVERLAY_BASETYPE}
 	make_rwfs ${OVERLAY_BASETYPE} "${FLASH_STATIC_RWFS_CMD}" ${OVERLAY_MKFS_OPTS}
 }
 do_generate_rwfs_static[dirs] = " ${S}/static"
@@ -115,6 +123,7 @@
         "
 
 do_generate_rwfs_ubi() {
+	clean_rwfs ${FLASH_UBI_OVERLAY_BASETYPE}
 	make_rwfs ${FLASH_UBI_OVERLAY_BASETYPE} "${FLASH_UBI_RWFS_CMD}"
 }
 do_generate_rwfs_ubi[dirs] = " ${S}/ubi"