Provide option to always use device path
The application has the ability to use either the 'OF_FULLNAME' udev
environment variable or the udev device path as the path to the config
file, though it defaults to OF_FULLNAME if it's there.
The disadvantage of using OF_FULLNAME is that the file name then has to
match what someone manually typed into the device tree for the system,
for example mydevice@72.conf. The device path method, on the other
hand, has a file name that matches the stable I2C details, such as
7-0052.conf.
To force phosphor-hwmon to always use the device path for its config and
avoid being dependent on the device tree name, this commits adds a new
--always-use-devpath meson option.
When enabled, it add an '|| true' into the start_hwmon.sh script to
force it down the path to use the device path when starting the hwmon
service.
Tested:
When disabled, diffed start_hwmon.sh to that built from previous HEAD
and the files matched.
When enabled, start_hwmon.sh now has
```
if [ -z "${path}" ] || true
```
and app now uses device path for config file path.
Change-Id: I5a03ebb6e6e967bc663ec747941258173dfd3363
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meson.build b/meson.build
index 28d4b1b..804fbaa 100644
--- a/meson.build
+++ b/meson.build
@@ -114,10 +114,18 @@
install_dir: udev_dir / 'rules.d'
)
+force_devpath = ''
+if get_option('always-use-devpath').enabled()
+ force_devpath = ' || true'
+endif
+
configure_file(
input : 'start_hwmon.sh.in',
output : 'start_hwmon.sh',
- configuration: {'OVERRIDE_WITH_DEVPATH': ' '.join(get_option('override-with-devpath'))},
+ configuration: {
+ 'OVERRIDE_WITH_DEVPATH': ' '.join(get_option('override-with-devpath')),
+ 'FORCE_DEVPATH': force_devpath
+ },
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x',
install: true,
diff --git a/meson.options b/meson.options
index 5aa5729..8016a2f 100644
--- a/meson.options
+++ b/meson.options
@@ -32,3 +32,10 @@
type: 'array',
description: 'Only use the devpath of the device even if OFPath exists'
)
+
+option(
+ 'always-use-devpath',
+ type: 'feature',
+ value: 'disabled',
+ description: 'Only use the devpath for all devices.'
+)
diff --git a/start_hwmon.sh.in b/start_hwmon.sh.in
index c14a7da..cdf9d11 100755
--- a/start_hwmon.sh.in
+++ b/start_hwmon.sh.in
@@ -16,7 +16,7 @@
}
path=$of_fullname
-if [ -z "${path}" ]
+if [ -z "${path}" ]@FORCE_DEVPATH@
then
path="$(use_devpath)"
else