1SUMMARY = "Phosphor OpenBMC IPMI daemon"
2DESCRIPTION = "Phosphor OpenBMC IPMI router and plugin libraries"
3PR = "r1"
4PV = "1.0+git${SRCPV}"
5LICENSE = "Apache-2.0"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
7
8RRECOMMENDS:${PN} += "packagegroup-obmc-ipmid-providers-libs"
9
10inherit autotools pkgconfig
11inherit obmc-phosphor-ipmiprovider-symlink
12inherit obmc-phosphor-sdbus-service
13inherit obmc-phosphor-systemd
14inherit phosphor-ipmi-host
15inherit python3native
16
17def ipmi_whitelists(d):
18    whitelists = d.getVar(
19        'VIRTUAL-RUNTIME_phosphor-ipmi-providers', True) or ''
20    whitelists = whitelists.split()
21    whitelists = [ '{}-whitelist-native'.format(x) for x in whitelists ]
22    return ' '.join(whitelists)
23
24PACKAGECONFIG ??= ""
25PACKAGECONFIG[dynamic-sensors] = "--enable-dynamic-sensors,--disable-dynamic-sensors"
26PACKAGECONFIG[hybrid-sensors] = "--enable-hybrid-sensors,--disable-hybrid-sensors"
27
28DEPENDS += "autoconf-archive-native"
29DEPENDS += "nlohmann-json"
30DEPENDS += "phosphor-state-manager"
31DEPENDS += "${@ipmi_whitelists(d)}"
32DEPENDS += "phosphor-dbus-interfaces"
33DEPENDS += "phosphor-logging"
34DEPENDS += "phosphor-mapper"
35DEPENDS += "sdbusplus"
36DEPENDS += "${PYTHON_PN}-sdbus++-native"
37DEPENDS += "virtual/phosphor-ipmi-inventory-sel"
38DEPENDS += "virtual/phosphor-ipmi-fru-merge-config"
39DEPENDS += "virtual/phosphor-ipmi-sensor-inventory"
40DEPENDS += "boost"
41DEPENDS += "sdeventplus"
42DEPENDS += "${PYTHON_PN}-native"
43DEPENDS += "${PYTHON_PN}-pyyaml-native"
44DEPENDS += "${PYTHON_PN}-mako-native"
45
46VIRTUAL-RUNTIME_ipmi-config ?= "phosphor-ipmi-config"
47
48RDEPENDS:${PN}-dev += "phosphor-logging"
49RDEPENDS:${PN}-dev += "phosphor-mapper-dev"
50RDEPENDS:${PN} += "clear-once"
51RDEPENDS:${PN} += "phosphor-network"
52RDEPENDS:${PN} += "phosphor-time-manager"
53RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_ipmi-config}"
54RDEPENDS:${PN} += "virtual/obmc-watchdog"
55RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_obmc-bmc-state-manager}"
56RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_obmc-bmc-version}"
57RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_obmc-bmc-updater}"
58
59inherit useradd
60
61USERADD_PACKAGES = "${PN}"
62# add ipmi group
63GROUPADD_PARAM:${PN} = "ipmi"
64
65SYSTEMD_SERVICE:${PN} += "xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service phosphor-ipmi-host.service"
66
67RRECOMMENDS:${PN} += "phosphor-settings-manager"
68
69
70require ${BPN}.inc
71
72# Setup IPMI Whitelist Conf files
73WHITELIST_CONF = " \
74        ${STAGING_DATADIR_NATIVE}/phosphor-ipmi-host/*.conf \
75        ${S}/host-ipmid-whitelist.conf \
76        "
77EXTRA_OECONF = " \
78        SENSOR_YAML_GEN=${STAGING_DIR_NATIVE}${sensor_datadir}/sensor.yaml \
79        INVSENSOR_YAML_GEN=${STAGING_DIR_NATIVE}${sensor_datadir}/invsensor.yaml \
80        FRU_YAML_GEN=${STAGING_DIR_NATIVE}${config_datadir}/fru_config.yaml \
81        "
82EXTRA_OECONF:append = " \
83        WHITELIST_CONF="${WHITELIST_CONF}" \
84        "
85
86S = "${WORKDIR}/git"
87
88SRC_URI += "file://merge_yamls.py "
89
90HOSTIPMI_PROVIDER_LIBRARY += "libipmi20.so"
91HOSTIPMI_PROVIDER_LIBRARY += "libsysintfcmds.so"
92HOSTIPMI_PROVIDER_LIBRARY += "libusercmds.so"
93
94NETIPMI_PROVIDER_LIBRARY += "libipmi20.so"
95NETIPMI_PROVIDER_LIBRARY += "libusercmds.so"
96
97FILES:${PN}:append = " ${libdir}/host-ipmid/lib*${SOLIBS}"
98FILES:${PN}:append = " ${libdir}/ipmid-providers/lib*${SOLIBS}"
99FILES:${PN}:append = " ${libdir}/net-ipmid/lib*${SOLIBS}"
100FILES:${PN}-dev:append = " ${libdir}/ipmid-providers/lib*${SOLIBSDEV} ${libdir}/ipmid-providers/*.la"
101
102# Soft Power Off
103# install the soft power off service in the host shutdown target
104SOFT_SVC = "xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service"
105SOFT_TGTFMT = "obmc-host-shutdown@{0}.target"
106SOFT_FMT = "../${SOFT_SVC}:${SOFT_TGTFMT}.requires/${SOFT_SVC}"
107SYSTEMD_LINK:${PN} += "${@compose_list_zip(d, 'SOFT_FMT', 'OBMC_HOST_INSTANCES')}"
108
109#Collect all hardcoded sensor yamls from different recipes and
110#merge all of them with sensor.yaml.
111python do_merge_sensors () {
112    import subprocess
113
114    # TODO: Perform the merge in a temporary directory?
115    workdir = d.getVar('WORKDIR', True)
116    nativedir = d.getVar('STAGING_DIR_NATIVE', True)
117    sensorsdir = d.getVar('sensor_datadir', True)
118    sensorsdir = sensorsdir[1:]
119    sensorsdir = os.path.join(nativedir, sensorsdir)
120    cmd = []
121    cmd.append(os.path.join(workdir, 'merge_yamls.py'))
122    cmd.append(os.path.join(sensorsdir, 'sensor.yaml'))
123
124    if os.stat(os.path.join(sensorsdir, 'sensor.yaml')).st_size == 0:
125        return
126    fetch = bb.fetch2.Fetch([], d)
127    override_urls = [url for url in fetch.urls if url.endswith('.hardcoded.yaml')]
128    for url in override_urls:
129        bb.debug(2, 'Overriding with source: ' + url)
130        local_base = os.path.basename(fetch.localpath(url))
131        filename = os.path.join(workdir, local_base)
132        cmd.append(filename)
133
134    # Invoke the script and don't catch any resulting exception.
135    subprocess.check_call(cmd)
136}
137
138# python-pyyaml-native is installed by do_configure, so put this task after
139addtask merge_sensors after do_configure before do_compile
140