From 3b83433a9e5ea8e2b556981d171b03bb49f903f1 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 24 Apr 2011 16:14:15 +0200 Subject: [PATCH] Fix sensors-detect with the udevdb now living under /run (#697565) Provide a native systemd service file (#692159) Drop systemv initscript Drop configuration conversion scripts, the last Fedora with lm_sensors-2.x was Fedora 8 ! --- lm_sensors-3.0.3-acpi-bus.patch | 64 ------------------------- lm_sensors-3.3.0-systemd.patch | 60 +++++++++++++++++++++++ lm_sensors.spec | 85 +++++++++++---------------------- 3 files changed, 88 insertions(+), 121 deletions(-) delete mode 100644 lm_sensors-3.0.3-acpi-bus.patch create mode 100644 lm_sensors-3.3.0-systemd.patch diff --git a/lm_sensors-3.0.3-acpi-bus.patch b/lm_sensors-3.0.3-acpi-bus.patch deleted file mode 100644 index dbbe7bb..0000000 --- a/lm_sensors-3.0.3-acpi-bus.patch +++ /dev/null @@ -1,64 +0,0 @@ -Index: lib/access.c -=================================================================== ---- lib/access.c (revision 5577) -+++ lib/access.c (working copy) -@@ -349,6 +349,8 @@ - return "SPI adapter"; - case SENSORS_BUS_TYPE_VIRTUAL: - return "Virtual device"; -+ case SENSORS_BUS_TYPE_ACPI: -+ return "ACPI interface"; - } - - /* bus types with several instances */ -Index: lib/sensors.h -=================================================================== ---- lib/sensors.h (revision 5577) -+++ lib/sensors.h (working copy) -@@ -42,6 +42,7 @@ - #define SENSORS_BUS_TYPE_PCI 2 - #define SENSORS_BUS_TYPE_SPI 3 - #define SENSORS_BUS_TYPE_VIRTUAL 4 -+#define SENSORS_BUS_TYPE_ACPI 5 - #define SENSORS_BUS_NR_ANY (-1) - #define SENSORS_BUS_NR_IGNORE (-2) - -Index: lib/sysfs.c -=================================================================== ---- lib/sysfs.c (revision 5577) -+++ lib/sysfs.c (working copy) -@@ -596,6 +596,11 @@ - entry.chip.addr = 0; - entry.chip.bus.type = SENSORS_BUS_TYPE_ISA; - entry.chip.bus.nr = 0; -+ } else if (subsys && !strcmp(subsys, "acpi")) { -+ entry.chip.bus.type = SENSORS_BUS_TYPE_ACPI; -+ /* For now we assume that acpi devices are unique */ -+ entry.chip.bus.nr = 0; -+ entry.chip.addr = 0; - } else { - /* Ignore unknown device */ - err = 0; -Index: lib/data.c -=================================================================== ---- lib/data.c (revision 5577) -+++ lib/data.c (working copy) -@@ -111,6 +111,8 @@ - res->bus.type = SENSORS_BUS_TYPE_SPI; - else if (!strncmp(name, "virtual", dash - name)) - res->bus.type = SENSORS_BUS_TYPE_VIRTUAL; -+ else if (!strncmp(name, "acpi", dash - name)) -+ res->bus.type = SENSORS_BUS_TYPE_ACPI; - else - goto ERROR; - name = dash + 1; -@@ -174,6 +176,9 @@ - case SENSORS_BUS_TYPE_VIRTUAL: - return snprintf(str, size, "%s-virtual-%x", chip->prefix, - chip->addr); -+ case SENSORS_BUS_TYPE_ACPI: -+ return snprintf(str, size, "%s-acpi-%x", chip->prefix, -+ chip->addr); - } - - return -SENSORS_ERR_CHIP_NAME; diff --git a/lm_sensors-3.3.0-systemd.patch b/lm_sensors-3.3.0-systemd.patch new file mode 100644 index 0000000..538eef0 --- /dev/null +++ b/lm_sensors-3.3.0-systemd.patch @@ -0,0 +1,60 @@ +Index: prog/init/lm_sensors.service +=================================================================== +--- prog/init/lm_sensors.service (revision 0) ++++ prog/init/lm_sensors.service (revision 0) +@@ -0,0 +1,14 @@ ++[Unit] ++Description=lm_sensors for monitoring motherboard sensor values ++After=syslog.target ++ ++[Service] ++EnvironmentFile=/etc/sysconfig/lm_sensors ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=-/sbin/modprobe -qab $BUS_MODULES $HWMON_MODULES ++ExecStart=/usr/bin/sensors -s ++ExecStop=-/sbin/modprobe -qabr $BUS_MODULES $HWMON_MODULES ++ ++[Install] ++WantedBy=multi-user.target +Index: prog/detect/sensors-detect +=================================================================== +--- prog/detect/sensors-detect (revision 5939) ++++ prog/detect/sensors-detect (working copy) +@@ -2339,7 +2339,7 @@ + if (!$use_udev) { + # Try some known default udev db locations, just in case + if (-e '/dev/.udev.tdb' || -e '/dev/.udev' +- || -e '/dev/.udevdb') { ++ || -e '/dev/.udevdb' || -e '/run/udev') { + $use_udev = 1; + $dev_i2c = '/dev/i2c-'; + } +@@ -6378,6 +6378,14 @@ + } + close(SYSCONFIG); + ++ if (-x "/bin/systemctl" && ++ -f "/lib/systemd/system/lm_sensors.service") { ++ system("/bin/systemctl", "enable", "lm_sensors.service"); ++ system("/bin/systemctl", "start", "lm_sensors.service"); ++ # All done, don't check for /etc/init.d/lm_sensors ++ return; ++ } ++ + print "Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors\n". + "for initialization at boot time.\n" + unless -f "/etc/init.d/lm_sensors"; +@@ -6433,8 +6441,10 @@ + exit -1; + } + +- if (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" && +- -f "/var/lock/subsys/lm_sensors") { ++ if (-x "/bin/systemctl" && -f "/lib/systemd/system/lm_sensors.service") { ++ system("/bin/systemctl", "stop", "lm_sensors.service"); ++ } elsif (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" && ++ -f "/var/lock/subsys/lm_sensors") { + system("/sbin/service", "lm_sensors", "stop"); + } + diff --git a/lm_sensors.spec b/lm_sensors.spec index 67b5523..dc97831 100644 --- a/lm_sensors.spec +++ b/lm_sensors.spec @@ -1,27 +1,23 @@ Name: lm_sensors Version: 3.3.0 -Release: 1%{?dist} +Release: 2%{?dist} URL: http://www.lm-sensors.org/ Source: http://dl.lm-sensors.org/lm-sensors/releases/%{name}-%{version}.tar.bz2 -#Source: %{name}-%{version}.svn5857.tar.gz Source1: lm_sensors.sysconfig # these 2 were taken from PLD-linux, Thanks! Source2: sensord.sysconfig Source3: sensord.init +Patch0: lm_sensors-3.3.0-systemd.patch Summary: Hardware monitoring tools Group: Applications/System -License: LGPLv2.1 -Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +License: LGPLv2+ %ifarch %{ix86} x86_64 Requires: /usr/sbin/dmidecode %endif -Requires(preun): chkconfig -Requires(post): chkconfig -Requires(post): /sbin/ldconfig +Requires(post): systemd-units BuildRequires: kernel-headers >= 2.2.16, bison, libsysfs-devel, flex, gawk BuildRequires: rrdtool-devel - %description The lm_sensors package includes a collection of modules for general SMBus access and hardware monitoring. @@ -57,6 +53,7 @@ database, and warns of sensor alarms. %prep %setup -q +%patch0 -p0 mv prog/init/README prog/init/README.initscripts chmod -x prog/init/fancontrol.init @@ -69,7 +66,6 @@ make PREFIX=%{_prefix} LIBDIR=%{_libdir} MANDIR=%{_mandir} EXLDFLAGS= \ %install -rm -fr $RPM_BUILD_ROOT make PREFIX=%{_prefix} LIBDIR=%{_libdir} MANDIR=%{_mandir} PROG_EXTRA=sensord \ DESTDIR=$RPM_BUILD_ROOT user_install rm $RPM_BUILD_ROOT%{_libdir}/libsensors.a @@ -77,64 +73,33 @@ rm $RPM_BUILD_ROOT%{_libdir}/libsensors.a ln -s sensors.conf.5.gz $RPM_BUILD_ROOT%{_mandir}/man5/sensors3.conf.5.gz mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sensors.d +mkdir -p $RPM_BUILD_ROOT%{_initrddir} +mkdir -p $RPM_BUILD_ROOT/lib/systemd/system install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/lm_sensors install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/sensord -install -p -m 755 prog/init/sysconfig-lm_sensors-convert \ - $RPM_BUILD_ROOT%{_bindir} -mkdir -p $RPM_BUILD_ROOT%{_initrddir} -install -p -m 755 prog/init/lm_sensors.init \ - $RPM_BUILD_ROOT%{_initrddir}/lm_sensors install -p -m 755 %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/sensord - -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sensors.d - -%clean -rm -fr $RPM_BUILD_ROOT +install -p -m 644 prog/init/lm_sensors.service \ + $RPM_BUILD_ROOT/lib/systemd/system -# For conversion of sensors.conf on upgrades from 2.10.x to 3.x.x -# First mv any /etc/sensors.conf.rpmsave from previous updates out of the way -# Then after uninstall check if /etc/sensors.conf.rpmsave is created, if it -# is the user was using a non pristine /etc/sensors.conf, so convert it - -%triggerun -- lm_sensors <= 2.10.999 -if [ -f /etc/sensors.conf.rpmsave ]; then - mv /etc/sensors.conf.rpmsave /etc/sensors.conf.rpmsave.old +# Note non standard systemd scriptlets, since reload / stop makes no sense +# for lm_sensors +%triggerun -- lm_sensors < 3.3.0-2 +if [ -L /etc/rc3.d/S26lm_sensors ]; then + /bin/systemctl enable lm_sensors.service >/dev/null 2>&1 || : fi +/sbin/chkconfig --del lm_sensors -%triggerpostun -- lm_sensors <= 2.10.999 -if [ -f /etc/sensors.conf.rpmsave ]; then - mv /etc/sensors3.conf /etc/sensors3.conf.rpmnew - %{_bindir}/sensors-conf-convert < /etc/sensors.conf.rpmsave > \ - /etc/sensors3.conf - rm /etc/sensors.conf.rpmsave +%preun +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable lm_sensors.service > /dev/null 2>&1 || : fi -if [ -f /etc/sensors.conf.rpmsave.old ]; then - mv /etc/sensors.conf.rpmsave.old /etc/sensors.conf.rpmsave -fi - -# for conversion of /etc/sysconfig/lm_sensors format change -%triggerpostun -- lm_sensors <= 3.0.3 -%{_bindir}/sysconfig-lm_sensors-convert - - -%pre -if [ -f /var/lock/subsys/sensors ]; then - mv -f /var/lock/subsys/sensors /var/lock/subsys/lm_sensors -fi - -%post -/sbin/chkconfig --add lm_sensors %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig -%preun -if [ $1 = 0 ]; then - /sbin/chkconfig --del lm_sensors -fi - - %post sensord /sbin/chkconfig --add sensord @@ -144,7 +109,6 @@ if [ $1 = 0 ]; then fi - %files %defattr(-,root,root,-) %doc CHANGES CONTRIBUTORS COPYING doc README* @@ -155,7 +119,7 @@ fi %{_mandir}/man5/* %{_mandir}/man8/* %{_sbindir}/* -%{_initrddir}/lm_sensors +/lib/systemd/system/lm_sensors.service %config(noreplace) %{_sysconfdir}/sysconfig/lm_sensors %exclude %{_sbindir}/sensord %exclude %{_mandir}/man8/sensord.8.gz @@ -181,6 +145,13 @@ fi %changelog +* Sun Apr 24 2011 Hans de Goede - 3.3.0-2 +- Fix sensors-detect with the udevdb now living under /run (#697565) +- Provide a native systemd service file (#692159) +- Drop systemv initscript +- Drop configuration conversion scripts, the last Fedora with lm_sensors-2.x + was Fedora 8 ! + * Tue Mar 29 2011 Nikola Pajkovsky - 3.3.0 - new upstream release 3.3.0 - Resolved: 691548 - include empty /etc/sensors.d into the package