diff options
author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2009-02-17 19:01:15 +0100 |
---|---|---|
committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2009-02-17 19:01:15 +0100 |
commit | ca94a87e93f466e2abf583e901d6dfc346fea972 (patch) | |
tree | 9d728fc903dd1e6b82d9fc232acdfc2df9d45fa3 | |
download | tp_smapi-package-ca94a87e93f466e2abf583e901d6dfc346fea972.tar.gz tp_smapi-package-ca94a87e93f466e2abf583e901d6dfc346fea972.tar.xz tp_smapi-package-ca94a87e93f466e2abf583e901d6dfc346fea972.zip |
Initial commitHEADtp_smapi-0.40-1.fc10master
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | GNUmakefile | 3 | ||||
m--------- | git-rpm | 0 | ||||
-rw-r--r-- | tp_smapi.init | 132 | ||||
-rw-r--r-- | tp_smapi.spec | 93 | ||||
-rw-r--r-- | tp_smapi.sysconfig | 9 | ||||
-rw-r--r-- | tp_smapi.udev-rules | 1 |
7 files changed, 241 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0ccfef1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "git-rpm"] + path = git-rpm + url = git://fedorapeople.org/~ndim/git-rpm.git diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..574f389 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,3 @@ +NAME = tp_smapi +dummy := $(shell test -f git-rpm/git-rpm.mk || git submodule update --init) +include git-rpm/git-rpm.mk diff --git a/git-rpm b/git-rpm new file mode 160000 +Subproject 8d3cdb227fde29c11480fe0cd3d9982875a6c96 diff --git a/tp_smapi.init b/tp_smapi.init new file mode 100644 index 0000000..d0fce10 --- /dev/null +++ b/tp_smapi.init @@ -0,0 +1,132 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/tp_smapi +# +# Load tp_smapi kernel driver and apply settings +# +# chkconfig: 345 10 90 +# description: Load tp_smapi kernel driver and apply settings +# processname: + +### BEGIN INIT INFO +# Provides: tp_smapi +# Required-Start: $syslog $local_fs +# Required-Stop: $syslog $local_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: load and set up tp_smapi +# Description: Load tp_smapi kernel driver and apply settings +### END INIT INFO + +# TODO: Make sure this script's startup runs after akmod's startup + +# Source function library. +. /etc/rc.d/init.d/functions + +RETVAL=0 +CONFIG=/etc/sysconfig/tp_smapi + +# Source function library. +. /etc/rc.d/init.d/functions + +load_modules() { + echo -n "Loading tp_smapi driver module" + if modprobe tp_smapi; then + success "Loading tp_smapi driver module" + else + failure "Loading tp_smapi driver module" + RETVAL=2 + fi + echo +} + +unload_modules() { + mdoules="tp_smapi thinkpad_ec" + echo -n "Unloading driver modules ${modules}" + if modprobe -r tp_smapi && modprobe -r thinkpad_ec; then + success "Unloading driver modules ${modules}" + else + failure "Unloading driver modules ${modules}" + RETVAL=2 + fi + echo +} + +smapi_config() { + if [ -s "$CONFIG" ]; then + . "$CONFIG" + dirty=false + cd /sys/devices/platform/smapi + echo -n "Configuring tp_smapi battery settings" + for bat in BAT*; do + if test -d "$bat"; then + if [ "x$START_CHARGE_THRESH" != x ]; then + echo "$START_CHARGE_THRESH" > "$bat/start_charge_thresh" + fi + if [ "x$STOP_CHARGE_THRESH" != x ]; then + echo "$STOP_CHARGE_THRESH" > "$bat/stop_charge_thresh" + fi + else + dirty=true + break + fi + done + if "$dirty"; then + passed "No tp_smapi battery settings" + else + success "Configured tp_smapi battery settings" + fi + echo + fi +} + +is_loaded() { + if /sbin/lsmod | grep '^tp_smapi ' > /dev/null; then + echo -n "tp_smapi settings:" + cd /sys/devices/platform/smapi + for bat in BAT*; do + if [ -d "$bat" ] && [ "$(<$bat/installed)" -eq 1 ]; then + echo -n " $bat($(<$bat/remaining_percent)%, $(<$bat/start_charge_thresh)%..$(<$bat/stop_charge_thresh)%)" + fi + done + echo + else + echo "tp_smapi driver is not loaded" + return 2 + fi +} + +case "$1" in +force-reload) + echo "$0: Unimplemented feature." + RETVAL=3 + ;; +start) + load_modules + smapi_config + ;; +reload|restart|force-reload) + unload_modules + load_modules + smapi_config + ;; +condrestart) + if is_loaded; then + unload_modules + load_modules + smapi_config + fi + ;; +stop) + unload_modules + ;; +status) + is_loaded + RETVAL=$? + ;; +*) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}" + RETVAL=2 +esac + +exit $RETVAL diff --git a/tp_smapi.spec b/tp_smapi.spec new file mode 100644 index 0000000..177be61 --- /dev/null +++ b/tp_smapi.spec @@ -0,0 +1,93 @@ +# +# References: +# http://fedoraproject.org/wiki/Packaging/SysVInitScript + +Name: tp_smapi +Version: 0.40 +Release: 1%{?dist} +Summary: ThinkPad System Management API - scripts and user interface + +Group: System Environment/Kernel +License: GPLv2+ +URL: http://tpctl.sourceforge.net/ +Source0: http://prdownloads.sourceforge.net/tpctl/tp_smapi-%{version}.tgz +Source11: tp_smapi.init +Source12: tp_smapi.sysconfig +Source21: tp_smapi.udev-rules + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildArch: noarch + +# The kmod magic in tp_smapi-kmod requires this: +Provides: tp_smapi-kmod-common = %{version} + +Requires: tp_smapi-kmod >= %{version} +Requires(post): tp_smapi-kmod >= %{version} + + +%define udevfname 66-tp_smapi.rules +%define udevrulesdir %{_sysconfdir}/udev/rules.d + + +%description +ThinkPad System Management API - scripts and user interface + + +%prep +%setup -q -n tp_smapi-%{version} + + +%build + + +%install +%{__rm} -rf "%{buildroot}" + +%{__install} -d -m 0755 "%{buildroot}/%{_sysconfdir}/init.d" +%{__install} -p -m 0755 "%{SOURCE11}" "%{buildroot}/%{_sysconfdir}/init.d/tp_smapi" + +%{__install} -d -m 0755 "%{buildroot}/%{_sysconfdir}/sysconfig" +%{__install} -p -m 0644 "%{SOURCE12}" "%{buildroot}/%{_sysconfdir}/sysconfig/tp_smapi" + +%{__install} -d -m 0755 "%{buildroot}/%{udevrulesdir}" +%{__install} -p -m 0644 "%{SOURCE21}" "%{buildroot}/%{udevrulesdir}/%{udevfname}" + + +%clean +%{__rm} -rf "%{buildroot}" + + +%post +chkconfig --add tp_smapi +service tp_smapi condrestart + + +%preun +service tp_smapi stop +chkconfig --del tp_smapi + + +%files +%defattr (-,root,root,-) +%doc README CHANGES TODO +%config(noreplace) %{udevrulesdir}/%{udevfname} +%config(noreplace) %{_sysconfdir}/sysconfig/tp_smapi +%{_sysconfdir}/init.d/tp_smapi + + +%changelog +* Tue Feb 17 2009 Hans Ulrich Niedermann <hun@n-dimensional.de> - 0.40-1 +- update to tp_smapi-0.40 +- run service condrestart instead of start + +* Wed Oct 08 2008 Hans Ulrich Niedermann <hun@n-dimensional.de> - 0.39-1 +- update to tp_smapi-0.39 + +* Sun Apr 13 2008 Hans Ulrich Niedermann <hun@n-dimensional.de> - 0.37-1 +- update to tp_smapi-0.37 +- add sysvinit script and sysconfig file +- rename package from tp_smapi-common to tp_smapi + +* Sun Apr 13 2008 Hans Ulrich Niedermann <hun@n-dimensional.de> - 0.34-7 +- separate tp_smapi-common package to complement tp_smapi-akmod diff --git a/tp_smapi.sysconfig b/tp_smapi.sysconfig new file mode 100644 index 0000000..48547bc --- /dev/null +++ b/tp_smapi.sysconfig @@ -0,0 +1,9 @@ +# Battery charge thresholds + +# This is supposed to make the battery survive many many cycles +#START_CHARGE_THRESH=40 +#STOP_CHARGE_THRESH=80 + +# This gives you more charge when you are on the road +#START_CHARGE_THRESH=60 +#STOP_CHARGE_THRESH=95 diff --git a/tp_smapi.udev-rules b/tp_smapi.udev-rules new file mode 100644 index 0000000..be6052a --- /dev/null +++ b/tp_smapi.udev-rules @@ -0,0 +1 @@ +KERNEL=="event[0-9]*", ATTRS{phys}=="hdaps/input1", ATTRS{modalias}=="input:b0019v1014p5054e4801-*", SYMLINK+="input/hdaps/accelerometer-event" |