summaryrefslogtreecommitdiff
blob: 518be1d02b2eb014d127101981d67797fb51db4e (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/speedfreq/speedfreq-0.7.2-r1.ebuild,v 1.1 2005/03/14 21:57:10 ciaranm Exp $

inherit eutils

DESCRIPTION="daemon to control the CPU speed in 2.6 kernels"
HOMEPAGE="http://www.goop.org/~jeremy/speedfreq/"
SRC_URI="http://www.goop.org/~jeremy/speedfreq/${P}.tar.gz"

LICENSE="GPL-1"
SLOT="0"
KEYWORDS="x86 ppc ~amd64"
IUSE="acpi"

DEPEND="!ppc? ( acpi? ( sys-apps/acpid ) )"

is_2_6_kernel() {
	local KV_major="$(echo "${KV}" | cut -d. -f1)"
	local KV_minor="$(echo "${KV}" | cut -d. -f2)"
	[ "${KV_major}" -eq 2 -a "${KV_minor}" -eq 6 ] \
		&& return 0 \
		|| return 1
}

pkg_setup() {
	check_KV
	if [ ! is_2_6_kernel ] ; then
		eerror "This only works with 2.6.x kernels"
		die "Only works with 2.6.x kernels, not ${KV}"
	fi
}

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${FILESDIR}/${PV}-python-ver.patch
	sed -i \
		-e 's/root\.root/root:root/' Makefile \
		|| die "sed Makefile failed"
}

src_compile() {
	emake CFLAGS="${CFLAGS}" || die "compile of speedfreq failed"
}

src_install() {
	make \
		PREFIX=${D}/usr \
		INITD=${T} \
		install \
		|| die "make install failed"
	exeinto /etc/init.d ; newexe ${FILESDIR}/speedfreq.rc speedfreq
	insinto /etc/conf.d ; newins ${FILESDIR}/speedfreq.conf speedfreq
	dodoc README
	if use acpi ; then
		exeinto /etc/acpi
		doexe ${FILESDIR}/battery.sh
	fi
}

pkg_postinst() {
	if use acpi ; then
		echo
		einfo "A sample script for powercontrol has been placed in /etc/acpi/battery.sh"
		einfo "To use it add the following lines to your /etc/acpi/events/default"
		einfo " event=battery.*"
		einfo " action=/etc/acpi/battery.sh %e"
		einfo "Note that this only supports one battery at the time"
		echo
		einfo "Configuration should be done in /etc/conf.d/speedfreq"
		einfo "Make sure that you have sysfs mounted on /sys"
		echo
	fi
}