diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2022-04-21 00:25:53 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2022-04-22 22:22:12 +0300 |
commit | 3952f8bd49b30590df75e8b86627e4087d73a387 (patch) | |
tree | 52731d5e7e60ec99172c2a6a972ee8d60a3ba250 | |
parent | f8cb53a272442fdfb58b391dc458d068ac3766d7 (diff) | |
download | openbmc-3952f8bd49b30590df75e8b86627e4087d73a387.tar.xz |
phosphor-state-manager: simplify systemd-links
Specify the target links as a variable with iteration rather than
manual entries for each symlink.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If40bf59dc00beb2c004c5da9953c3c5e64cbffba
-rw-r--r-- | meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc | 184 |
1 files changed, 35 insertions, 149 deletions
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 index e716c72276..6b0bda0ac7 100644 --- a/meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc +++ b/meta-phosphor/recipes-phosphor/state/phosphor-state-manager-systemd-links.inc @@ -1,3 +1,24 @@ +DEFAULT_TARGETS = " \ + multi-user.target.requires/xyz.openbmc_project.State.Host@{}.service \ + multi-user.target.requires/obmc-host-reset@{}.target \ + multi-user.target.requires/phosphor-discover-system-state@{}.service \ + obmc-chassis-poweron@{}.target.wants/phosphor-reset-host-recovery@{}.service \ + obmc-host-start@{}.target.requires/obmc-host-startmin@{}.target \ + obmc-host-start@{}.target.requires/phosphor-reset-host-reboot-attempts@{}.service \ + obmc-host-startmin@{}.target.wants/phosphor-set-host-transition-to-running@{}.service \ + obmc-host-stop@{}.target.wants/phosphor-set-host-transition-to-off@{}.service \ + obmc-host-reset@{}.target.requires/phosphor-reset-host-running@{}.service \ + obmc-host-stop@{}.target.wants/phosphor-reset-sensor-states@{}.service \ + obmc-host-quiesce@{}.target.wants/phosphor-reset-sensor-states@{}.service \ + obmc-host-shutdown@{}.target.requires/obmc-chassis-poweroff@{}.target \ + obmc-host-reboot@{}.target.requires/obmc-host-shutdown@{}.target \ + obmc-host-reboot@{}.target.requires/phosphor-reboot-host@{}.service \ + obmc-host-warm-reboot@{}.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service \ + obmc-host-force-warm-reboot@{}.target.requires/obmc-host-stop@{}.target \ + obmc-host-force-warm-reboot@{}.target.requires/phosphor-reboot-host@{}.service \ + obmc-host-warm-reboot@{}.target.requires/obmc-host-force-warm-reboot@{}.target \ + obmc-chassis-poweroff@{}.target.wants/phosphor-clear-one-time@{}.service \ +" # TODO: There are some targets that are chassis oriented, but there is no # obvious way to map HOST<->CHASSIS relationships. Making an assumption @@ -7,94 +28,14 @@ pkg_postinst:${PN}-obmc-targets:append() { for i in ${OBMC_HOST_INSTANCES}; do - mkdir -p $D$systemd_system_unitdir/multi-user.target.requires - LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Host@${i}.service" - TARGET="../xyz.openbmc_project.State.Host@.service" - ln -s $TARGET $LINK - - LINK="$D$systemd_system_unitdir/multi-user.target.requires/obmc-host-reset@${i}.target" - TARGET="../obmc-host-reset@.target" - ln -s $TARGET $LINK - - LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-discover-system-state@${i}.service" - TARGET="../phosphor-discover-system-state@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.wants - LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.wants/phosphor-reset-host-recovery@${i}.service" - TARGET="../phosphor-reset-host-recovery@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-start@${i}.target.requires - LINK="$D$systemd_system_unitdir/obmc-host-start@${i}.target.requires/obmc-host-startmin@${i}.target" - TARGET="../obmc-host-startmin@.target" - ln -s $TARGET $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-start@${i}.target.requires/phosphor-reset-host-reboot-attempts@${i}.service" - TARGET="../phosphor-reset-host-reboot-attempts@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@${i}.target.wants - LINK="$D$systemd_system_unitdir/obmc-host-startmin@${i}.target.wants/phosphor-set-host-transition-to-running@${i}.service" - TARGET="../phosphor-set-host-transition-to-running@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-stop@${i}.target.wants - LINK="$D$systemd_system_unitdir/obmc-host-stop@${i}.target.wants/phosphor-set-host-transition-to-off@${i}.service" - TARGET="../phosphor-set-host-transition-to-off@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-reset@${i}.target.requires - LINK="$D$systemd_system_unitdir/obmc-host-reset@${i}.target.requires/phosphor-reset-host-running@${i}.service" - TARGET="../phosphor-reset-host-running@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-stop@${i}.target.wants - LINK="$D$systemd_system_unitdir/obmc-host-stop@${i}.target.wants/phosphor-reset-sensor-states@${i}.service" - TARGET="../phosphor-reset-sensor-states@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-quiesce@${i}.target.wants - LINK="$D$systemd_system_unitdir/obmc-host-quiesce@${i}.target.wants/phosphor-reset-sensor-states@${i}.service" - TARGET="../phosphor-reset-sensor-states@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-shutdown@${i}.target.requires - LINK="$D$systemd_system_unitdir/obmc-host-shutdown@${i}.target.requires/obmc-chassis-poweroff@${i}.target" - TARGET="../obmc-chassis-poweroff@.target" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-reboot@${i}.target.requires - LINK="$D$systemd_system_unitdir/obmc-host-reboot@${i}.target.requires/obmc-host-shutdown@${i}.target" - TARGET="../obmc-host-shutdown@.target" - ln -s $TARGET $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-reboot@${i}.target.requires/phosphor-reboot-host@${i}.service" - TARGET="../phosphor-reboot-host@.service" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-host-warm-reboot@${i}.target.requires - LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@${i}.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@${i}.target.requires - LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@${i}.target.requires/obmc-host-stop@${i}.target" - TARGET="../obmc-host-stop@.target" - ln -s $TARGET $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@${i}.target.requires/phosphor-reboot-host@${i}.service" - TARGET="../phosphor-reboot-host@.service" - ln -s $TARGET $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@${i}.target.requires/obmc-host-force-warm-reboot@${i}.target" - TARGET="../obmc-host-force-warm-reboot@.target" - ln -s $TARGET $LINK - - mkdir -p $D$systemd_system_unitdir/obmc-chassis-poweroff@${i}.target.wants - LINK="$D$systemd_system_unitdir/obmc-chassis-poweroff@${i}.target.wants/phosphor-clear-one-time@${i}.service" - TARGET="../phosphor-clear-one-time@.service" - ln -s $TARGET $LINK + for j in ${DEFAULT_TARGETS}; + do + LINK="$D$systemd_system_unitdir/${j}" + LINK="$(echo ${LINK} | sed s/{}/${i}/g )" + TARGET="../$(basename ${j} | sed s/{}//g )" + mkdir -p "$(dirname ${LINK})" + ln -s "${TARGET}" "${LINK}" + done done } @@ -125,67 +66,12 @@ pkg_prerm:${PN}-obmc-targets:append() { for i in ${OBMC_HOST_INSTANCES}; do - - LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Host@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/multi-user.target.requires/xyz.openbmc_project.State.Chassis@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/multi-user.target.requires/obmc-host-reset@${i}.target" - rm $LINK - - LINK="$D$systemd_system_unitdir/multi-user.target.requires/phosphor-discover-system-state@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@${i}.target.wants/phosphor-reset-host-recovery@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-start@${i}.target.requires/obmc-host-startmin@${i}.target" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-start@${i}.target.requires/phosphor-reset-host-reboot-attempts@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-startmin@${i}.target.wants/phosphor-set-host-transition-to-running@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-stop@${i}.target.wants/phosphor-set-host-transition-to-off@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-stop@${i}.target.wants/phosphor-reset-sensor-states@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-quiesce@${i}.target.wants/phosphor-reset-sensor-states@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-reset@${i}.target.requires/phosphor-reset-host-running@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-shutdown@${i}.target.requires/obmc-chassis-poweroff@${i}.target" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-reboot@${i}.target.requires/obmc-host-shutdown@${i}.target" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-reboot@${i}.target.requires/phosphor-reboot-host@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@${i}.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@${i}.target.requires/obmc-host-stop@${i}.target" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-force-warm-reboot@${i}.target.requires/phosphor-reboot-host@${i}.service" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-host-warm-reboot@${i}.target.requires/obmc-host-force-warm-reboot@${i}.target" - rm $LINK - - LINK="$D$systemd_system_unitdir/obmc-chassis-poweroff@${i}.target.wants/phosphor-clear-one-time@${i}.service" - rm $LINK - + for j in ${DEFAULT_TARGETS}; + do + LINK="$D$systemd_system_unitdir/${j}" + LINK="$(echo ${LINK} | sed s/{}/${i}/g )" + rm "${LINK}" + done done } |