]> Pileus Git - ~andy/sunrise/blob - x11-drivers/asus-switcheroo/asus-switcheroo-0_p20110814.ebuild
x11-drivers/asus-switcheroo: Updating to allow use of /etc/X11/xorg.conf.d/ and byo...
[~andy/sunrise] / x11-drivers / asus-switcheroo / asus-switcheroo-0_p20110814.ebuild
1 # Copyright 1999-2011 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 3 0 0; then
31                 eerror "This package has only been tested with 2.6.x version kernels"
32                 die
33         fi
34
35         if kernel_is ge 2 6 38; then
36                 CONFIG_CHECK="VGA_SWITCHEROO"
37         else
38                 use video_cards_intel && MODULE_NAMES="${MODULE_NAMES}  i915-jprobe(extra/${PN}:${S})"
39         fi
40
41         linux-mod_pkg_setup
42 }
43
44 src_install(){
45         linux-mod_src_install
46         exeinto /etc/pm/sleep.d
47         doexe  ${PN}-pm
48
49         if kernel_is ge 2 6 38 ; then
50                 sed -i "/915/d" ${PN}.conf-modprobe.d
51         fi
52
53         sed -i '1ioptions asus-switcheroo ' ${PN}.conf-modprobe.d
54
55         if ( use video_cards_nvidia || use byo) ; then
56                 sed -i "s:options.*oo:& dummy-client=1 \n:"  ${PN}.conf-modprobe.d
57         fi
58
59         if use video_cards_nvidia ; then
60                 sed -i "s:/sbin/modprobe nouveau-jprobe:/bin/echo DIS > /sys/kernel/debug/vgaswitcheroo/switch:"  ${PN}.conf-modprobe.d
61                 sed -i "s:ouveau:vidia:g"  ${PN}.conf-modprobe.d
62         fi
63
64         if use byo ; then
65                 sed -i "s:asus:byo:g"  ${PN}.conf-modprobe.d
66                 sed -i "s:options.*oo:&  model=AsusUL30VT:"  ${PN}.conf-modprobe.d
67         fi
68
69         if use video_cards_nvidia ; then
70                 sed -i '1iblacklist nvidia' ${PN}.conf-modprobe.d
71
72                 insinto /etc/modprobe.d
73                 newins ${PN}.conf-modprobe.d ${PN}.conf
74
75                 newinitd "${FILESDIR}"/switcheroo-dir.rc switcheroo
76
77                 exeinto /usr/sbin
78                 newexe "${FILESDIR}"/switcheroo-to-nvidia.sh switcheroo-to-nvidia
79
80                 insinto /etc/X11
81                 doins "${FILESDIR}"/xorg.conf-nvidia
82
83         elif use video_cards_nouveau ; then
84                 insinto /etc/modprobe.d
85                 newins ${PN}.conf-modprobe.d ${PN}.conf
86         fi
87 }
88
89 pkg_postinst() {
90         elog "If debugfs isn't automatically mounted for you,"
91         elog "add this to your /etc/fstab:"
92         elog ""
93         elog "debugfs /sys/kernel/debug debugfs defaults 0 0"
94         elog ""
95         elog "Remember to add asus_switcheroo or byo_switcheroo"
96         elog "to /etc/conf.d/modules, and edit your laptop model."
97         elog ""
98         elog "To turn off the discrete card on boot, put"
99         elog ""
100         elog 'if [ -f "/sys/kernel/debug/vgaswitcheroo/switch" ] ; then '
101         elog "   /bin/echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"
102         elog "fi"
103         elog ""
104         elog "in /etc/local.d/switcheroo.start"
105
106         if use video_cards_nvidia ; then
107                 elog ""
108                 elog "This ebuild has installed a system for switching"
109                 elog "to the nVidia card and driver. This system requires"
110                 elog "that you use the supplied xorg.conf for nVidia"
111                 elog "and no xorg.conf for the intel card. The switching"
112                 elog "is handled by the command switcheroo-to-nvidia"
113                 elog "and the switcheroo init.d script."
114         fi
115
116         linux-mod_pkg_postinst
117 }