blob: 516fc815f48a4f767f85f6fa022392b08d300687 [file] [log] [blame]
Brad Bishopb1e88402017-01-11 11:12:32 -05001SUMMARY = "OpenBMC hwmon poller"
2DESCRIPTION = "OpenBMC hwmon poller."
Brad Bishopb1e88402017-01-11 11:12:32 -05003LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
Brad Bishop6d105112017-02-20 14:36:31 -05005DEPENDS += " \
6 sdbusplus \
William A. Kennington III4e10c562018-10-18 19:23:49 -07007 sdeventplus \
Patrick Venture6e2600f2020-05-21 08:32:30 -07008 stdplus \
Brad Bishop6d105112017-02-20 14:36:31 -05009 phosphor-dbus-interfaces \
10 phosphor-logging \
Patrick Venturef67ce692018-09-14 09:54:18 -070011 gpioplus \
Patrick Venture806405f2019-03-11 14:06:11 -070012 cli11 \
Brad Bishop6d105112017-02-20 14:36:31 -050013 "
Ed Tanous9936f862022-09-19 09:13:20 -070014SRCREV = "5e5259bf6710f22d3b78667098e56fa0e4895160"
15PACKAGECONFIG ??= ""
16# Meson configure option to enable/disable max31785-msl
17PACKAGECONFIG[max31785-msl] = "-Denable-max31785-msl=true, -Denable-max31785-msl=false"
18PV = "1.0+git${SRCPV}"
19PR = "r1"
20
21SRC_URI += "git://github.com/openbmc/phosphor-hwmon;branch=master;protocol=https"
22
23SYSTEMD_PACKAGES = "${PN} max31785-msl"
24SYSTEMD_SERVICE:${PN} = "xyz.openbmc_project.Hwmon@.service"
25SYSTEMD_SERVICE:max31785-msl = "${@bb.utils.contains('PACKAGECONFIG', 'max31785-msl', 'phosphor-max31785-msl@.service', '', d)}"
26S = "${WORKDIR}/git"
27
28inherit pkgconfig meson
29inherit obmc-phosphor-systemd
Brad Bishop6d105112017-02-20 14:36:31 -050030
Patrick Williamsed104d42021-08-31 13:19:27 -050031EXTRA_OEMESON:append = " -Dtests=disabled"
William A. Kennington IIIcd01a3b2021-05-29 15:03:49 -070032
Patrick Williams12fc9392021-08-06 09:16:53 -050033RDEPENDS:${PN} += "\
Joel Stanley1c7e17d2017-09-05 17:44:33 +100034 bash \
Brad Bishopb1e88402017-01-11 11:12:32 -050035 "
Ed Tanous9936f862022-09-19 09:13:20 -070036RDEPENDS:max31785-msl = "${VIRTUAL-RUNTIME_base-utils} i2c-tools bash"
Brad Bishopb1e88402017-01-11 11:12:32 -050037
Patrick Williams12fc9392021-08-06 09:16:53 -050038RRECOMMENDS:${PN} += "${VIRTUAL-RUNTIME_phosphor-hwmon-config}"
Brad Bishop3217b272017-02-22 20:50:13 -050039
Ed Tanous9936f862022-09-19 09:13:20 -070040FILES:${PN} += "${base_libdir}/systemd/system/xyz.openbmc_project.Hwmon@.service"
Patrick Williams12fc9392021-08-06 09:16:53 -050041FILES:max31785-msl = "\
Anton D. Kachalov22e00252021-02-06 12:23:10 +010042 ${base_libdir}/systemd/system/phosphor-max31785-msl@.service \
43 ${bindir}/max31785-msl \
44 "
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020045
46# The following postinstall script iterate over hwmon env files:
47# 1. It adds HW_SENSOR_ID value if not set. The value being calculated
48# as sha256sum.
49# 2. For each hwmon the script generates busconfig ACLs.
Patrick Williams12fc9392021-08-06 09:16:53 -050050pkg_postinst:${PN}() {
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020051 hwmon_dir="$D/etc/default/obmc/hwmon"
Patrick Williams9aefc7b2021-10-04 17:26:22 -050052 dbus_dir="$D/${datadir}/dbus-1/system.d"
Anton D. Kachalov34521532021-05-11 15:35:09 +020053 if [ -n "$D" -a -d "${hwmon_dir}" ]; then
54 # Remove existing links and replace with actual copy of the file to prevent
55 # HW_SENSOR_ID variable override for different sensors' instances.
56 find "${hwmon_dir}" -type l -name \*.conf | while read f; do
57 path="$(readlink -f $f)"
58 rm -f "${f}"
59 cp "${path}" "${f}"
60 done
Anton D. Kachalov34521532021-05-11 15:35:09 +020061 find "${hwmon_dir}" -type f -name \*.conf | while read f; do
62 path="/${f##${hwmon_dir}/}"
63 path="${path%.conf}"
64 sensor_id="$(printf "%s" "${path}" | sha256sum | cut -d\ -f1)"
65 acl_file="${dbus_dir}/xyz.openbmc_project.Hwmon-${sensor_id}.conf"
Anton D. Kachalov34521532021-05-11 15:35:09 +020066 egrep -q '^HW_SENSOR_ID\s*=' "${f}" ||
67 printf "\n# Sensor id for %s\nHW_SENSOR_ID = \"%s\"\n" "${path}" "${sensor_id}" >> "${f}"
Anton D. Kachalov34521532021-05-11 15:35:09 +020068 # Extract HW_SENSOR_ID that could be either quoted or unquoted string.
69 sensor_id="$(sed -n 's,^HW_SENSOR_ID\s*=\s*"\?\(.[^" ]\+\)\s*"\?,\1,p' "${f}")"
Anton D. Kachalov34521532021-05-11 15:35:09 +020070 [ ! -f "${acl_file}" ] || continue
71 path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')"
Anton D. Kachalov34521532021-05-11 15:35:09 +020072 cat <<EOF>"${acl_file}"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020073<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
74 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
75<busconfig>
76 <policy user="root">
77 <!-- ${path_s} -->
78 <allow own="xyz.openbmc_project.Hwmon-${sensor_id}.Hwmon1"/>
79 <allow send_destination="xyz.openbmc_project.Hwmon-${sensor_id}.Hwmon1"/>
80 </policy>
81</busconfig>
82EOF
Anton D. Kachalov34521532021-05-11 15:35:09 +020083 done
84 fi
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020085}
Ed Tanous9936f862022-09-19 09:13:20 -070086
87PACKAGE_BEFORE_PN = "max31785-msl"