]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - app-laptop/hdapsd/hdapsd-20141024.ebuild
Use versioned init/conf files and clean up the ebuild a little.
[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 "
26 ERROR_SENSORS_HDAPS+="USE enabled) or kernel support for "
27 ERROR_SENSORS_HDAPS+="CONFIG_SENSORS_HDAPS enabled"
28 linux-info_pkg_setup
29 fi
30 }
31
32 src_configure(){
33 econf \
34 $(use_enable libconfig) \
35 --with-systemdsystemunitdir=$(systemd_get_unitdir) \
36 --docdir="${EROOT}usr/share/doc/${PF}"
37 }
38
39 src_install() {
40 default
41 newconfd "${FILESDIR}/hdapsd.conf-${PV}" hdapsd
42 newinitd "${FILESDIR}/hdapsd.init-${PV}" hdapsd
43 readme.gentoo_create_doc
44 }
45
46 pkg_postinst(){
47 [[ -z $(ls "${EROOT}"sys/block/*/queue/protect 2>/dev/null) ]] && \
48 [[ -z $(ls "${EROOT}"sys/block/*/device/unload_heads 2>/dev/null) ]] && \
49 ewarn "Your kernel does NOT support shock protection."
50
51 if ! has_version app-laptop/tp_smapi[hdaps]; then
52 ewarn "Using the hdaps module provided by app-laptop/tp_smapi instead"
53 ewarn "of the in-kernel driver is strongly recommended!"
54 fi
55
56 readme.gentoo_print_elog
57 }
58
59 DISABLE_AUTOFORMATTING=1
60 DOC_CONTENTS='
61 You can change the default frequency by modifing,
62
63 /sys/devices/platform/hdaps/sampling_rate
64
65 You might need to enable shock protection manually by running:
66
67 # echo -1 > /sys/block/DEVICE/device/unload_heads
68
69 as root.
70 '