summaryrefslogtreecommitdiff
blob: 86e95cbfe6a2964694c71487604519226a248d03 (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
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-wireless/ndiswrapper/ndiswrapper-0.3.ebuild,v 1.1 2004/03/06 23:44:20 latexer Exp $

inherit kernel-mod

S=${WORKDIR}/${PN}
DESCRIPTION="Wrapper for using Windows drivers for some wireless cards"
HOMEPAGE="http://ndiswrapper.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE=""
DEPEND="sys-devel/flex"

src_unpack() {
	check_KV
	kernel-mod_getversion
	unpack ${A}

	# Fix path to kernel and KVERS
	sed -i -e "s:^KSRC.*:KSRC=${ROOT}/usr/src/linux:" \
		-e "s:^KVERS.*:KVERS=${KV_MAJOR}${KV_MINOR}:" \
		${S}/driver/Makefile
}

src_install() {
	if [ ${KV_MINOR} -gt 4 ]
	then
		KV_OBJ="ko"
	else
		KV_OBJ="o"
	fi

	dobin ${S}/utils/loaddriver
	dodoc ${S}/README ${S}/AUTHORS

	insinto /lib/modules/${KV}/misc
	doins ${S}/driver/ndiswrapper.${KV_OBJ}

	insinto /etc/modules.d
	newins ${FILESDIR}/ndiswrapper.modules.d ndiswrapper
}

pkg_postinst() {
	kernel-mod_pkg_postinst

	einfo
	einfo "Part of the ${PN} module configuration can be done by running"
	einfo "# ebuild /var/db/pkg/net-wiress/${P}/${P}.ebuild config"
	einfo "Please consult /etc/modules.d/ndiswrapper to finish"
	einfo "configuring the driver"
	einfo
	einfo "In particular, ndiswrapper requires .inf and .sys files from"
	einfo "a Windows(tm) driver to function. Put these somewhere like"
	einfo "/usr/lib/hotplug/drivers, edit /etc/modules.d/ndiswrapper to match,"
	einfo "then run 'update-modules'"
	einfo
}

pkg_config() {
	if [ ! -f "/etc/modules.d/ndiswrapper" ]
	then
		eerror "/etc/modules.d/ndiswrapper not found. Please re-emerge"
		eerror "${PN} to have this file installed, then re-run this script"
		die "Driver configuration file not found"
	fi

	if ! egrep "VENDORID" /etc/modules.d/ndiswrapper
	then
		eerror "/etc/modules.d/ndiswrapper doesn't appear to be the one"
		eerror "distributed by the ${PN} ebuild. To use this config script,"
		eerror "Please re-emerge ${PN} and then re-run this script."
		die "Driver configuration file not usable"
	else
		einfo "Found acceptable config file at /etc/modules.d/ndiswrapper"
	fi

	if [ `lspci -n | grep 'Class 0280:' | wc -l` -gt 1 ]
	then
		eerror "More than one suitable device detected. This script"
		eerror "will only work with one suitable device present."
		die "Too many potential devices found"
	fi

	I=`lspci -n | grep 'Class 0280:' | cut -d' ' -f4`

	if [ -z "${I}" ]
	then
		die "No suitable devices found"
	fi

	VENDOR=`echo $I | cut -d':' -f1`
	DEVICEID=`echo $I | cut -d':' -f2`

	einfo "Setting the vendor ID to ${VENDOR} and the device ID to ${DEVICEID}"
	sed -i -e "s:VENDORID:${VENDOR}:" \
		-e "s:DEVICEID:${DEVICEID}:" \
		-e "s:loadndisdriver:loaddriver:" \
		/etc/modules.d/ndiswrapper
}