From 9d90e2d7e3f82500cc95d884a92c3b280007770d Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 28 Sep 2011 17:07:40 +0200 Subject: [PATCH] add app-laptop/tp_smapi-0.41 --- app-laptop/tp_smapi/Manifest | 4 + app-laptop/tp_smapi/files/tp_smapi-0.41-confd | 20 ++++ app-laptop/tp_smapi/files/tp_smapi-0.41-initd | 92 +++++++++++++++++++ app-laptop/tp_smapi/tp_smapi-0.41.ebuild | 60 ++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 app-laptop/tp_smapi/Manifest create mode 100644 app-laptop/tp_smapi/files/tp_smapi-0.41-confd create mode 100755 app-laptop/tp_smapi/files/tp_smapi-0.41-initd create mode 100644 app-laptop/tp_smapi/tp_smapi-0.41.ebuild diff --git a/app-laptop/tp_smapi/Manifest b/app-laptop/tp_smapi/Manifest new file mode 100644 index 0000000..a0d2ad9 --- /dev/null +++ b/app-laptop/tp_smapi/Manifest @@ -0,0 +1,4 @@ +AUX tp_smapi-0.41-confd 785 RMD160 55d174b025625dd51e128baaaad2271fbddc3cab SHA1 a2a6d5198230da99dfbd3f451406ec9989b3ae49 SHA256 3996b08957adea6f14e5a0e394212026dc73e6802a8dcd5aa9a3b413530c3fdb +AUX tp_smapi-0.41-initd 1832 RMD160 154ac41defcd04f2edbc83d5ab71c4048f02835d SHA1 4ffd64701c8158b945b45ef46986876bc073d7c2 SHA256 a6f5096f52d2d9fdaa0e2be9a3b796f101ba109fa53816b7c515a400110de1af +DIST tp_smapi-0.41.tar.gz 38852 RMD160 e4db1b7449d0da741c1433396a4227d1274743f1 SHA1 ab222a41a2773bfa8a67c4b74343655dca6fb8be SHA256 6aef02b92d10360ac9be0db29ae390636be55017990063a092a285c70b54e666 +EBUILD tp_smapi-0.41.ebuild 1347 RMD160 e855695fbf13509f6697cab9ac83a16bc7389826 SHA1 55394b582d14c0aaa46a27227f7ad729e8d95d55 SHA256 bbacbf61dd06986822bc9285cafda47b10cf2974d1292ba83c7f0236d89ad982 diff --git a/app-laptop/tp_smapi/files/tp_smapi-0.41-confd b/app-laptop/tp_smapi/files/tp_smapi-0.41-confd new file mode 100644 index 0000000..7c80f35 --- /dev/null +++ b/app-laptop/tp_smapi/files/tp_smapi-0.41-confd @@ -0,0 +1,20 @@ +# /etc/conf.d/smapi: config file for /etc/init.d/smapi + +# use '/etc/init.d/smapi info' at any time to check the thresholds +# currently used by the driver +# Note that the kernel does some sanity checking on the values and +# will not accept any combination of values you may try to set up. +# (i.e. stop value lower than start) So if the output of info does +# not match what you wanted the driver probably did not like your +# configuration. + +# default thresholds for '/etc/init.d/smapi start' +SMAPI_THRESH_START="30" +SMAPI_THRESH_STOP="85" +# values to be used for '/etc/init.d/smapi low' +SMAPI_LOW_THRESH_START="${SMAPI_THRESH_START}" +SMAPI_LOW_THRESH_STOP="${SMAPI_THRESH_STOP}" + +# values to be used for '/etc/init.d/smapi high' +SMAPI_HIGH_THRESH_START="95" +SMAPI_HIGH_THRESH_STOP="100" diff --git a/app-laptop/tp_smapi/files/tp_smapi-0.41-initd b/app-laptop/tp_smapi/files/tp_smapi-0.41-initd new file mode 100755 index 0000000..4edb051 --- /dev/null +++ b/app-laptop/tp_smapi/files/tp_smapi-0.41-initd @@ -0,0 +1,92 @@ +#!/sbin/runscript +# Copyright (C) 2011 Henning Schild +# Copyright (C) 2011 Sebastian Pipping +# +# Distributed under the terms of the GNU General Public License, v2 or later + +opts="low high info" + +SMAPI_SYSFS="/sys/devices/platform/smapi" +BATS="BAT0 BAT1" + +depend() { + after modules +} + +start() { + local state1 + local state2 + + ebegin "Making sure that module 'tp_smapi' is loaded" + modprobe tp_smapi + state1=$? + eend ${state1} + + ebegin "Checking for \"${SMAPI_SYSFS}\"" + test -d "${SMAPI_SYSFS}" + state2=$? + eend ${state2} + + if [ "${state1}" -ne "0" ] || [ "${state2}" -ne "0" ]; then + return 1 + fi + + ebegin "Starting ${SVCNAME}" + set_all ${SMAPI_THRESH_START} ${SMAPI_THRESH_STOP} + eend $? +} + +stop() { + einfo "Nothing required to be done to stop ${SVCNAME}" +} + +require_started() { + if ! service_started; then + "${RC_SERVICE}" start || return $? + fi +} + +high() { + require_started + + einfo "Switching ${SVCNAME} to high thesholds" + set_all ${SMAPI_HIGH_THRESH_START} ${SMAPI_HIGH_THRESH_STOP} +} + +low() { + require_started + + einfo "Switching ${SVCNAME} to low thesholds" + set_all ${SMAPI_LOW_THRESH_START} ${SMAPI_LOW_THRESH_STOP} +} + +set_all() { + local tstart=$1 + local tstop=$2 + local bat + + for bat in ${BATS}; do + ebegin " setting thresholds for ${bat}: $tstart $tstop" + echo ${tstart} > ${SMAPI_SYSFS}/${bat}/start_charge_thresh + echo ${tstop} > ${SMAPI_SYSFS}/${bat}/stop_charge_thresh + eend $? + done +} + +info() { + local presence + local tstart + local tstop + local bat + + require_started + + for bat in ${BATS}; do + tstart=$(cat ${SMAPI_SYSFS}/${bat}/start_charge_thresh) + tstop=$(cat ${SMAPI_SYSFS}/${bat}/stop_charge_thresh) + if [ "$(cat ${SMAPI_SYSFS}/${bat}/installed)" -eq "1" ]; then + presence=" [installed]" + fi + einfo "${bat}: ${tstart} ${tstop}${presence}" + done +} diff --git a/app-laptop/tp_smapi/tp_smapi-0.41.ebuild b/app-laptop/tp_smapi/tp_smapi-0.41.ebuild new file mode 100644 index 0000000..90c8f5f --- /dev/null +++ b/app-laptop/tp_smapi/tp_smapi-0.41.ebuild @@ -0,0 +1,60 @@ +EAPI=4 + +inherit eutils linux-mod + +DESCRIPTION="IBM ThinkPad SMAPI BIOS driver" +HOMEPAGE="http://tpctl.sourceforge.net/" +SRC_URI="http://github.com/downloads/evgeni/tp_smapi/${P}.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +RESTRICT="mirror" +KEYWORDS="~amd64 ~x86" + +IUSE="hdaps" + + +# We need dmideode if the kernel does not support DMI_DEV_TYPE_OEM_STRING +# in dmi.h +DEPEND="sys-apps/dmidecode" +RDEPEND="${DEPEND}" + +pkg_pretend() { + linux-mod_pkg_setup + + if kernel_is lt 2 6 19; then + eerror + eerror "${P} requires Linux kernel 2.6.19 or above." + eerror + die "Unsupported kernel version" + fi + + MODULE_NAMES="thinkpad_ec(extra:) tp_smapi(extra:)" + BUILD_PARAMS="KSRC=${KV_DIR} KBUILD=${KV_OUT_DIR}" + BUILD_TARGETS="default" + + if use hdaps; then + CONFIG_CHECK="~INPUT_UINPUT" + WARNING_INPUT_UINPUT="Your kernel needs uinput for the hdaps module to perform better" + linux-info_pkg_setup + + MODULE_NAMES="${MODULE_NAMES} hdaps(extra:)" + BUILD_PARAMS="${BUILD_PARAMS} HDAPS=1" + + CONFIG_CHECK="!SENSORS_HDAPS" + ERROR_SENSORS_HDAPS="${P} with USE=hdaps conflicts with in-kernel HDAPS (CONFIG_SENSORS_HDAPS)" + linux-info_pkg_setup + fi +} + +pkg_setup() { + # run again as pkg_pretend is not var safe + pkg_pretend +} + +src_install() { + linux-mod_src_install + dodoc CHANGES README + newinitd "${FILESDIR}"/${P}-initd smapi + newconfd "${FILESDIR}"/${P}-confd smapi +} -- 2.30.2