blob: d85b58b48f57c2d269713395b31bfa045c473eee [file] [log] [blame]
Brad Bishopb1e88402017-01-11 11:12:32 -05001SUMMARY = "OpenBMC hwmon poller"
2DESCRIPTION = "OpenBMC hwmon poller."
3PR = "r1"
Patrick Venturebc174e62018-10-01 20:22:40 -07004PV = "1.0+git${SRCPV}"
Brad Bishopb1e88402017-01-11 11:12:32 -05005LICENSE = "Apache-2.0"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
7
Andrew Geisslerec34cc62021-11-03 09:57:52 -05008inherit pkgconfig meson
Patrick Venturebc174e62018-10-01 20:22:40 -07009inherit obmc-phosphor-systemd
Brad Bishop4186efb2017-01-11 15:30:07 -050010
Matthew Barth3afbeed2020-11-17 08:45:59 -060011PACKAGECONFIG ??= ""
Anton D. Kachalov22e00252021-02-06 12:23:10 +010012# Meson configure option to enable/disable max31785-msl
Matt Spinlerc15c7532021-04-14 14:52:53 -050013PACKAGECONFIG[max31785-msl] = "-Denable-max31785-msl=true, -Denable-max31785-msl=false"
Matthew Barth3afbeed2020-11-17 08:45:59 -060014
Brad Bishop4ce57192017-08-01 21:33:30 -040015PACKAGE_BEFORE_PN = "max31785-msl"
16SYSTEMD_PACKAGES = "${PN} max31785-msl"
17
Patrick Williams12fc9392021-08-06 09:16:53 -050018SYSTEMD_SERVICE:${PN} = "xyz.openbmc_project.Hwmon@.service"
19SYSTEMD_SERVICE:max31785-msl = "${@bb.utils.contains('PACKAGECONFIG', 'max31785-msl', 'phosphor-max31785-msl@.service', '', d)}"
Brad Bishopb1e88402017-01-11 11:12:32 -050020
Brad Bishop6d105112017-02-20 14:36:31 -050021DEPENDS += " \
22 sdbusplus \
William A. Kennington III4e10c562018-10-18 19:23:49 -070023 sdeventplus \
Patrick Venture6e2600f2020-05-21 08:32:30 -070024 stdplus \
Brad Bishop6d105112017-02-20 14:36:31 -050025 phosphor-dbus-interfaces \
26 phosphor-logging \
Patrick Venturef67ce692018-09-14 09:54:18 -070027 gpioplus \
Patrick Venture806405f2019-03-11 14:06:11 -070028 cli11 \
Brad Bishop6d105112017-02-20 14:36:31 -050029 "
30
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 -050033FILES:${PN} += "${base_libdir}/systemd/system/xyz.openbmc_project.Hwmon@.service"
34RDEPENDS:${PN} += "\
Joel Stanley1c7e17d2017-09-05 17:44:33 +100035 bash \
Brad Bishopb1e88402017-01-11 11:12:32 -050036 "
37
Patrick Williams12fc9392021-08-06 09:16:53 -050038RRECOMMENDS:${PN} += "${VIRTUAL-RUNTIME_phosphor-hwmon-config}"
Brad Bishop3217b272017-02-22 20:50:13 -050039
Patrick Williams12fc9392021-08-06 09:16:53 -050040FILES:max31785-msl = "\
Anton D. Kachalov22e00252021-02-06 12:23:10 +010041 ${base_libdir}/systemd/system/phosphor-max31785-msl@.service \
42 ${bindir}/max31785-msl \
43 "
Patrick Williams12fc9392021-08-06 09:16:53 -050044RDEPENDS:max31785-msl = "${VIRTUAL-RUNTIME_base-utils} i2c-tools bash"
Brad Bishop4ce57192017-08-01 21:33:30 -040045
Patrick Williamsbb99d222022-01-24 15:55:09 -060046SRC_URI += "git://github.com/openbmc/phosphor-hwmon;branch=master;protocol=https"
Brad Bishopb1e88402017-01-11 11:12:32 -050047
Andrew Geisslerd821f692021-11-06 17:51:07 +000048SRCREV = "b6c1771bfd4dcc4bc461878424b3f71b3bffdbca"
Brad Bishopb1e88402017-01-11 11:12:32 -050049
50S = "${WORKDIR}/git"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020051
52# The following postinstall script iterate over hwmon env files:
53# 1. It adds HW_SENSOR_ID value if not set. The value being calculated
54# as sha256sum.
55# 2. For each hwmon the script generates busconfig ACLs.
Patrick Williams12fc9392021-08-06 09:16:53 -050056pkg_postinst:${PN}() {
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020057 hwmon_dir="$D/etc/default/obmc/hwmon"
Patrick Williams9aefc7b2021-10-04 17:26:22 -050058 dbus_dir="$D/${datadir}/dbus-1/system.d"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020059
Anton D. Kachalov34521532021-05-11 15:35:09 +020060 if [ -n "$D" -a -d "${hwmon_dir}" ]; then
61 # Remove existing links and replace with actual copy of the file to prevent
62 # HW_SENSOR_ID variable override for different sensors' instances.
63 find "${hwmon_dir}" -type l -name \*.conf | while read f; do
64 path="$(readlink -f $f)"
65 rm -f "${f}"
66 cp "${path}" "${f}"
67 done
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020068
Anton D. Kachalov34521532021-05-11 15:35:09 +020069 find "${hwmon_dir}" -type f -name \*.conf | while read f; do
70 path="/${f##${hwmon_dir}/}"
71 path="${path%.conf}"
72 sensor_id="$(printf "%s" "${path}" | sha256sum | cut -d\ -f1)"
73 acl_file="${dbus_dir}/xyz.openbmc_project.Hwmon-${sensor_id}.conf"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020074
Anton D. Kachalov34521532021-05-11 15:35:09 +020075 egrep -q '^HW_SENSOR_ID\s*=' "${f}" ||
76 printf "\n# Sensor id for %s\nHW_SENSOR_ID = \"%s\"\n" "${path}" "${sensor_id}" >> "${f}"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020077
Anton D. Kachalov34521532021-05-11 15:35:09 +020078 # Extract HW_SENSOR_ID that could be either quoted or unquoted string.
79 sensor_id="$(sed -n 's,^HW_SENSOR_ID\s*=\s*"\?\(.[^" ]\+\)\s*"\?,\1,p' "${f}")"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020080
Anton D. Kachalov34521532021-05-11 15:35:09 +020081 [ ! -f "${acl_file}" ] || continue
82 path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020083
Anton D. Kachalov34521532021-05-11 15:35:09 +020084 cat <<EOF>"${acl_file}"
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020085<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
86 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
87<busconfig>
88 <policy user="root">
89 <!-- ${path_s} -->
90 <allow own="xyz.openbmc_project.Hwmon-${sensor_id}.Hwmon1"/>
91 <allow send_destination="xyz.openbmc_project.Hwmon-${sensor_id}.Hwmon1"/>
92 </policy>
93</busconfig>
94EOF
Anton D. Kachalov34521532021-05-11 15:35:09 +020095 done
96 fi
Anton D. Kachalovf0e06982021-05-05 14:54:13 +020097}