blob: ed80203bc47dd1ec27a7451eeb0ff97b6e34104b (
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.8 2004/12/06 22:05:08 johnm Exp $
# This eclass provides functions for compiling external kernel modules
# from source.
inherit linux-info
ECLASS=linux-mod
INHERITED="$INHERITED $ECLASS"
EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile
DESCRIPTION="Based on the $ECLASS eclass"
SLOT=0
DEPEND="virtual/linux-sources
sys-apps/sed"
# This eclass is designed to help ease the installation of external kernel
# modules into the kernel tree.
# eclass utilities
# ----------------------------------
use_m() {
# if we haven't determined the version yet, we need too.
get_version;
# if the kernel version is greater than 2.6.6 then we should use
# M= instead of SUBDIRS=
[ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
return 0 || return 1
}
convert_to_m() {
[ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument"
if use_m
then
ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS="
sed -i 's:SUBDIRS=:M=:g' ${1}
eend $?
fi
}
update_depmod() {
# if we haven't determined the version yet, we need too.
get_version;
ebegin "Updating module dependencies for ${KV_FULL}"
if [ -r ${KV_OUT_DIR}/System.map ]
then
depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL}
else
ewarn
ewarn "${KV_OUT_DIR}/System.map not found."
ewarn "You must manually update the kernel module dependencies using depmod."
ewarn
fi
eend $?
}
update_modules() {
if [ -x /sbin/modules-update ] ;
then
ebegin "Updating modules.conf"
/sbin/modules-update
eend $?
fi
}
set_kvobj() {
if kernel_is 2 6
then
KV_OBJ="ko"
else
KV_OBJ="o"
fi
einfo "Using KV_OBJ=${KV_OBJ}"
}
display_postinst() {
# if we haven't determined the version yet, we need too.
get_version;
local modulename moduledir sourcedir module_temp file i
file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}
file=${file/\/\///}
einfo "If you would like to load this module automatically upon boot"
einfo "please type the following as root:"
for i in ${MODULE_NAMES}
do
module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
modulename="${i/(*/}"
moduledir="${module_temp/:*/}"
moduledir="${moduledir:-misc}"
sourcedir="${module_temp/*:/}"
sourcedir="${sourcedir:-${S}}"
einfo " # echo \"${modulename}\" >> ${file}"
done
echo
}
# default ebuild functions
# --------------------------------
linux-mod_pkg_setup() {
linux-info_pkg_setup;
check_kernel_built;
check_modules_supported;
check_extra_config;
set_kvobj;
}
linux-mod_src_compile() {
local modulename moduledir sourcedir module_temp xarch i
xarch="${ARCH}"
unset ARCH
for i in "${MODULE_NAMES}"
do
module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
modulename="${i/(*/}"
moduledir="${module_temp/:*/}"
moduledir="${moduledir:-misc}"
sourcedir="${module_temp/*:/}"
sourcedir="${sourcedir:-${S}}"
einfo "Preparing ${modulename} module"
cd ${sourcedir}
emake ${BUILD_PARAMS} ${BUILD_TARGETS:-clean module} || die Unable to make ${BUILD_PARAMS} ${BUILD_TARGETS:-clean module}.
done
ARCH="${xarch}"
}
linux-mod_src_install() {
local modulename moduledir sourcedir module_temp i
for i in "${MODULE_NAMES}"
do
module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
modulename="${i/(*/}"
moduledir="${module_temp/:*/}"
moduledir="${moduledir:-misc}"
sourcedir="${module_temp/*:/}"
sourcedir="${sourcedir:-${S}}"
einfo "Installing ${modulename} module"
cd ${sourcedir}
insinto /lib/modules/${KV_FULL}/${moduledir}
doins ${modulename}.${KV_OBJ}
done
}
linux-mod_pkg_postinst() {
update_depmod;
update_modules;
display_postinst;
}
|