overlay: remove OBMC_PHOSPHOR_IMAGE_OVERLAY

Solve the problem resulting in the addition of this variable
differently, such that it can be removed and image type
selection can be selected in the standard way using IMAGE_FSTYPES.

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: Ice94e8f278f00b8b4d344244bfb87dddeb173a23
diff --git a/meta-phosphor/classes/image_types_phosphor.bbclass b/meta-phosphor/classes/image_types_phosphor.bbclass
new file mode 100644
index 0000000..eef1b1c
--- /dev/null
+++ b/meta-phosphor/classes/image_types_phosphor.bbclass
@@ -0,0 +1,16 @@
+# Base image class extension, inlined into every image.
+
+def build_uboot(d):
+    fstypes = d.getVar('IMAGE_FSTYPES', True).split()
+    if any([x.endswith('u-boot') for x in fstypes]):
+        return 'image_types_uboot'
+    return ''
+
+
+# Inherit u-boot classes if legacy uboot images are in use.
+IMAGE_TYPE_uboot = '${@build_uboot(d)}'
+inherit ${IMAGE_TYPE_uboot}
+
+# Inherit the overlay class if overlay is in use.
+IMAGE_TYPE_overlay = '${@bb.utils.contains("IMAGE_FSTYPES", "overlay", "image-overlay", "", d)}'
+inherit ${IMAGE_TYPE_overlay}
diff --git a/meta-phosphor/classes/obmc-phosphor-debug-tarball.bbclass b/meta-phosphor/classes/obmc-phosphor-debug-tarball.bbclass
index 0e5dbd2..a7d2dc4 100644
--- a/meta-phosphor/classes/obmc-phosphor-debug-tarball.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-debug-tarball.bbclass
@@ -1,7 +1,11 @@
+# IMAGE_FSTYPES must appear before image.bbclass
+# is inherited otherwise image.bbclass will inherit
+# "live" image fstypes that we don't want.
+IMAGE_FSTYPES = "tar.xz"
+
 inherit image
 inherit obmc-phosphor-license
 
-IMAGE_FSTYPES = "tar.xz"
 IMAGE_INSTALL_append = " busybox packagegroup-obmc-phosphor-debugtools"
 
 # Override from image_types.bbclass to restrict tarball to /usr tree.
diff --git a/meta-phosphor/classes/obmc-phosphor-image.bbclass b/meta-phosphor/classes/obmc-phosphor-image.bbclass
index 4758c8a..9b0a547 100644
--- a/meta-phosphor/classes/obmc-phosphor-image.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-image.bbclass
@@ -95,14 +95,6 @@
 
 OBMC_IMAGE_EXTRA_INSTALL ?= ""
 
-def image_overlay_enabled(d, ifEnabledStr):
-        if d.getVar('OBMC_PHOSPHOR_IMAGE_OVERLAY', True) != "1":
-            return ""
-        return ifEnabledStr
-
-IMAGE_FSTYPES += "${@image_overlay_enabled(d, "overlay")}"
-inherit ${@image_overlay_enabled(d, "image-overlay")}
-
 do_image_complete[depends] += "obmc-phosphor-debug-tarball:do_image_complete"
 
 # The /etc/version file is misleading and not useful.  Remove it.
diff --git a/meta-phosphor/conf/distro/openbmc-phosphor.conf b/meta-phosphor/conf/distro/openbmc-phosphor.conf
index 9f8bad2..924e119 100644
--- a/meta-phosphor/conf/distro/openbmc-phosphor.conf
+++ b/meta-phosphor/conf/distro/openbmc-phosphor.conf
@@ -56,3 +56,5 @@
 
 KERNEL_FEATURES_append = " phosphor-gpio-keys"
 KERNEL_FEATURES_remove_qemuall = " phosphor-gpio-keys"
+
+IMAGE_CLASSES_append = " image_types_phosphor"
diff --git a/meta-phosphor/conf/machine/include/obmc-bsp-common.inc b/meta-phosphor/conf/machine/include/obmc-bsp-common.inc
index f4649e3..03e73b3 100644
--- a/meta-phosphor/conf/machine/include/obmc-bsp-common.inc
+++ b/meta-phosphor/conf/machine/include/obmc-bsp-common.inc
@@ -10,12 +10,9 @@
 
 MACHINEOVERRIDES =. "openbmc:"
 
-OBMC_PHOSPHOR_IMAGE_OVERLAY= "1"
-IMAGE_FSTYPES += "cpio.${INITRAMFS_CTYPE}.u-boot"
+IMAGE_FSTYPES += "cpio.${INITRAMFS_CTYPE}.u-boot overlay"
 OBMC_IMAGE_EXTRA_INSTALL_append = " u-boot-fw-utils"
 
-IMAGE_CLASSES += "image_types_uboot"
-
 INITRAMFS_CTYPE ?= "lzma"
 INITRAMFS_FSTYPES += "cpio.${INITRAMFS_CTYPE}"
 INITRAMFS_IMAGE = "obmc-phosphor-initramfs"