gnu: Add lm-sensors.

* gnu/packages/patches/lm-sensors-hwmon-attrs.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/linux.scm (lm-sensors): New variable.
This commit is contained in:
Mark H Weaver 2014-08-07 20:29:32 -04:00
parent 13e7ce857c
commit 30016044e0
3 changed files with 163 additions and 2 deletions

View File

@ -337,6 +337,7 @@ dist_patch_DATA = \
gnu/packages/patches/libtool-skip-tests.patch \
gnu/packages/patches/libtool-skip-tests-for-mips.patch \
gnu/packages/patches/libssh-CVE-2014-0017.patch \
gnu/packages/patches/lm-sensors-hwmon-attrs.patch \
gnu/packages/patches/luit-posix.patch \
gnu/packages/patches/m4-gets-undeclared.patch \
gnu/packages/patches/m4-readlink-EINVAL.patch \

View File

@ -23,8 +23,7 @@
#:use-module ((guix licenses)
#:hide (zlib))
#:use-module (gnu packages)
#:use-module ((gnu packages compression)
#:renamer (symbol-prefix-proc 'guix:))
#:use-module ((gnu packages compression) #:prefix guix:)
#:use-module (gnu packages flex)
#:use-module (gnu packages bison)
#:use-module (gnu packages gperf)
@ -44,6 +43,9 @@
#:use-module (gnu packages autotools)
#:use-module (gnu packages texinfo)
#:use-module (gnu packages check)
#:use-module (gnu packages maths)
#:use-module (gnu packages which)
#:use-module (gnu packages rrdtool)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system gnu)
@ -1366,3 +1368,76 @@ Extensions. The Wireless Extension is an interface allowing you to set
Wireless LAN specific parameters and get the specific stats.")
(home-page "http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html")
(license gpl2+)))
(define-public lm-sensors
(package
(name "lm-sensors")
(version "3.3.5")
(source (origin
(method url-fetch)
(uri (string-append
"http://dl.lm-sensors.org/lm-sensors/releases/lm_sensors-"
version ".tar.bz2"))
(sha256
(base32
"1ksgrynxgrq590nb2fwxrl1gwzisjkqlyg3ljfd1al0ibrk6mbjx"))
(patches (list (search-patch "lm-sensors-hwmon-attrs.patch")))))
(build-system gnu-build-system)
(inputs `(("rrdtool" ,rrdtool)
("perl" ,perl)
("kmod" ,kmod)
("gnuplot" ,gnuplot)))
(native-inputs `(("pkg-config" ,pkg-config)
("flex" ,flex)
("bison" ,bison)
("which" ,which)))
(arguments
`(#:tests? #f ; no 'check' target
#:make-flags (list (string-append "PREFIX=" %output)
(string-append "ETCDIR=" %output "/etc")
(string-append "MANDIR=" %output "/share/man"))
#:phases
(alist-delete
'configure
(alist-cons-before
'build 'patch-exec-paths
(lambda* (#:key inputs outputs #:allow-other-keys)
(substitute* "prog/detect/sensors-detect"
(("`uname")
(string-append "`" (assoc-ref inputs "coreutils")
"/bin/uname"))
(("(`|\")modprobe" all open-quote)
(string-append open-quote
(assoc-ref inputs "kmod")
"/bin/modprobe")))
(substitute* '("prog/pwm/pwmconfig"
"prog/pwm/fancontrol")
(("gnuplot")
(string-append (assoc-ref inputs "gnuplot")
"/bin/gnuplot"))
(("cat ")
(string-append (assoc-ref inputs "coreutils")
"/bin/cat "))
(("egrep ")
(string-append (assoc-ref inputs "grep")
"/bin/egrep "))
(("sed -e")
(string-append (assoc-ref inputs "sed")
"/bin/sed -e"))
(("cut -d")
(string-append (assoc-ref inputs "coreutils")
"/bin/cut -d"))
(("sleep ")
(string-append (assoc-ref inputs "coreutils")
"/bin/sleep "))
(("readlink -f")
(string-append (assoc-ref inputs "coreutils")
"/bin/readlink -f"))))
%standard-phases))))
(home-page "http://www.lm-sensors.org/")
(synopsis "Utilities to read temperature/voltage/fan sensors")
(description
"lm-sensors is a hardware health monitoring package for Linux. It allows
you to access information from temperature, voltage, and fan speed sensors.
It works with most newer systems.")
(license gpl2+)))

View File

@ -0,0 +1,85 @@
fancontrol: Deal with moving hwmon attributes
Several kernel drivers have already moved their attributes from the
hardware device to the hwmon class device, and others will follow.
Teach fancontrol about this possibility and let it adjust the attribute
paths transparently.
Patch by Jean Delvare <khali@linux-fr.org>.
See <http://www.lm-sensors.org/changeset/6216>.
--- lm-sensors/prog/pwm/fancontrol (revision 6172)
+++ lm-sensors/prog/pwm/fancontrol (revision 6216)
@@ -207,4 +207,63 @@
}
+function FixupDeviceFiles
+{
+ local DEVICE="$1"
+ local fcvcount pwmo tsen fan
+
+ let fcvcount=0
+ while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs
+ do
+ pwmo=${AFCPWM[$fcvcount]}
+ AFCPWM[$fcvcount]=${pwmo//$DEVICE\/device/$DEVICE}
+ if [ "${AFCPWM[$fcvcount]}" != "$pwmo" ]
+ then
+ echo "Adjusing $pwmo -> ${AFCPWM[$fcvcount]}"
+ fi
+ let fcvcount=$fcvcount+1
+ done
+
+ let fcvcount=0
+ while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
+ do
+ tsen=${AFCTEMP[$fcvcount]}
+ AFCTEMP[$fcvcount]=${tsen//$DEVICE\/device/$DEVICE}
+ if [ "${AFCTEMP[$fcvcount]}" != "$tsen" ]
+ then
+ echo "Adjusing $tsen -> ${AFCTEMP[$fcvcount]}"
+ fi
+ let fcvcount=$fcvcount+1
+ done
+
+ let fcvcount=0
+ while (( $fcvcount < ${#AFCFAN[@]} )) # go through all fan inputs
+ do
+ fan=${AFCFAN[$fcvcount]}
+ AFCFAN[$fcvcount]=${fan//$DEVICE\/device/$DEVICE}
+ if [ "${AFCFAN[$fcvcount]}" != "$fan" ]
+ then
+ echo "Adjusing $fan -> ${AFCFAN[$fcvcount]}"
+ fi
+ let fcvcount=$fcvcount+1
+ done
+}
+
+# Some drivers moved their attributes from hard device to class device
+function FixupFiles
+{
+ local DEVPATH="$1"
+ local entry device
+
+ for entry in $DEVPATH
+ do
+ device=`echo "$entry" | sed -e 's/=[^=]*$//'`
+
+ if [ -e "$device/name" ]
+ then
+ FixupDeviceFiles "$device"
+ fi
+ done
+}
+
# Check that all referenced sysfs files exist
function CheckFiles
@@ -306,4 +365,8 @@
echo "Configuration appears to be outdated, please run pwmconfig again" >&2
exit 1
+fi
+if [ "$DIR" = "/sys/class/hwmon" ]
+then
+ FixupFiles "$DEVPATH"
fi
CheckFiles || exit 1