summaryrefslogtreecommitdiff
blob: 6e451716393a9b5aaa75aa585da94de5dbd23ae7 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-laptop/ibm-acpi/ibm-acpi-0.8.ebuild,v 1.6 2005/01/01 14:46:37 eradicator Exp $

inherit kernel-mod eutils

DESCRIPTION="IBM ThinkPad ACPI extras"

HOMEPAGE="http://ibm-acpi.sourceforge.net"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86"

IUSE="doc"

DEPEND="virtual/linux-sources
		sys-apps/sed"

pkg_setup() {
	local DIE=0

	if kernel-mod_is_2_4_kernel
	then
		die "${P} does not support kernel 2.4.x"
	fi

	if kernel-mod_configoption_present ACPI_IBM
	then
		eerror ""
		eerror "${P} requires IBM ThinkPad Laptop Extras (CONFIG_ACPI_IBM)"
		eerror "to be DISABLED in the kernel to avoid conflicting modules."
		DIE=1
	fi

	if ! kernel-mod_configoption_present ACPI
	then
		eerror ""
		eerror "${PN} requires an ACPI (CONFIG_ACPI) enabled kernel."
		eerror ""
		DIE=1
	fi

	kernel-mod_check_modules_supported

	if [ $DIE -eq 1 ]
	then
		eerror ""
		die "You kernel is missing the required option(s) listed above."
	fi
}

src_unpack() {
	unpack ${A}

	# let pkg_postinst() handle depmod
	sed -i "s:depmod -a::" ${S}/Makefile

	kernel-mod_getversion

	if [ ${KV_MINOR} -gt 5 ] && [ ${KV_PATCH} -gt 5 ]
	then
		sed -i 's:SUBDIRS=:M=:g' ${S}/Makefile
	fi
}

src_compile() {
	set_arch_to_kernel

	emake KDIR=${ROOT}/usr/src/linux || die
}

src_install() {
	set_arch_to_kernel

	emake MDIR=${D}/lib/modules/${KV}/acpi install || die

	set_arch_to_portage

	dodoc LICENSE README

	if use doc; then
		docinto examples/etc/acpi/actions
		dodoc config/etc/acpi/actions/*

		docinto examples/etc/acpi/events
		dodoc config/etc/acpi/events/*
	fi
}

pkg_postinst() {
	einfo "Checking kernel module dependencies"
	test -r "${ROOT}/usr/src/linux/System.map" && \
		depmod -ae -F "${ROOT}/usr/src/linux/System.map" -b "${ROOT}" -r ${KV}

	einfo ""
	einfo "You may wish to install sys-apps/acpid to handle the ACPI events generated"
	einfo "by ${PN}."

	if use doc &> /dev/null; then
		einfo ""
		einfo "Example acpid configuration has been installed to"
		einfo "/usr/share/doc/${PF}/examples/"
	fi

	einfo ""
	einfo "For further instructions please see /usr/share/doc/${PF}/README.gz"
	einfo ""
}