Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 1 | SUMMARY = "OpenBMC hwmon poller" |
| 2 | DESCRIPTION = "OpenBMC hwmon poller." |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 3 | LICENSE = "Apache-2.0" |
| 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc" |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 5 | DEPENDS += " \ |
| 6 | sdbusplus \ |
William A. Kennington III | 4e10c56 | 2018-10-18 19:23:49 -0700 | [diff] [blame] | 7 | sdeventplus \ |
Patrick Venture | 6e2600f | 2020-05-21 08:32:30 -0700 | [diff] [blame] | 8 | stdplus \ |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 9 | phosphor-dbus-interfaces \ |
| 10 | phosphor-logging \ |
Patrick Venture | f67ce69 | 2018-09-14 09:54:18 -0700 | [diff] [blame] | 11 | gpioplus \ |
Patrick Venture | 806405f | 2019-03-11 14:06:11 -0700 | [diff] [blame] | 12 | cli11 \ |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 13 | " |
Andrew Geissler | 00a8ebf | 2022-12-08 17:20:29 -0600 | [diff] [blame] | 14 | SRCREV = "46a29b7f21c03fbe7230abc6feff3991efd9f76b" |
Ed Tanous | 9936f86 | 2022-09-19 09:13:20 -0700 | [diff] [blame] | 15 | PACKAGECONFIG ??= "" |
| 16 | # Meson configure option to enable/disable max31785-msl |
| 17 | PACKAGECONFIG[max31785-msl] = "-Denable-max31785-msl=true, -Denable-max31785-msl=false" |
| 18 | PV = "1.0+git${SRCPV}" |
| 19 | PR = "r1" |
| 20 | |
| 21 | SRC_URI += "git://github.com/openbmc/phosphor-hwmon;branch=master;protocol=https" |
| 22 | |
| 23 | SYSTEMD_PACKAGES = "${PN} max31785-msl" |
| 24 | SYSTEMD_SERVICE:${PN} = "xyz.openbmc_project.Hwmon@.service" |
| 25 | SYSTEMD_SERVICE:max31785-msl = "${@bb.utils.contains('PACKAGECONFIG', 'max31785-msl', 'phosphor-max31785-msl@.service', '', d)}" |
| 26 | S = "${WORKDIR}/git" |
| 27 | |
| 28 | inherit pkgconfig meson |
| 29 | inherit obmc-phosphor-systemd |
Brad Bishop | 6d10511 | 2017-02-20 14:36:31 -0500 | [diff] [blame] | 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 | RDEPENDS:${PN} += "\ |
Joel Stanley | 1c7e17d | 2017-09-05 17:44:33 +1000 | [diff] [blame] | 34 | bash \ |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 35 | " |
Ed Tanous | 9936f86 | 2022-09-19 09:13:20 -0700 | [diff] [blame] | 36 | RDEPENDS:max31785-msl = "${VIRTUAL-RUNTIME_base-utils} i2c-tools bash" |
Brad Bishop | b1e8840 | 2017-01-11 11:12:32 -0500 | [diff] [blame] | 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 | |
Ed Tanous | 9936f86 | 2022-09-19 09:13:20 -0700 | [diff] [blame] | 40 | FILES:${PN} += "${base_libdir}/systemd/system/xyz.openbmc_project.Hwmon@.service" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 41 | FILES:max31785-msl = "\ |
Anton D. Kachalov | 22e0025 | 2021-02-06 12:23:10 +0100 | [diff] [blame] | 42 | ${base_libdir}/systemd/system/phosphor-max31785-msl@.service \ |
| 43 | ${bindir}/max31785-msl \ |
| 44 | " |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 45 | |
| 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 Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 50 | pkg_postinst:${PN}() { |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 51 | hwmon_dir="$D/etc/default/obmc/hwmon" |
Patrick Williams | 9aefc7b | 2021-10-04 17:26:22 -0500 | [diff] [blame] | 52 | dbus_dir="$D/${datadir}/dbus-1/system.d" |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 53 | 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. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 61 | 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. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 66 | 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. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 68 | # 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. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 70 | [ ! -f "${acl_file}" ] || continue |
| 71 | path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')" |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 72 | cat <<EOF>"${acl_file}" |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 73 | <!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> |
| 82 | EOF |
Anton D. Kachalov | 3452153 | 2021-05-11 15:35:09 +0200 | [diff] [blame] | 83 | done |
| 84 | fi |
Anton D. Kachalov | f0e0698 | 2021-05-05 14:54:13 +0200 | [diff] [blame] | 85 | } |
Ed Tanous | 9936f86 | 2022-09-19 09:13:20 -0700 | [diff] [blame] | 86 | |
| 87 | PACKAGE_BEFORE_PN = "max31785-msl" |