image_types_phosphor: Add do_generate_ext4_tar()

Add a new do_generate_ext4_tar() function that creates a tarball with
u-boot, kernel, ext4 rootfs and rwfs image files. This tarball is
intended for systems running with a mmc chip.

(From meta-phosphor rev: 02d65b716915f4424feca600f955937e1d16eb1a)

Change-Id: I3545dbb7c36d4ba5a71fb3735324228e8b609a15
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 54cbfa5..23ff347 100644
--- a/meta-phosphor/classes/image_types_phosphor.bbclass
+++ b/meta-phosphor/classes/image_types_phosphor.bbclass
@@ -16,16 +16,18 @@
 OVERLAY_BASETYPE ?= "jffs2"
 FLASH_UBI_BASETYPE ?= "${IMAGE_BASETYPE}"
 FLASH_UBI_OVERLAY_BASETYPE ?= "ubifs"
+FLASH_EXT4_BASETYPE ?= "ext4"
 FLASH_EXT4_OVERLAY_BASETYPE ?= "ext4"
 
-IMAGE_TYPES += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar"
+IMAGE_TYPES += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar mmc-ext4-tar"
 
 IMAGE_TYPEDEP_mtd-static = "${IMAGE_BASETYPE}"
 IMAGE_TYPEDEP_mtd-static-tar = "${IMAGE_BASETYPE}"
 IMAGE_TYPEDEP_mtd-static-alltar = "mtd-static"
 IMAGE_TYPEDEP_mtd-ubi = "${FLASH_UBI_BASETYPE}"
 IMAGE_TYPEDEP_mtd-ubi-tar = "${FLASH_UBI_BASETYPE}"
-IMAGE_TYPES_MASKED += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar"
+IMAGE_TYPEDEP_mmc-ext4-tar = "${FLASH_EXT4_BASETYPE}"
+IMAGE_TYPES_MASKED += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar mmc-ext4-tar"
 
 # Flash characteristics in KB unless otherwise noted
 DISTROOVERRIDES .= ":flash-${FLASH_SIZE}"
@@ -383,6 +385,23 @@
         ${PN}:do_copy_signing_pubkey \
         "
 
+do_generate_ext4_tar() {
+	ln -sf ${S}/MANIFEST MANIFEST
+	ln -sf ${S}/publickey publickey
+	make_image_links rwfs.${FLASH_EXT4_OVERLAY_BASETYPE} ${FLASH_EXT4_BASETYPE}
+	make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
+	make_tar_of_images ext4.mmc MANIFEST publickey ${signature_files}
+}
+do_generate_ext4_tar[dirs] = " ${S}/ext4"
+do_generate_ext4_tar[depends] += " \
+        ${PN}:do_image_${FLASH_EXT4_BASETYPE} \
+        virtual/kernel:do_deploy \
+        u-boot:do_populate_sysroot \
+        openssl-native:do_populate_sysroot \
+        ${SIGNING_KEY_DEPENDS} \
+        ${PN}:do_copy_signing_pubkey \
+        "
+
 def get_pubkey_basedir(d):
     return os.path.join(
         d.getVar('STAGING_DIR_TARGET', True),
@@ -460,4 +479,10 @@
                 'do_generate_ubi_tar',
                 'do_image_complete',
                 'do_generate_rwfs_ubi do_generate_phosphor_manifest', d)
+
+    if 'mmc-ext4-tar' in types:
+        bb.build.addtask(
+                'do_generate_ext4_tar',
+                'do_image_complete',
+                'do_generate_rwfs_ext4 do_generate_phosphor_manifest', d)
 }