diff options
Diffstat (limited to 'meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb')
-rw-r--r-- | meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb b/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb index 4e90977b4..0d163c164 100644 --- a/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb +++ b/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb @@ -5,10 +5,11 @@ PV = "1.0+git${SRCPV}" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc" -inherit meson pkgconfig +inherit meson inherit obmc-phosphor-systemd PACKAGECONFIG ??= "" +# Meson configure option to enable/disable max31785-msl PACKAGECONFIG[max31785-msl] = "-Denable-max31785-msl=true, -Denable-max31785-msl=false" PACKAGE_BEFORE_PN = "max31785-msl" @@ -17,7 +18,6 @@ SYSTEMD_PACKAGES = "${PN} max31785-msl" SYSTEMD_SERVICE_${PN} = "xyz.openbmc_project.Hwmon@.service" SYSTEMD_SERVICE_max31785-msl = "${@bb.utils.contains('PACKAGECONFIG', 'max31785-msl', 'phosphor-max31785-msl@.service', '', d)}" -DEPENDS += "autoconf-archive-native" DEPENDS += " \ sdbusplus \ sdeventplus \ @@ -28,31 +28,68 @@ DEPENDS += " \ cli11 \ " - +FILES_${PN} += "${base_libdir}/systemd/system/xyz.openbmc_project.Hwmon@.service" RDEPENDS_${PN} += "\ bash \ " RRECOMMENDS_${PN} += "${VIRTUAL-RUNTIME_phosphor-hwmon-config}" -FILES_max31785-msl = "${bindir}/max31785-msl" +FILES_max31785-msl = "\ + ${base_libdir}/systemd/system/phosphor-max31785-msl@.service \ + ${bindir}/max31785-msl \ + " RDEPENDS_max31785-msl = "${VIRTUAL-RUNTIME_base-utils} i2c-tools bash" SRC_URI += "git://github.com/openbmc/phosphor-hwmon" -SRC_URI += "file://70-hwmon.rules" -SRC_URI += "file://70-iio.rules" -SRC_URI += "file://start_hwmon.sh" -SRCREV = "73769099e215de68fbb6c82664eb682cacce9f56" +SRCREV = "e32ce16bb6cc527b2e46b6e90ef7ac47404da173" S = "${WORKDIR}/git" -do_install_append() { +# The following postinstall script iterate over hwmon env files: +# 1. It adds HW_SENSOR_ID value if not set. The value being calculated +# as sha256sum. +# 2. For each hwmon the script generates busconfig ACLs. +pkg_postinst_${PN}() { + hwmon_dir="$D/etc/default/obmc/hwmon" + dbus_dir="$D/etc/dbus-1/system.d" + + if [ -n "$D" -a -d "${hwmon_dir}" ]; then + # Remove existing links and replace with actual copy of the file to prevent + # HW_SENSOR_ID variable override for different sensors' instances. + find "${hwmon_dir}" -type l -name \*.conf | while read f; do + path="$(readlink -f $f)" + rm -f "${f}" + cp "${path}" "${f}" + done + + find "${hwmon_dir}" -type f -name \*.conf | while read f; do + path="/${f##${hwmon_dir}/}" + path="${path%.conf}" + sensor_id="$(printf "%s" "${path}" | sha256sum | cut -d\ -f1)" + acl_file="${dbus_dir}/xyz.openbmc_project.Hwmon-${sensor_id}.conf" + + egrep -q '^HW_SENSOR_ID\s*=' "${f}" || + printf "\n# Sensor id for %s\nHW_SENSOR_ID = \"%s\"\n" "${path}" "${sensor_id}" >> "${f}" + + # Extract HW_SENSOR_ID that could be either quoted or unquoted string. + sensor_id="$(sed -n 's,^HW_SENSOR_ID\s*=\s*"\?\(.[^" ]\+\)\s*"\?,\1,p' "${f}")" - install -d ${D}/${base_libdir}/udev/rules.d/ - install -m 0644 ${WORKDIR}/70-hwmon.rules ${D}/${base_libdir}/udev/rules.d/ - install -m 0644 ${WORKDIR}/70-iio.rules ${D}/${base_libdir}/udev/rules.d/ + [ ! -f "${acl_file}" ] || continue + path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')" - install -d ${D}${bindir} - install -m 0755 ${WORKDIR}/start_hwmon.sh ${D}${bindir} + cat <<EOF>"${acl_file}" +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <policy user="root"> + <!-- ${path_s} --> + <allow own="xyz.openbmc_project.Hwmon-${sensor_id}.Hwmon1"/> + <allow send_destination="xyz.openbmc_project.Hwmon-${sensor_id}.Hwmon1"/> + </policy> +</busconfig> +EOF + done + fi } |