c19b496762c32b8a6997bd26df09d659a0f6f8b3
[pti/rtp.git] / meta-stx / recipes-core / stx-ha / sm.inc
1 #
2 ## Copyright (C) 2019 Wind River Systems, Inc.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15
16 PACKAGES += " sm"
17
18 RDEPENDS_sm += " \
19         bash \
20         python \
21         logrotate \
22         time \
23         systemd \
24         chkconfig \
25         mtce-pmon \
26         "
27
28 do_configure_append () {
29         # fix the hardcoded path
30         sed -i -e "s|/usr/local/sbin|${sbindir}|" \
31                 ${S}/service-mgmt/sm-common/src/sm_types.h \
32                 ${S}/service-mgmt/sm-common/src/sm_watchdog_nfs.c
33 }
34
35 do_compile_append() {
36         cd ${S}/service-mgmt/sm/src
37         oe_runmake -e -j1 VER=0 VER_MJR=1 \
38                 INCLUDES="-I. -I${S}/service-mgmt/sm-common/src \
39                         -I${S}/service-mgmt/sm-db/src $(pkg-config --cflags glib-2.0)" \
40                 EXTRACCFLAGS="-I. -I${S}/service-mgmt/sm-common/src \
41                         -I${S}/service-mgmt/sm-db/src $(pkg-config --cflags glib-2.0) \
42                         -L${S}/service-mgmt/sm-common/src -L${S}/service-mgmt/sm-db/src \
43                                 $(pkg-config --ldlags glib-2.0)" \
44                 CCFLAGS="${CXXFLAGS} -std=c++11" LDFLAGS="${LDFLAGS} -rdynamic"
45 }
46
47 do_install_append () {
48         cd ${S}/service-mgmt/sm/src
49         oe_runmake -e DEST_DIR=${D} BIN_DIR=${bindir} UNIT_DIR=${systemd_system_unitdir} \
50                 LIB_DIR=${libdir} INC_DIR=${includedir} VER=0 VER_MJR=1 install
51         cd ${S}/service-mgmt/sm/scripts
52
53         install -d ${D}/${sysconfdir}/init.d
54         install sm ${D}/${sysconfdir}/init.d/sm
55         install sm.shutdown ${D}/${sysconfdir}/init.d/sm-shutdown
56         install -d -m0755 ${D}/${sysconfdir}/pmon.d
57         install -m 644 sm.conf ${D}/${sysconfdir}/pmon.d/sm.conf
58         install -d ${D}/${sysconfdir}/logrotate.d
59         install -m 644 sm.logrotate ${D}/${sysconfdir}/logrotate.d/sm.logrotate
60         install -d -m 755 ${D}/${sbindir}
61         install sm.notify ${D}/${sbindir}/stx-ha-sm-notify
62         install sm.troubleshoot ${D}/${sbindir}/sm-troubleshoot
63         install sm.notification ${D}/${sbindir}/sm-notification
64         install -d $(D)${systemd_system_unitdir}
65         install -m 644 *.service ${D}/${systemd_system_unitdir}
66 }
67
68 FILES_sm = " \
69         ${bindir}/sm \
70         ${sysconfdir}/init.d/sm \
71         ${sysconfdir}/init.d/sm-shutdown \
72         ${sysconfdir}/pmon.d/sm.conf \
73         ${sysconfdir}/logrotate.d/sm.logrotate \
74         ${sbindir}/stx-ha-sm-notify \
75         ${sbindir}/sm-troubleshoot \
76         ${sbindir}/sm-notification \
77         ${systemd_system_unitdir}/sm-shutdown.service \
78         ${systemd_system_unitdir}/sm.service \
79         "
80
81 pkg_postinst_ontarget_sm_append () {
82         /usr/bin/update-alternatives --install /usr/sbin/sm-notify sm-notify /usr/sbin/stx-ha-sm-notify 5
83 }
84
85 SYSTEMD_PACKAGES += "sm"
86 SYSTEMD_SERVICE_sm = "sm.service sm-shutdown.service"
87 SYSTEMD_AUTO_ENABLE_sm = "enable"