x86-power-control: install templated service correctly

The latest yocto update is flagging an error on machines using this
recipe. The reason appears to be because the templated services are
added to the SYSTEMD_SERVICE variable but they are not properly
installed into the filesystem.

Install the templated service file utilizing a more direct and tested
method.

Tested:
- Confirmed service file installed in rootfs as expected
```
/rootfs/usr/lib/systemd/system/sysinit.target.wants/xyz.openbmc_project.Chassis.Control.Power@0.service
```

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Ic0b375f31a0b92314618f978871c971caab041b4
diff --git a/meta-phosphor/recipes-x86/chassis/x86-power-control_git.bb b/meta-phosphor/recipes-x86/chassis/x86-power-control_git.bb
index 897c3a7..553a96b 100755
--- a/meta-phosphor/recipes-x86/chassis/x86-power-control_git.bb
+++ b/meta-phosphor/recipes-x86/chassis/x86-power-control_git.bb
@@ -12,12 +12,6 @@
 inherit meson systemd pkgconfig
 inherit obmc-phosphor-dbus-service
 
-def get_service(d):
-    if(d.getVar('OBMC_HOST_INSTANCES') == '0'):
-      return "xyz.openbmc_project.Chassis.Control.Power@0.service"
-    else:
-      return " ".join(["xyz.openbmc_project.Chassis.Control.Power@{}.service".format(x) for x in d.getVar('OBMC_HOST_INSTANCES').split()])
-SYSTEMD_SERVICE:${PN} = "${@get_service(d)}"
 SYSTEMD_SERVICE:${PN} += "chassis-system-reset.service \
                          chassis-system-reset.target"
 DEPENDS += " \
@@ -29,3 +23,21 @@
     phosphor-logging \
   "
 FILES:${PN}  += "${systemd_system_unitdir}/xyz.openbmc_project.Chassis.Control.Power@.service"
+
+pkg_postinst:${PN}:append() {
+    mkdir -p $D$systemd_system_unitdir/sysinit.target.wants
+    for i in ${OBMC_HOST_INSTANCES};
+    do
+        LINK="$D$systemd_system_unitdir/sysinit.target.wants/xyz.openbmc_project.Chassis.Control.Power@${i}.service"
+        TARGET="../xyz.openbmc_project.Chassis.Control.Power@.service"
+        ln -s $TARGET $LINK
+    done
+}
+
+pkg_prerm:${PN}:append() {
+    for i in ${OBMC_HOST_INSTANCES};
+    do
+        LINK="$D$systemd_system_unitdir/sysinit.target.requires/xyz.openbmc_project.Chassis.Control.Power@${i}.service"
+        rm $LINK
+    done
+}