phosphor-power: Fix pkg_postinst script

The pkg_postinst script uses the variable OBMC_POWER_SUPPLY_INSTANCES
that is not availabe during the post installation. This results in the
links of power-supply-monitor@.service are not created.

Use `@d.getVar()` to get the variable from bitbake fixed the issue.

Also removes the default OBMC_POWER_SUPPLY_INSTANCES, let the build fail
when OBMC_POWER_SUPPLY_INSTANCES is not defined. Otherwise such issues
are only found at runtime.

Tested: Verify the witherspoon build contains the
        power-supply-monitor@.service links;
        Unset OBMC_POWER_SUPPLY_INSTANCES, verify the build fails due to
        installation failure.

Change-Id: I988dca7cb0002128ec9cbe853c2833c0754431c7
Signed-off-by: Lei YU <mine260309@gmail.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/recipes-phosphor/power/phosphor-power-systemd-links.bb b/recipes-phosphor/power/phosphor-power-systemd-links.bb
index 0ee5e83..2baaf0d 100644
--- a/recipes-phosphor/power/phosphor-power-systemd-links.bb
+++ b/recipes-phosphor/power/phosphor-power-systemd-links.bb
@@ -8,8 +8,6 @@
 
 RDEPENDS_${PN} += "phosphor-power"
 
-OBMC_POWER_SUPPLY_INSTANCES ?= "0"
-
 ALLOW_EMPTY_${PN} = "1"
 
 pkg_postinst_${PN}() {
@@ -24,7 +22,9 @@
 	TARGET="../pseq-monitor-pgood.service"
 	ln -s $TARGET $LINK
 
-	for inst in $OBMC_POWER_SUPPLY_INSTANCES; do
+	[ -z "${OBMC_POWER_SUPPLY_INSTANCES}" ] && echo "No power supply instance defined" && exit 1
+
+	for inst in ${OBMC_POWER_SUPPLY_INSTANCES}; do
 		LINK="$D$systemd_system_unitdir/multi-user.target.requires/power-supply-monitor@$inst.service"
 		TARGET="../power-supply-monitor@.service"
 		ln -s $TARGET $LINK
@@ -36,7 +36,10 @@
 	rm $LINK
 	LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@0.target.wants/pseq-monitor-pgood.service"
 	rm $LINK
-	for inst in $OBMC_POWER_SUPPLY_INSTANCES; do
+
+	[ -z "${OBMC_POWER_SUPPLY_INSTANCES}" ] && echo "No power supply instance defined" && exit 1
+
+	for inst in ${OBMC_POWER_SUPPLY_INSTANCES}; do
 		LINK="$D$systemd_system_unitdir/multi-user.target.requires/power-supply-monitor@$inst.service"
 		rm $LINK
 	done