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
+}
diff --git a/meta-phosphor/recipes-phosphor/state/phosphor-state-manager_git.bb b/meta-phosphor/recipes-phosphor/state/phosphor-state-manager_git.bb
index 09ec151..a73f387 100644
--- a/meta-phosphor/recipes-phosphor/state/phosphor-state-manager_git.bb
+++ b/meta-phosphor/recipes-phosphor/state/phosphor-state-manager_git.bb
@@ -8,6 +8,8 @@
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
+include phosphor-state-manager-systemd-links.inc
+
STATE_MGR_PACKAGES = " \
${PN}-host \
${PN}-chassis \
@@ -82,102 +84,6 @@
FILES_${PN}-scheduled-host-transition = "${bindir}/phosphor-scheduled-host-transition"
DBUS_SERVICE_${PN}-scheduled-host-transition += "xyz.openbmc_project.State.ScheduledHostTransition.service"
-RESET_CHECK_TMPL = "phosphor-reset-host-check@.service"
-RESET_CHECK_TGTFMT = "obmc-host-reset@{1}.target"
-RESET_CHECK_INSTFMT = "phosphor-reset-host-check@{0}.service"
-RESET_CHECK_FMT = "../${RESET_CHECK_TMPL}:${RESET_CHECK_TGTFMT}.requires/${RESET_CHECK_INSTFMT}"
-
-SENSOR_RESET_TMPL = "phosphor-reset-sensor-states@.service"
-SENSOR_RESET_TGTFMT = "obmc-host-reset@{1}.target"
-SENSOR_RESET_INSTFMT = "phosphor-reset-sensor-states@{0}.service"
-SENSOR_RESET_FMT = "../${SENSOR_RESET_TMPL}:${SENSOR_RESET_TGTFMT}.requires/${SENSOR_RESET_INSTFMT}"
-
-RESET_RUNNING_TMPL = "phosphor-reset-host-running@.service"
-RESET_RUNNING_TGTFMT = "obmc-host-reset@{1}.target"
-RESET_RUNNING_INSTFMT = "phosphor-reset-host-running@{0}.service"
-RESET_RUNNING_FMT = "../${RESET_RUNNING_TMPL}:${RESET_RUNNING_TGTFMT}.requires/${RESET_RUNNING_INSTFMT}"
-
-SYSTEMD_LINK_${PN}-host-check += "${@compose_list_zip(d, 'RESET_CHECK_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
-SYSTEMD_LINK_${PN}-host-check += "${@compose_list_zip(d, 'RESET_RUNNING_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
-
-SYSTEMD_LINK_${PN}-reset-sensor-states += "${@compose_list_zip(d, 'SENSOR_RESET_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
-
-# Force the standby target to run the host reset check target
-RESET_TMPL_CTRL = "obmc-host-reset@.target"
-SYSD_TGT = "multi-user.target"
-RESET_INSTFMT_CTRL = "obmc-host-reset@{0}.target"
-RESET_FMT_CTRL = "../${RESET_TMPL_CTRL}:${SYSD_TGT}.wants/${RESET_INSTFMT_CTRL}"
-SYSTEMD_LINK_${PN}-host-check += "${@compose_list_zip(d, 'RESET_FMT_CTRL', 'OBMC_HOST_INSTANCES')}"
-
-TMPL = "phosphor-discover-system-state@.service"
-INSTFMT = "phosphor-discover-system-state@{0}.service"
-FMT = "../${TMPL}:multi-user.target.wants/${INSTFMT}"
-SYSTEMD_LINK_${PN}-discover += "${@compose_list(d, 'FMT', 'OBMC_HOST_INSTANCES')}"
-
-# Force the shutdown target to run the chassis-poweroff target
-CHASSIS_STOP_TMPL = "obmc-chassis-poweroff@.target"
-HOST_STOP_TGTFMT = "obmc-host-shutdown@{1}.target"
-CHASSIS_STOP_INSTFMT = "obmc-chassis-poweroff@{0}.target"
-HOST_STOP_FMT = "../${CHASSIS_STOP_TMPL}:${HOST_STOP_TGTFMT}.requires/${CHASSIS_STOP_INSTFMT}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_STOP_FMT', 'OBMC_CHASSIS_INSTANCES', 'OBMC_HOST_INSTANCES')}"
-
-# Force the host reboot target to run the shutdown target
-HOST_SHUTDOWN_TMPL = "obmc-host-shutdown@.target"
-HOST_REBOOT_TGTFMT = "obmc-host-reboot@{0}.target"
-HOST_SHUTDOWN_INSTFMT = "obmc-host-shutdown@{0}.target"
-HOST_REBOOT_FMT = "../${HOST_SHUTDOWN_TMPL}:${HOST_REBOOT_TGTFMT}.requires/${HOST_SHUTDOWN_INSTFMT}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_REBOOT_FMT', 'OBMC_HOST_INSTANCES')}"
-
-# And also force the reboot target to call the host startmin service
-HOST_REBOOT_SVC = "phosphor-reboot-host@.service"
-HOST_REBOOT_SVC_INST = "phosphor-reboot-host@{0}.service"
-HOST_REBOOT_SVC_FMT = "../${HOST_REBOOT_SVC}:${HOST_REBOOT_TGTFMT}.requires/${HOST_REBOOT_SVC_INST}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_REBOOT_SVC_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
-
-# Force the host-start target to call the host-startmin target
-HOST_STARTMIN_TMPL = "obmc-host-startmin@.target"
-HOST_START_TGTFMT = "obmc-host-start@{0}.target"
-HOST_STARTMIN_INSTFMT = "obmc-host-startmin@{0}.target"
-HOST_START_FMT = "../${HOST_STARTMIN_TMPL}:${HOST_START_TGTFMT}.requires/${HOST_STARTMIN_INSTFMT}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_START_FMT', 'OBMC_HOST_INSTANCES')}"
-
-# Force the host-start target to call the reboot count reset service
-HOST_RST_RBT_ATTEMPTS_SVC = "phosphor-reset-host-reboot-attempts@.service"
-HOST_RST_RBT_ATTEMPTS_SVC_INST = "phosphor-reset-host-reboot-attempts@{0}.service"
-HOST_RST_RBT_ATTEMPTS_SVC_FMT = "../${HOST_RST_RBT_ATTEMPTS_SVC}:${HOST_START_TGTFMT}.requires/${HOST_RST_RBT_ATTEMPTS_SVC_INST}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_RST_RBT_ATTEMPTS_SVC_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
-
-# Force warm reboot target to call soft power off
-HOST_WARM_REBOOT_TGTFMT = "obmc-host-warm-reboot@{0}.target"
-HOST_WARM_REBOOT_SOFT_SVC = "xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service"
-HOST_WARM_REBOOT_SOFT_SVC_FMT = "../${HOST_WARM_REBOOT_SOFT_SVC}:${HOST_WARM_REBOOT_TGTFMT}.requires/${HOST_WARM_REBOOT_SOFT_SVC}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_SOFT_SVC_FMT', 'OBMC_HOST_INSTANCES')}"
-
-# Force warm reboot target to call host stop
-HOST_WARM_REBOOT_STOP_TMPL="obmc-host-stop@.target"
-HOST_WARM_REBOOT_STOP_REQUIRES="obmc-host-force-warm-reboot@{0}.target"
-HOST_WARM_REBOOT_STOP_TMPL_INST="obmc-host-stop@{0}.target"
-HOST_WARM_REBOOT_STOP_TARGET_FMT = "../${HOST_WARM_REBOOT_STOP_TMPL}:${HOST_WARM_REBOOT_STOP_REQUIRES}.requires/${HOST_WARM_REBOOT_STOP_TMPL_INST}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_STOP_TARGET_FMT', 'OBMC_HOST_INSTANCES')}"
-
-# Force warm reboot target to call reboot host
-HOST_WARM_REBOOT_FORCE_TGTFMT = "obmc-host-force-warm-reboot@{0}.target"
-HOST_WARM_REBOOT_SVC = "phosphor-reboot-host@.service"
-HOST_WARM_REBOOT_SVC_INST = "phosphor-reboot-host@{0}.service"
-HOST_WARM_REBOOT_SVC_FMT = "../${HOST_WARM_REBOOT_SVC}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_SVC_INST}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_SVC_FMT', 'OBMC_HOST_INSTANCES')}"
-
-# Warm reboot to call force warm reboot
-# Warm reboot will be graceful due to to it also containing soft power off
-HOST_WARM_REBOOT_FORCE_TGT = "obmc-host-force-warm-reboot@.target"
-HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_TGTFMT}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_FORCE_TARGET_FMT', 'OBMC_HOST_INSTANCES')}"
-
-# Diagnostic target to call force warm reboot target
-HOST_DIAG_TGTFMT = "obmc-host-diagnostic-mode@0.target"
-HOST_DIAG_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_DIAG_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_TGTFMT}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_DIAG_TARGET_FMT', 'OBMC_HOST_INSTANCES')}"
-
# Chassis power synchronization targets
# - start-pre: Services to run before we start power on process
# - start: Services to run to do the chassis power on