summaryrefslogtreecommitdiff
blob: 4e8101bdb3dcc565435e064ed947afddd6a9f441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-laptop/hdapsd/hdapsd-20090401-r2.ebuild,v 1.3 2013/06/25 11:37:29 ago Exp $

EAPI=4
inherit linux-info readme.gentoo

DESCRIPTION="IBM ThinkPad Harddrive Active Protection disk head parking daemon"
HOMEPAGE="http://hdaps.sourceforge.net/"
SRC_URI="mirror://sourceforge/hdaps/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 x86"
IUSE=""

pkg_setup() {
	# We require the hdaps module which can either come from kernel sources or
	# from the tp_smapi package.
	if ! has_version app-laptop/tp_smapi[hdaps]; then
		CONFIG_CHECK="~SENSORS_HDAPS"
		ERROR_SENSORS_HDAPS="${P} requires app-laptop/tp_smapi (with hdaps USE enabled) or support for CONFIG_SENSORS_HDAPS enabled"
		linux-info_pkg_setup
	fi

	DOC_CONTENTS="You can change the default frequency by modifing /sys/devices/platform/hdaps/sampling_rate.
		You might need to enable shock protection manually by running:\n
		# echo -1 > /sys/block/DEVICE/device/unload_heads"
}

src_install() {
	emake DESTDIR="${ED}" install
	rm -rf "${ED}"/usr/share/doc/hdapsd
	dodoc ChangeLog README AUTHORS
	newconfd "${FILESDIR}"/hdapsd.conf.3 hdapsd
	newinitd "${FILESDIR}"/hdapsd.init.3 hdapsd
	readme.gentoo_create_doc
}

pkg_postinst(){
	[[ -z $(ls ${EROOT}/sys/block/*/queue/protect 2>/dev/null) ]] && \
	[[ -z $(ls ${EROOT}/sys/block/*/device/unload_heads 2>/dev/null) ]] && \
		ewarn "Your kernel does NOT support shock protection. Kernel 2.6.28 and above is recommended!"

	if ! has_version app-laptop/tp_smapi[hdaps]; then
		ewarn "Using the hdaps module provided by app-laptop/tp_smapi instead"
		ewarn "of the in-kernel driver is strongly recommended!"
	fi

	readme.gentoo_print_elog
}