Add initial meta-stx to support StarlingX build
[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 #       aaa_base
28
29 do_configure_append () {
30         :
31 }
32
33 do_compile_append() {
34         cd ${S}/service-mgmt/sm/src
35         oe_runmake -e -j1 VER=0 VER_MJR=1 \
36                 INCLUDES="-I. -I${S}/service-mgmt/sm-common/src \
37                         -I${S}/service-mgmt/sm-db/src $(pkg-config --cflags glib-2.0)" \
38                 EXTRACCFLAGS="-I. -I${S}/service-mgmt/sm-common/src \
39                         -I${S}/service-mgmt/sm-db/src $(pkg-config --cflags glib-2.0) \
40                         -L${S}/service-mgmt/sm-common/src -L${S}/service-mgmt/sm-db/src \
41                                 $(pkg-config --ldlags glib-2.0)" \
42                 CCFLAGS="${CXXFLAGS} -std=c++11" LDFLAGS="${LDFLAGS} -rdynamic"
43 }
44
45 do_install_append () {
46         cd ${S}/service-mgmt/sm/src
47         oe_runmake -e DEST_DIR=${D} BIN_DIR=${bindir} UNIT_DIR=${systemd_system_unitdir} \
48                 LIB_DIR=${libdir} INC_DIR=${includedir} VER=0 VER_MJR=1 install
49         cd ${S}/service-mgmt/sm/scripts
50
51         install -d ${D}/${sysconfdir}/init.d
52         install sm ${D}/${sysconfdir}/init.d/sm
53         install sm.shutdown ${D}/${sysconfdir}/init.d/sm-shutdown
54         install -d -m0755 ${D}/${sysconfdir}/pmon.d
55         install -m 644 sm.conf ${D}/${sysconfdir}/pmon.d/sm.conf
56         install -d ${D}/${sysconfdir}/logrotate.d
57         install -m 644 sm.logrotate ${D}/${sysconfdir}/logrotate.d/sm.logrotate
58         install -d -m 755 ${D}/${sbindir}
59         install sm.notify ${D}/${sbindir}/stx-ha-sm-notify
60         install sm.troubleshoot ${D}/${sbindir}/sm-troubleshoot
61         install sm.notification ${D}/${sbindir}/sm-notification
62         install -d $(D)${systemd_system_unitdir}
63         install -m 644 *.service ${D}/${systemd_system_unitdir}
64 }
65
66 FILES_sm = " \
67         ${bindir}/sm \
68         ${sysconfdir}/init.d/sm \
69         ${sysconfdir}/init.d/sm-shutdown \
70         ${sysconfdir}/pmon.d/sm.conf \
71         ${sysconfdir}/logrotate.d/sm.logrotate \
72         ${sbindir}/stx-ha-sm-notify \
73         ${sbindir}/sm-troubleshoot \
74         ${sbindir}/sm-notification \
75         ${systemd_system_unitdir}/sm-shutdown.service \
76         ${systemd_system_unitdir}/sm.service \
77         "
78
79 pkg_postinst_ontarget_sm_append () {
80         /usr/bin/update-alternatives --install /usr/sbin/sm-notify sm-notify /usr/sbin/stx-ha-sm-notify 5
81 }
82
83 SYSTEMD_PACKAGES += "sm"
84 SYSTEMD_SERVICE_sm = "sm.service sm-shutdown.service"
85 SYSTEMD_AUTO_ENABLE_sm = "enable"