openpower-software-manager: Support ubi and static layout

Move ubi and static specific configures into bbclass, and inherit the
bbclass in openpower-software-manager recipe.

Tested: Verify Romulus build uses the static bbclass, and Witherspoon
        uses the ubi bbclass.

(From meta-openpower rev: 2c2604d36e9415396baf1936b07a6a974b376cd9)

Change-Id: I23f68486ab95802785f7c5c22232a9f2b76d0341
Signed-off-by: Lei YU <mine260309@gmail.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meta-openpower/classes/openpower-software-manager-static.bbclass b/meta-openpower/classes/openpower-software-manager-static.bbclass
new file mode 100644
index 0000000..4afb274
--- /dev/null
+++ b/meta-openpower/classes/openpower-software-manager-static.bbclass
@@ -0,0 +1,4 @@
+RDEPENDS_${PN} += "pflash"
+
+SYSTEMD_SERVICE_${PN} += "openpower-pnor-update@.service"
+
diff --git a/meta-openpower/classes/openpower-software-manager-ubi.bbclass b/meta-openpower/classes/openpower-software-manager-ubi.bbclass
new file mode 100644
index 0000000..ae6c388
--- /dev/null
+++ b/meta-openpower/classes/openpower-software-manager-ubi.bbclass
@@ -0,0 +1,35 @@
+SRC_URI += "file://obmc-flash-bios"
+
+PACKAGECONFIG_append = " ubifs_layout"
+
+do_install_append() {
+        install -d ${D}${sbindir}
+        install -m 0755 ${WORKDIR}/obmc-flash-bios ${D}${sbindir}/obmc-flash-bios
+}
+
+SYSTEMD_SERVICE_${PN} += " \
+        obmc-flash-bios-ubiattach.service \
+        obmc-flash-bios-ubimount@.service \
+        obmc-flash-bios-ubiumount-ro@.service \
+        obmc-flash-bios-ubiumount-rw@.service \
+        obmc-flash-bios-ubipatch.service \
+        obmc-flash-bios-ubiremount.service \
+        obmc-flash-bios-updatesymlinks.service \
+        obmc-flash-bios-cleanup.service \
+        obmc-flash-bios-enable-clearvolatile@.service \
+        obmc-flash-bios-check-clearvolatile@.service \
+        op-pnor-msl.service \
+        "
+
+ENABLE_CLEAR_VOLATILE_TMPL = "obmc-flash-bios-enable-clearvolatile@.service"
+HOST_START_TGTFMT = "obmc-host-start@{0}.target"
+ENABLE_CLEAR_VOLATILE_INSTFMT = "obmc-flash-bios-enable-clearvolatile@{0}.service"
+ENABLE_CLEAR_VOLATILE_START_FMT = "../${ENABLE_CLEAR_VOLATILE_TMPL}:${HOST_START_TGTFMT}.requires/${ENABLE_CLEAR_VOLATILE_INSTFMT}"
+
+CHECK_CLEAR_VOLATILE_TMPL = "obmc-flash-bios-check-clearvolatile@.service"
+HOST_STARTMIN_TGTFMT = "obmc-host-startmin@{0}.target"
+CHECK_CLEAR_VOLATILE_INSTFMT = "obmc-flash-bios-check-clearvolatile@{0}.service"
+CHECK_CLEAR_VOLATILE_START_FMT = "../${CHECK_CLEAR_VOLATILE_TMPL}:${HOST_STARTMIN_TGTFMT}.requires/${CHECK_CLEAR_VOLATILE_INSTFMT}"
+
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'ENABLE_CLEAR_VOLATILE_START_FMT', 'OBMC_HOST_INSTANCES')}"
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHECK_CLEAR_VOLATILE_START_FMT', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-openpower/recipes-phosphor/flash/openpower-software-manager_git.bb b/meta-openpower/recipes-phosphor/flash/openpower-software-manager_git.bb
index 4969368..6ef74a8 100644
--- a/meta-openpower/recipes-phosphor/flash/openpower-software-manager_git.bb
+++ b/meta-openpower/recipes-phosphor/flash/openpower-software-manager_git.bb
@@ -8,11 +8,16 @@
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
 
-inherit autotools pkgconfig
+inherit autotools pkgconfig systemd
 inherit obmc-phosphor-dbus-service
 inherit pythonnative
 
