systemd-units: move state units to own inc

The openbmc project is moving away from obmc-phosphor-systemd and its
SYSTEMD_LINK macros in favor of more explicit package based
installation. This commit gets phosphor-state-manager going in the right
direction so that future targets and services can build on the new way
to do things.

The chassis/host action and synchronization targets still need some
additional thought and effort.

Tested:
Booted up image in QEMU and spot checked a few services ensuring they
were still in the expected locations.

(From meta-phosphor rev: 5059a445b94e70efa7d6c90c1b5e7aa755dfe1d7)

Change-Id: I576cddd8ae10edb222d45e5b4903ea7195def4d4
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc b/meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc
new file mode 100644
index 0000000..c6ec8ea
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc
@@ -0,0 +1,118 @@
+pkg_postinst_${PN}-obmc-targets_append() {
+
+    mkdir -p $D$systemd_system_unitdir/multi-user.target.requires
+    LINK="$D$systemd_system_unitdir/multi-user.target.requires/obmc-host-reset@0.target"
+    TARGET="../obmc-host-reset@.target"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-discover-system-state@0.service"
+    TARGET="../phosphor-discover-system-state@.service"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-start@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.requires/obmc-host-startmin@0.target"
+    TARGET="../obmc-host-startmin@.target"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.requires/phosphor-reset-host-reboot-attempts@0.service"
+    TARGET="../phosphor-reset-host-reboot-attempts@.service"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-reset@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/phosphor-reset-host-check@0.service"
+    TARGET="../phosphor-reset-host-check@.service"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/phosphor-reset-sensor-states@0.service"
+    TARGET="../phosphor-reset-sensor-states@.service"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/phosphor-reset-host-running@0.service"
+    TARGET="../phosphor-reset-host-running@.service"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-shutdown@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-shutdown@0.target.requires/obmc-chassis-poweroff@0.target"
+    TARGET="../obmc-chassis-poweroff@.target"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-reboot@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-reboot@0.target.requires/obmc-host-shutdown@0.target"
+    TARGET="../obmc-host-shutdown@.target"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reboot@0.target.requires/phosphor-reboot-host@0.service"
+    TARGET="../phosphor-reboot-host@.service"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service"
+    TARGET="../xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/obmc-host-stop@0.target"
+    TARGET="../obmc-host-stop@.target"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/phosphor-reboot-host@0.service"
+    TARGET="../phosphor-reboot-host@.service"
+    ln -s $TARGET $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires/obmc-host-force-warm-reboot@0.target"
+    TARGET="../obmc-host-force-warm-reboot@.target"
+    ln -s $TARGET $LINK
+
+    mkdir -p $D$systemd_system_unitdir/obmc-host-diagnostic-mode@0.target.requires
+    LINK="$D$systemd_system_unitdir/obmc-host-diagnostic-mode@0.target.requires/obmc-host-force-warm-reboot@0.target"
+    TARGET="../obmc-host-force-warm-reboot@.target"
+    ln -s $TARGET $LINK
+}
+
+pkg_prerm_${PN}-obmc-targets_append() {
+
+    LINK="$D$systemd_system_unitdir/multi-user.target.requires/obmc-host-reset@0.target"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-discover-system-state@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.requires/obmc-host-startmin@0.target"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.requires/phosphor-reset-host-reboot-attempts@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/phosphor-reset-host-check@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/phosphor-reset-sensor-states@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/phosphor-reset-host-running@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-shutdown@0.target.requires/obmc-chassis-poweroff@0.target"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reboot@0.target.requires/obmc-host-shutdown@0.target"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-reboot@0.target.requires/phosphor-reboot-host@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/obmc-host-stop@0.target"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/phosphor-reboot-host@0.service"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires/obmc-host-force-warm-reboot@0.target"
+    rm $LINK
+
+    LINK="$D$systemd_system_unitdir/obmc-host-diagnostic-mode@0.target.requires/obmc-host-force-warm-reboot@0.target"
+    rm $LINK
+}