1pkg_postinst:${PN}:append() {
2	mkdir -p $D$systemd_system_unitdir/obmc-host-crash@0.target.wants
3	mkdir -p $D$systemd_system_unitdir/obmc-host-timeout@0.target.wants
4
5	# The obmc-host-crash target is repurposed for the memory preserving reboot
6	# feature when it is enabled. If not enabled, then install the standard
7	# debug collector checkstop service for basic error reporting
8	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'mpreboot', d)}" != mpreboot ]; then
9		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.wants/openpower-debug-collector-checkstop@0.service"
10		TARGET="../openpower-debug-collector-checkstop@.service"
11		ln -s $TARGET $LINK
12	fi
13
14	LINK="$D$systemd_system_unitdir/obmc-host-timeout@0.target.wants/openpower-debug-collector-watchdog@0.service"
15	TARGET="../openpower-debug-collector-watchdog@.service"
16	ln -s $TARGET $LINK
17
18	if [ "${@bb.utils.filter('MACHINE_FEATURES', 'phal', d)}" != 'phal' ]; then
19		LINK="$D$systemd_system_unitdir/obmc-host-timeout@0.target.wants/openpower-debug-collector-watchdog-timeout@0.service"
20		TARGET="../openpower-debug-collector-watchdog-timeout@.service"
21		ln -s $TARGET $LINK
22	fi
23}
24
25pkg_prerm:${PN}:append() {
26	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'mpreboot', d)}" != mpreboot ]; then
27		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.wants/openpower-debug-collector-checkstop@0.service"
28		rm $LINK
29	fi
30	LINK="$D$systemd_system_unitdir/obmc-host-timeout@0.target.wants/openpower-debug-collector-watchdog@0.service"
31	rm $LINK
32	if [ "${@bb.utils.filter('MACHINE_FEATURES', 'phal', d)}" != 'phal' ]; then
33		LINK="$D$systemd_system_unitdir/obmc-host-timeout@0.target.wants/openpower-debug-collector-watchdog-timeout@0.service"
34		rm $LINK
35	fi
36}
37