+inherit ${@bb.utils.contains('DISTRO_FEATURES', 'openpower-ubi-fs', \
+                             'openpower-software-manager-ubi', \
+                             'openpower-software-manager-static', d)}
+
 PACKAGECONFIG[verify_pnor_signature] = "--enable-verify_pnor_signature,--disable-verify_pnor_signature"
+PACKAGECONFIG[ubifs_layout] = "--enable-ubifs_layout,--disable-ubifs_layout,,mtd-utils-ubifs"
 
 EXTRA_OECONF += " \
     PNOR_MSL="v2.0.10 v2.2" \
@@ -27,7 +32,6 @@
         "
 
 RDEPENDS_${PN} += " \
-        mtd-utils-ubifs \
         virtual-obmc-image-manager \
         "
 
@@ -35,40 +39,10 @@
 
 SRC_URI += "git://github.com/openbmc/openpower-pnor-code-mgmt"
 
-SRC_URI += "file://obmc-flash-bios"
-
 SRCREV = "799eb1972c141271068cd4ea1010753e0347d8ab"
 
-do_install_append() {
-        install -d ${D}${sbindir}
-        install -m 0755 ${WORKDIR}/obmc-flash-bios ${D}${sbindir}/obmc-flash-bios
-}
-
 DBUS_SERVICE_${PN} += "org.open_power.Software.Host.Updater.service"
 
 SYSTEMD_SERVICE_${PN} += " \
-        obmc-flash-bios-ubiattach.service \
-        obmc-flash-bios-ubimount@.service \
-        obmc-flash-bios-ubiumount-ro@.service \
-        obmc-flash-bios-ubiumount-rw@.service \
-        obmc-flash-bios-ubipatch.service \
-        obmc-flash-bios-ubiremount.service \
-        obmc-flash-bios-updatesymlinks.service \
-        obmc-flash-bios-cleanup.service \
-        obmc-flash-bios-enable-clearvolatile@.service \
-        obmc-flash-bios-check-clearvolatile@.service \
         op-pnor-msl.service \
         "
-
-ENABLE_CLEAR_VOLATILE_TMPL = "obmc-flash-bios-enable-clearvolatile@.service"
-HOST_START_TGTFMT = "obmc-host-start@{0}.target"
-ENABLE_CLEAR_VOLATILE_INSTFMT = "obmc-flash-bios-enable-clearvolatile@{0}.service"
-ENABLE_CLEAR_VOLATILE_START_FMT = "../${ENABLE_CLEAR_VOLATILE_TMPL}:${HOST_START_TGTFMT}.requires/${ENABLE_CLEAR_VOLATILE_INSTFMT}"
-
-CHECK_CLEAR_VOLATILE_TMPL = "obmc-flash-bios-check-clearvolatile@.service"
-HOST_STARTMIN_TGTFMT = "obmc-host-startmin@{0}.target"
-CHECK_CLEAR_VOLATILE_INSTFMT = "obmc-flash-bios-check-clearvolatile@{0}.service"
-CHECK_CLEAR_VOLATILE_START_FMT = "../${CHECK_CLEAR_VOLATILE_TMPL}:${HOST_STARTMIN_TGTFMT}.requires/${CHECK_CLEAR_VOLATILE_INSTFMT}"
-
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'ENABLE_CLEAR_VOLATILE_START_FMT', 'OBMC_HOST_INSTANCES')}"
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHECK_CLEAR_VOLATILE_START_FMT', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-openpower/recipes-phosphor/packagegroups/packagegroup-op-apps.bb b/meta-openpower/recipes-phosphor/packagegroups/packagegroup-op-apps.bb
index cdbc3f0..fba9ab2 100644
--- a/meta-openpower/recipes-phosphor/packagegroups/packagegroup-op-apps.bb
+++ b/meta-openpower/recipes-phosphor/packagegroups/packagegroup-op-apps.bb
@@ -42,13 +42,15 @@
         "
 
 SUMMARY_${PN}-flash = "OpenPOWER Flash"
+
+# TODO: remove below legacy services
 RDEPENDS_${PN}-flash = " \
         obmc-flash-bios \
         obmc-mgr-download \
         obmc-op-flasher \
         "
-RDEPENDS_${PN}-flash_df-openpower-ubi-fs = " \
-        openpower-software-manager \
+RDEPENDS_${PN}-flash += " \
+        openpower-software-manager\
         "
 
 SUMMARY_${PN}-system = "OpenPOWER System"