phosphor-settings-read-settings-mrw recipe

phosphor-settings-read-settings-mrw recipe calls gen_settings.pl
to replace any MRW variables in mrw-override-settings.yaml with
their MRW value.
The file generated by gen_settings.pl, mrw-settings.override.yaml,
is then used as an override of phosphor-settings.

mrw-override-settings.yaml by default is empty so no settings are
actually overwritten. A later commit will modify
mrw-override-settings.yaml in the Witherspoon layer.

Change-Id: I3134dbb834ff52abe5be589dd1d88444b8577254
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/common/recipes-phosphor/settings/phosphor-settings-manager.bb b/common/recipes-phosphor/settings/phosphor-settings-manager.bb
index 10938c9..3d4335d 100644
--- a/common/recipes-phosphor/settings/phosphor-settings-manager.bb
+++ b/common/recipes-phosphor/settings/phosphor-settings-manager.bb
@@ -16,6 +16,7 @@
 DEPENDS += "python-mako-native"
 DEPENDS += "autoconf-archive-native"
 DEPENDS += "virtual/phosphor-settings-defaults"
+DEPENDS += "${@cf_enabled(d, 'obmc-mrw', 'phosphor-settings-read-settings-mrw')}"
 DEPENDS += "sdbusplus sdbusplus-native"
 DEPENDS += "phosphor-dbus-interfaces phosphor-dbus-interfaces-native"
 DEPENDS += "phosphor-logging"
@@ -46,6 +47,10 @@
     cmd = []
     cmd.append(os.path.join(workdir, 'merge_settings.py'))
     cmd.append(os.path.join(settingsdir, 'defaults.yaml'))
+    # Used for any settings from the MRW
+    use_mrw = cf_enabled(d, 'obmc-mrw', 'true')
+    if (use_mrw == 'true'):
+        cmd.append(os.path.join(settingsdir, 'mrw-settings.override.yaml'))
 
     fetch = bb.fetch2.Fetch([], d)
     override_urls = [url for url in fetch.urls if url.endswith('.override.yml')]
diff --git a/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb b/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb
new file mode 100644
index 0000000..7260434
--- /dev/null
+++ b/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb
@@ -0,0 +1,33 @@
+# Generates MRW settings override yaml for phosphor-settings-manager
+# The default YAML file, mrw-override-settings.yaml, is empty, therefore no
+# settings will be overwritten. To override, modify mrw-override-settings.yaml.
+
+SUMMARY = "Generates MRW settings override YAML for phosphor-settings-manager."
+PR = "r1"
+
+inherit native
+inherit phosphor-settings-manager
+
+inherit obmc-phosphor-license
+
+DEPENDS += "mrw-native mrw-perl-tools-native"
+
+SRC_URI += "file://mrw-override-settings.yaml"
+
+S = "${WORKDIR}"
+
+do_install() {
+    DEST=${D}${config_datadir}
+    install -D mrw-override-settings.yaml ${DEST}/mrw-override-settings.yaml
+
+    SETTINGS=${D}${settings_datadir}
+    install -d ${SETTINGS}
+
+    # gen_settings.pl replaces any MRW variables with their value
+    ${bindir}/perl-native/perl \
+        ${bindir}/gen_settings.pl \
+        -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+        -s ${DEST}/mrw-override-settings.yaml \
+        -o ${SETTINGS}/mrw-settings.override.yaml \
+        -f
+}
diff --git a/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml b/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml
new file mode 100644
index 0000000..c0fbede
--- /dev/null
+++ b/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml
@@ -0,0 +1,3 @@
+# Default MRW settings override definition YAML - empty.
+# Any MRW variables, marked by MRW_<MRW variable name>, are replaced with their
+# MRW value.