From 6610a5ca4b8f7480c33cb5798d82c45a3efc927d Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Wed, 6 Oct 2021 10:30:24 -0400 Subject: [PATCH] import lm_sensors-3.4.0-23.20180522git70f7e08.el8 --- .../lm_sensors-3.4.0-allow_no_sensors.patch | 92 +++++++++++++++++++ SOURCES/lm_sensors-wrapper | 8 ++ SOURCES/lm_sensors.service | 2 +- SPECS/lm_sensors.spec | 12 ++- 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 SOURCES/lm_sensors-3.4.0-allow_no_sensors.patch create mode 100644 SOURCES/lm_sensors-wrapper diff --git a/SOURCES/lm_sensors-3.4.0-allow_no_sensors.patch b/SOURCES/lm_sensors-3.4.0-allow_no_sensors.patch new file mode 100644 index 0000000..17d85f0 --- /dev/null +++ b/SOURCES/lm_sensors-3.4.0-allow_no_sensors.patch @@ -0,0 +1,92 @@ +diff --git a/prog/sensors/main.c b/prog/sensors/main.c +index f535b66..a19b919 100644 +--- a/prog/sensors/main.c ++++ b/prog/sensors/main.c +@@ -54,15 +54,16 @@ static void print_short_help(void) + static void print_long_help(void) + { + printf("Usage: %s [OPTION]... [CHIP]...\n", PROGRAM); +- puts(" -c, --config-file Specify a config file\n" +- " -h, --help Display this help text\n" +- " -s, --set Execute `set' statements (root only)\n" +- " -f, --fahrenheit Show temperatures in degrees fahrenheit\n" +- " -A, --no-adapter Do not show adapter for each chip\n" +- " --bus-list Generate bus statements for sensors.conf\n" +- " -u Raw output\n" +- " -j Json output\n" +- " -v, --version Display the program version\n" ++ puts(" -c, --config-file Specify a config file\n" ++ " -h, --help Display this help text\n" ++ " -s, --set Execute `set' statements (root only)\n" ++ " -f, --fahrenheit Show temperatures in degrees fahrenheit\n" ++ " -A, --no-adapter Do not show adapter for each chip\n" ++ " --bus-list Generate bus statements for sensors.conf\n" ++ " -u Raw output\n" ++ " -j Json output\n" ++ " -v, --version Display the program version\n" ++ " -n, --allow-no-sensors Do not fail if no sensors found\n" + "\n" + "Use `-' after `-c' to read the config file from stdin.\n" + "If no chips are specified, all chip info will be printed.\n" +@@ -270,7 +271,7 @@ static void print_bus_list(void) + + int main(int argc, char *argv[]) + { +- int c, i, err, do_bus_list; ++ int c, i, err, do_bus_list, allow_no_sensors; + const char *config_file_name = NULL; + + struct option long_opts[] = { +@@ -281,6 +282,7 @@ int main(int argc, char *argv[]) + { "no-adapter", no_argument, NULL, 'A' }, + { "config-file", required_argument, NULL, 'c' }, + { "bus-list", no_argument, NULL, 'B' }, ++ { "allow-no-sensors", no_argument, NULL, 'n' }, + { 0, 0, 0, 0 } + }; + +@@ -291,8 +293,9 @@ int main(int argc, char *argv[]) + do_sets = 0; + do_bus_list = 0; + hide_adapter = 0; ++ allow_no_sensors = 0; + while (1) { +- c = getopt_long(argc, argv, "hsvfAc:uj", long_opts, NULL); ++ c = getopt_long(argc, argv, "hsvfAc:ujn", long_opts, NULL); + if (c == EOF) + break; + switch(c) { +@@ -327,6 +330,9 @@ int main(int argc, char *argv[]) + case 'B': + do_bus_list = 1; + break; ++ case 'n': ++ allow_no_sensors = 1; ++ break; + default: + fprintf(stderr, + "Internal error while parsing options!\n"); +@@ -349,7 +355,9 @@ int main(int argc, char *argv[]) + "No sensors found!\n" + "Make sure you loaded all the kernel drivers you need.\n" + "Try sensors-detect to find out which these are.\n"); +- err = 1; ++ if (!allow_no_sensors) { ++ err = 1; ++ } + } + } else { + int cnt = 0; +diff --git a/prog/sensors/sensors.1 b/prog/sensors/sensors.1 +index 7d66e4b..d207aa1 100644 +--- a/prog/sensors/sensors.1 ++++ b/prog/sensors/sensors.1 +@@ -78,6 +78,8 @@ are only needed if you have several chips sharing the same address on different + buses of the same type. As bus numbers are usually not guaranteed to be stable + over reboots, these statements let you refer to each bus by its name rather + than numbers. ++.IP "-n, --allow-no-sensors" ++Do not fail if no sensors found. The error message will be printed in the log. + .SH FILES + .I /etc/sensors3.conf + .br diff --git a/SOURCES/lm_sensors-wrapper b/SOURCES/lm_sensors-wrapper new file mode 100644 index 0000000..8eb32a4 --- /dev/null +++ b/SOURCES/lm_sensors-wrapper @@ -0,0 +1,8 @@ +#!/bin/sh +if /usr/bin/systemd-detect-virt 2>/dev/null 1>&2; then + SENSORS_FLAGS_VM='-n'; +else + SENSORS_FLAGS_VM=''; +fi; + +/usr/bin/sensors -s $SENSORS_FLAGS_VM diff --git a/SOURCES/lm_sensors.service b/SOURCES/lm_sensors.service index 904660a..fc99241 100644 --- a/SOURCES/lm_sensors.service +++ b/SOURCES/lm_sensors.service @@ -6,7 +6,7 @@ EnvironmentFile=/etc/sysconfig/lm_sensors Type=oneshot RemainAfterExit=yes ExecStart=-@WRAPPER_DIR@/lm_sensors-modprobe-wrapper $BUS_MODULES $HWMON_MODULES -ExecStart=/usr/bin/sensors -s +ExecStart=@WRAPPER_DIR@/lm_sensors-wrapper ExecStop=-@WRAPPER_DIR@/lm_sensors-modprobe-r-wrapper $BUS_MODULES $HWMON_MODULES [Install] diff --git a/SPECS/lm_sensors.spec b/SPECS/lm_sensors.spec index 98998eb..b4523c3 100644 --- a/SPECS/lm_sensors.spec +++ b/SPECS/lm_sensors.spec @@ -7,7 +7,7 @@ Name: lm_sensors Version: 3.4.0 -Release: 22.%{date}git%{shortcommit}%{?dist} +Release: 23.%{date}git%{shortcommit}%{?dist} Summary: Hardware monitoring tools Group: Applications/System @@ -29,6 +29,7 @@ Source4: lm_sensors-modprobe-r-wrapper Source5: sensord.service Source6: sensord-service-wrapper Source7: lm_sensors.service +Source8: lm_sensors-wrapper # Upstream patch: Patch1: 0001-sensors-detect-Add-detection-of-AMD-Family-17h-model.patch @@ -42,6 +43,8 @@ Patch3: 0001-sensors-detect-Fix-printing-CPU-info-on-ppc-and-arm.patch Patch4: fix-unexpanded-revision-strings.patch # Upstream commit 5deee7d0c301df779: Patch5: 0001-sensors-detect-Add-support-for-AMD-CPU-Family-19h.patch +# Upstream commit a0ef84f6583dbf427ff5a3534528e1e72bd00137: +Patch6: lm_sensors-3.4.0-allow_no_sensors.patch Requires: /usr/sbin/modprobe %ifarch %{ix86} x86_64 @@ -102,6 +105,7 @@ database, and warns of sensor alarms. %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 # Remove currently unused files to make sure we've got the license right rm -f prog/init/sysconfig-lm_sensors-convert prog/hotplug/unhide_ICH_SMBus @@ -144,6 +148,7 @@ install -pm 644 sensord.service $RPM_BUILD_ROOT%{_unitdir} mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/%{name} install -pm 755 %{SOURCE3} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/lm_sensors-modprobe-wrapper install -pm 755 %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/lm_sensors-modprobe-r-wrapper +install -pm 755 %{SOURCE8} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/lm_sensors-wrapper # sensord service wrapper install -pm 755 %{SOURCE6} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/sensord-service-wrapper @@ -201,6 +206,7 @@ fi %{_unitdir}/fancontrol.service %dir %{_libexecdir}/%{name} %{_libexecdir}/%{name}/lm_sensors-modprobe*wrapper +%{_libexecdir}/%{name}/lm_sensors-wrapper %exclude %{_sbindir}/sensord %exclude %{_mandir}/man8/sensord.8.gz @@ -223,6 +229,10 @@ fi %changelog +* Thu Feb 25 2021 Artem Egorenkov - 3.4.0-23 +- New flag for no sensors added. This flag is used in VM environment + to make sensors binaries not fail if no sensors was detected. + * Fri Oct 30 2020 Artem Egorenkov - 3.4.0-22.20180522git70f7e08 - Add support for AMD CPU Family 19h - Resolves: rhbz#1846847