]> Pileus Git - ~andy/sunrise/blob - x11-drivers/asus-switcheroo/asus-switcheroo-0_p20110814.ebuild
dev-db/cppdb: Add ~amd64 keyword, EAPI bump
[~andy/sunrise] / x11-drivers / asus-switcheroo / asus-switcheroo-0_p20110814.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=4
6 inherit linux-mod eutils
7
8 DESCRIPTION="Modules to turn off nVidia card for ASUS laptops"
9 HOMEPAGE="https://github.com/awilliam/asus-switcheroo"
10
11 KEYWORDS="~amd64"
12 DEPEND="sys-power/pm-utils"
13 RDEPEND="${DEPEND}"
14 SLOT="0"
15 LICENSE="GPL-2"
16 IUSE="byo video_cards_intel video_cards_nouveau video_cards_nvidia"
17 REQUIRED_USE="video_cards_nouveau? ( !video_cards_nvidia )"
18
19 GITHUB_COMMIT="9231be9"
20 SRC_URI="http://www.github.com/awilliam/${PN}/tarball/${GITHUB_COMMIT} -> ${P}.tar.gz"
21 S="${WORKDIR}/awilliam-${PN}-${GITHUB_COMMIT}"
22
23 BUILD_TARGETS="default"
24
25 pkg_setup() {
26         MODULE_NAMES="${PN}(extra/${PN}:${S})"
27         use byo && MODULE_NAMES="byo-switcheroo(extra/${PN}:${S})"
28         use video_cards_nouveau && MODULE_NAMES="${MODULE_NAMES}  nouveau-jprobe(extra/${PN}:${S})"
29
30         if kernel_is ge 2 6 38; then
31                 CONFIG_CHECK="~VGA_SWITCHEROO"
32         else
33                 use video_cards_intel && MODULE_NAMES="${MODULE_NAMES}  i915-jprobe(extra/${PN}:${S})"
34         fi
35
36         linux-mod_pkg_setup
37 }
38
39 src_install(){
40         linux-mod_src_install
41         exeinto /etc/pm/sleep.d
42         doexe  ${PN}-pm
43
44         if kernel_is ge 2 6 38 ; then
45                 sed -i "/915/d" ${PN}.conf-modprobe.d
46         fi
47
48         sed -i '1ioptions asus-switcheroo ' ${PN}.conf-modprobe.d
49
50         if ( use video_cards_nvidia || use byo) ; then
51                 sed -i "s:options.*oo:& dummy-client=1 \n:"  ${PN}.conf-modprobe.d
52         fi
53
54         if use video_cards_nvidia ; then
55                 sed -i "s:/sbin/modprobe nouveau-jprobe:/bin/echo DIS > /sys/kernel/debug/vgaswitcheroo/switch:"  ${PN}.conf-modprobe.d
56                 sed -i "s:ouveau:vidia:g"  ${PN}.conf-modprobe.d
57         fi
58
59         if use byo ; then
60                 sed -i "s:asus:byo:g"  ${PN}.conf-modprobe.d
61                 sed -i "s:options.*oo:&  model=AsusUL30VT:"  ${PN}.conf-modprobe.d
62         fi
63
64         if use video_cards_nvidia ; then
65                 sed -i '1iblacklist nvidia' ${PN}.conf-modprobe.d
66
67                 insinto /etc/modprobe.d
68                 newins ${PN}.conf-modprobe.d ${PN}.conf
69
70                 newinitd "${FILESDIR}"/switcheroo-dir.rc switcheroo
71
72                 exeinto /usr/sbin
73                 newexe "${FILESDIR}"/switcheroo-to-nvidia.sh switcheroo-to-nvidia
74
75                 insinto /etc/X11
76                 doins "${FILESDIR}"/xorg.conf-nvidia
77
78         elif use video_cards_nouveau ; then
79                 insinto /etc/modprobe.d
80                 newins ${PN}.conf-modprobe.d ${PN}.conf
81         fi
82 }
83
84 pkg_postinst() {
85         elog "If debugfs isn't automatically mounted for you,"
86         elog "add this to your /etc/fstab:"
87         elog ""
88         elog "debugfs /sys/kernel/debug debugfs defaults 0 0"
89         elog ""
90         elog "Remember to add asus_switcheroo or byo_switcheroo"
91         elog "to /etc/conf.d/modules, and edit your laptop model."
92         elog ""
93         elog "To turn off the discrete card on boot, put"
94         elog ""
95         elog 'if [ -f "/sys/kernel/debug/vgaswitcheroo/switch" ] ; then '
96         elog "   /bin/echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"
97         elog "fi"
98         elog ""
99         elog "in /etc/local.d/switcheroo.start"
100
101         if use video_cards_nvidia ; then
102                 elog ""
103                 elog "This ebuild has installed a system for switching"
104                 elog "to the nVidia card and driver. This system requires"
105                 elog "that you use the supplied xorg.conf for nVidia"
106                 elog "and no xorg.conf for the intel card. The switching"
107                 elog "is handled by the command switcheroo-to-nvidia"
108                 elog "and the switcheroo init.d script."
109         fi
110
111         linux-mod_pkg_postinst
112 }