]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - app-laptop/hdapsd/hdapsd-20141024.ebuild
a4e29e02d7c6318e3cae00ca4030e8b79716c0ea
[mjo-overlay.git] / app-laptop / hdapsd / hdapsd-20141024.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=5
6 inherit linux-info readme.gentoo systemd
7
8 DESCRIPTION="IBM ThinkPad Hard Drive Active Protection System (HDAPS) daemon"
9 HOMEPAGE="https://github.com/evgeni/${PN}/"
10 SRC_URI="https://github.com/evgeni/${PN}/releases/download/${PV}/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="~amd64 ~x86"
15 IUSE="libconfig"
16
17 DEPEND="libconfig? ( dev-libs/libconfig )"
18 RDEPEND="${DEPEND}"
19
20 pkg_setup() {
21 # We require the hdaps module which can either come from kernel sources
22 # or from the tp_smapi package.
23 if ! has_version app-laptop/tp_smapi[hdaps]; then
24 CONFIG_CHECK="~SENSORS_HDAPS"
25 ERROR_SENSORS_HDAPS="${P} requires app-laptop/tp_smapi (with hdaps USE enabled) or support for CONFIG_SENSORS_HDAPS enabled"
26 linux-info_pkg_setup
27 fi
28
29 DOC_CONTENTS="You can change the default frequency by modifing /sys/devices/platform/hdaps/sampling_rate.
30 You might need to enable shock protection manually by running:\n
31 # echo -1 > /sys/block/DEVICE/device/unload_heads"
32 }
33
34 src_configure(){
35 econf \
36 $(use_enable libconfig) \
37 --with-systemdsystemunitdir=$(systemd_get_unitdir) \
38 --docdir="${EROOT}usr/share/doc/${PF}"
39 }
40
41 src_install() {
42 default
43 newconfd "${FILESDIR}"/hdapsd.conf.3 hdapsd
44 newinitd "${FILESDIR}"/hdapsd.init.3 hdapsd
45 readme.gentoo_create_doc
46 }
47
48 pkg_postinst(){
49 [[ -z $(ls "${EROOT}"sys/block/*/queue/protect 2>/dev/null) ]] && \
50 [[ -z $(ls "${EROOT}"sys/block/*/device/unload_heads 2>/dev/null) ]] && \
51 ewarn "Your kernel does NOT support shock protection."
52
53 if ! has_version app-laptop/tp_smapi[hdaps]; then
54 ewarn "Using the hdaps module provided by app-laptop/tp_smapi instead"
55 ewarn "of the in-kernel driver is strongly recommended!"
56 fi
57
58 readme.gentoo_print_elog
59 }