diff options
author | Anton D. Kachalov <gmouse@google.com> | 2021-05-11 16:35:09 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2021-05-12 16:47:43 +0300 |
commit | 3452153a6e93bab2536c9665b817588ff7b33b8e (patch) | |
tree | 4708725cc18fab95349063ebce63179cdda887ca /meta-phosphor/recipes-phosphor | |
parent | 3a60b152fd8b38e3095b90ca16dbe78526f242e7 (diff) | |
download | openbmc-3452153a6e93bab2536c9665b817588ff7b33b8e.tar.xz |
phosphor-hwmon: conditionally run generator function
The pkg_postinst is not running as a separate function.
To allow "_append" routines do conditional checks instead of "exit".
Signed-off-by: Anton D. Kachalov <gmouse@google.com>
Change-Id: Ia82ce0a2454198035b6ae7585bb04885d8e1e238
Diffstat (limited to 'meta-phosphor/recipes-phosphor')
-rw-r--r-- | meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb b/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb index 8daeb91f3..793217551 100644 --- a/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb +++ b/meta-phosphor/recipes-phosphor/sensors/phosphor-hwmon_git.bb @@ -52,36 +52,34 @@ S = "${WORKDIR}/git" # as sha256sum. # 2. For each hwmon the script generates busconfig ACLs. pkg_postinst_${PN}() { - [ -n "$D" ] || return 0 - hwmon_dir="$D/etc/default/obmc/hwmon" dbus_dir="$D/etc/dbus-1/system.d" - [ -d "${hwmon_dir}" ] || return 0 + 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 - # 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" - 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}" - 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}")" - # 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}")" + [ ! -f "${acl_file}" ] || continue + path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')" - [ ! -f "${acl_file}" ] || continue - path_s="$(echo "${path}" | sed 's,\-\-,\\-\\-,g')" - cat <<EOF>"${acl_file}" + 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> @@ -92,5 +90,6 @@ pkg_postinst_${PN}() { </policy> </busconfig> EOF - done + done + fi } |