Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 1 | SUMMARY = "OpenBMC hwmon poller" |
| 2 | DESCRIPTION = "OpenBMC hwmon poller." |
| 3 | PR = "r1" |
Patrick Venture | bc174e6 | 2018-10-01 20:22:40 -0700 | [diff] [blame] | 4 | PV = "1.0+git${SRCPV}" |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 5 | LICENSE = "Apache-2.0" |
| 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc" |
| 7 | |
Anton D. Kachalov | 22e0025 | 2021-02-06 12:23:10 +0100 | [diff] [blame] | 8 | inherit meson |
Patrick Venture | bc174e6 | 2018-10-01 20:22:40 -0700 | [diff] [blame] | 9 | inherit obmc-phosphor-systemd |
Brad Bishop | 4186efb | 2017-01-11 15:30:07 -0500 | [diff] [blame] | 10 | |
Matthew Barth | 3afbeed | 2020-11-17 08:45:59 -0600 | [diff] [blame] | 11 | PACKAGECONFIG ??= "" |
Anton D. Kachalov | 22e0025 | 2021-02-06 12:23:10 +0100 | [diff] [blame] | 12 | # Meson configure option to enable/disable max31785-msl |
Matt Spinler | c15c753 | 2021-04-14 14:52:53 -0500 | [diff] [blame] | 13 | PACKAGECONFIG[max31785-msl] = "-Denable-max31785-msl=true, -Denable-max31785-msl=false" |
Matthew Barth | 3afbeed | 2020-11-17 08:45:59 -0600 | [diff] [blame] | 14 | |
Brad Bishop | 4ce5719 | 2017-08-01 21:33:30 -0400 | [diff] [blame] | 15 | PACKAGE_BEFORE_PN = "max31785-msl" |
| 16 | SYSTEMD_PACKAGES = "${PN} max31785-msl" |
| 17 | |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 18 | SYSTEMD_SERVICE:${PN} = "xyz.openbmc_project.Hwmon@.service" |
| 19 | SYSTEMD_SERVICE:max31785-msl = "${@bb.utils.contains('PACKAGECONFIG', 'max31785-msl', 'phosphor-max31785-msl@.service', '', d)}" |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 20 | |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 21 | DEPENDS += " \ |
| 22 | sdbusplus \ |
William A. Kennington III | 4e10c56 | 2018-10-18 19:23:49 -0700 | [diff] [blame] | 23 | sdeventplus \ |
Patrick Venture | 6e2600f | 2020-05-21 08:32:30 -0700 | [diff] [blame] | 24 | stdplus \ |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 25 | phosphor-dbus-interfaces \ |
| 26 | phosphor-logging \ |
Patrick Venture | f67ce69 | 2018-09-14 09:54:18 -0700 | [diff] [blame] | 27 | gpioplus \ |
Patrick Venture | 806405f | 2019-03-11 14:06:11 -0700 | [diff] [blame] | 28 | cli11 \ |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 29 | " |
| 30 | |
Patrick Williams | ed104d4 | 2021-08-31 13:19:27 -0500 | [diff] [blame] | 31 | EXTRA_OEMESON:append = " -Dtests=disabled" |
William A. Kennington III | cd01a3b | 2021-05-29 15:03:49 -0700 | [diff] [blame] | 32 | |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 33 | FILES:${PN} += "${base_libdir}/systemd/system/xyz.openbmc_project.Hwmon@.service" |
| 34 | RDEPENDS:${PN} += "\ |
Joel Stanley | 1c7e17d | 2017-09-05 17:44:33 +1000 | [diff] [blame] | 35 | bash \ |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 36 | " |
| 37 | |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 38 | RRECOMMENDS:${PN} += "${VIRTUAL-RUNTIME_phosphor-hwmon-config}" |
Brad Bishop | 3217b27 | 2017-02-22 20:50:13 -0500 | [diff] [blame] | 39 | |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 40 | FILES:max31785-msl = "\ |
Anton D. Kachalov | 22e0025 | 2021-02-06 12:23:10 +0100 | [diff] [blame] | 41 | ${base_libdir}/systemd/system/phosphor-max31785-msl@.service \ |
| 42 | ${bindir}/max31785-msl \ |
| 43 | " |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 44 | RDEPENDS:max31785-msl = "${VIRTUAL-RUNTIME_base-utils} i2c-tools bash" |
Brad Bishop | 4ce5719 | 2017-08-01 21:33:30 -0400 | [diff] [blame] | 45 | |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 46 | SRC_URI += "git://github.com/openbmc/phosphor-hwmon" |
| 47 | |
Andrew Geissler | 9ff7193 | 2021-10-06 21:32:08 +0000 | [diff] [blame] | 48 | SRCREV = "3a816147e3e1e1196e7da61b26ccbd01fdbbf6c2" |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 49 | |
| 50 | S = "${WORKDIR}/git" |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 51 | |
| 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 Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 56 | pkg_postinst:${PN}() { |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 57 | hwmon_dir="$D/etc/default/obmc/hwmon" |
Patrick Williams | 9aefc7b | 2021-10-04 17:26:22 -0500 | [diff] [blame] | 58 | dbus_dir="$D/${datadir}/dbus-1/system.d" |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 59 | |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 60 | 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. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 68 | |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 69 | 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. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 74 | |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 75 | 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. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 77 | |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 78 | # 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. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 80 | |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 81 | [ ! -f "${acl_file}" ] || continue |
| 82 | path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')" |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 83 | |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 84 | cat <<EOF>"${acl_file}" |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 85 | <!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> |
| 94 | EOF |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 95 | done |
| 96 | fi |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 97 | } |