/[gentoo-x86]/eclass/linux-mod.eclass
Gentoo

Diff of /eclass/linux-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.25 Revision 1.26
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.25 2005/01/28 17:33:17 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.26 2005/01/31 20:03:47 johnm Exp $
4 4
5# Description: This eclass is used to interface with linux-info in such a way 5# Description: This eclass is used to interface with linux-info in such a way
6# to provide the functionality required and initial functions 6# to provide the functionality required and initial functions
7# required to install external modules against a kernel source 7# required to install external modules against a kernel source
8# tree. 8# tree.
13# Please direct your bugs to the current eclass maintainer :) 13# Please direct your bugs to the current eclass maintainer :)
14 14
15# A Couple of env vars are available to effect usage of this eclass 15# A Couple of env vars are available to effect usage of this eclass
16# These are as follows: 16# These are as follows:
17# 17#
18# Env Var Option Default Description 18# Env Var Option Default Description
19# KERNEL_DIR <string> /usr/src/linux The directory containing kernel 19# KERNEL_DIR <string> /usr/src/linux The directory containing kernel
20# the target kernel sources. 20# the target kernel sources.
21# ECONF_PARAMS <string> The parameters to pass to econf. 21# ECONF_PARAMS <string> The parameters to pass to econf.
22# If this is not set, then econf isn't 22# If this is not set, then econf
23# run. 23# isn't run.
24# BUILD_PARAMS <string> The parameters to pass to emake. 24# BUILD_PARAMS <string> The parameters to pass to emake.
25# BUILD_TARGETS <string> clean modules The build targets to pass to make. 25# BUILD_TARGETS <string> clean modules The build targets to pass to
26# make.
26# MODULE_NAMES <string> This is the modules which are 27# MODULE_NAMES <string> This is the modules which are
27# to be built automatically using the 28# to be built automatically using
28# default pkg_compile/install. They 29# the default pkg_compile/install.
29# are explained properly below. 30# They are explained properly
30# It will only make BUILD_TARGETS once 31# below. It will only make
32# BUILD_TARGETS once in any
31# in any directory. 33# directory.
32# NO_MODULESD <string> Set this to something to prevent
33# modulesd file generation
34
35 34
36# MODULE_NAMES - Detailed Overview 35# MODULE_NAMES - Detailed Overview
37# 36#
38# The structure of each MODULE_NAMES entry is as follows: 37# The structure of each MODULE_NAMES entry is as follows:
39# modulename(libmodulesdir:modulesourcedir) 38# modulename(libdir:srcdir:objdir)
40# for example: 39# for example:
41# MODULE_NAMES="module_pci(pci:${S}/pci) module_usb(usb:${S}/usb)" 40# MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})"
42# 41#
43# what this would do is 42# what this would do is
44# cd ${S}/pci 43# cd ${S}/pci
45# make ${BUILD_PARAMS} ${BUILD_TARGETS} 44# make ${BUILD_PARAMS} ${BUILD_TARGETS}
45# cd ${S}
46# insinto /lib/modules/${KV_FULL}/pci 46# insinto /lib/modules/${KV_FULL}/pci
47# doins module_pci.${KV_OBJ} 47# doins module_pci.${KV_OBJ}
48# 48#
49# cd ${S}/usb 49# cd ${S}/usb
50# make ${BUILD_PARAMS} ${BUILD_TARGETS} 50# make ${BUILD_PARAMS} ${BUILD_TARGETS}
51# cd ${S}
51# insinto /lib/modules/${KV_FULL}/usb 52# insinto /lib/modules/${KV_FULL}/usb
52# doins module_usb.${KV_OBJ} 53# doins module_usb.${KV_OBJ}
53# 54#
54# if the modulessourcedir isnt specified, it assumes ${S} 55# if the srcdir isnt specified, it assumes ${S}
55# if the libmodulesdir isnt specified, it assumes misc. 56# if the libdir isnt specified, it assumes misc.
56# if no seperator is defined ":" then it assumes the argument is modulesourcedir 57# if the objdir isnt specified, it assumes srcdir
58
59# There is also support for automatyed modules.d file generation.
60# This can be explicitly enabled by setting any of the following variables.
61#
62#
63# MODULESD_${modulename}_ENABLED This enables the modules.d file
64# generation even if we dont
65# specify any additional info.
66# MODULESD_${modulename}_EXAMPLES This is a bash array containing
67# a list of examples which should
68# be used. If you want us to try and
69# take a guess. Set this to "guess"
70# MODULESD_${modulename}_ALIASES This is a bash array containing
71# a list of associated aliases.
72# MODULESD_${modulename}_ADDITIONS This is a bash array containing
73# A list of additional things to
74# add to the bottom of the file.
75# This can be absolutely anything.
76# Each entry is a new line.
77# MODULES_${modulename}_DOCS This is a string list which contains
78# the full path to any associated
79# documents for $modulename
80
57 81
58inherit linux-info 82inherit linux-info
59ECLASS=linux-mod 83ECLASS=linux-mod
60INHERITED="$INHERITED $ECLASS" 84INHERITED="$INHERITED $ECLASS"
61EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst src_compile 85EXPORT_FUNCTIONS pkg_setup pkg_postinst src_install src_compile \
86 src_compile_userland src_install_userland
62 87
88SLOT="0"
63DESCRIPTION="Based on the $ECLASS eclass" 89DESCRIPTION="Based on the $ECLASS eclass"
64SLOT=0
65DEPEND="virtual/linux-sources 90DEPEND="virtual/linux-sources
66 sys-apps/sed 91 sys-apps/sed
67 virtual/modutils" 92 virtual/modutils"
93
68 94
69# eclass utilities 95# eclass utilities
70# ---------------------------------- 96# ----------------------------------
71 97
72use_m() { 98use_m() {
121 then 147 then
122 KV_OBJ="ko" 148 KV_OBJ="ko"
123 else 149 else
124 KV_OBJ="o" 150 KV_OBJ="o"
125 fi 151 fi
152 # Do we really need to know this?
153 # Lets silence it.
126 einfo "Using KV_OBJ=${KV_OBJ}" 154 # einfo "Using KV_OBJ=${KV_OBJ}"
127} 155}
128 156
129generate_modulesd() { 157generate_modulesd() {
130 # This function will generate the neccessary modules.d file from the 158 # This function will generate the neccessary modules.d file from the
131 # information contained in the modules exported parms 159 # information contained in the modules exported parms
132 160
133 local selectedmodule selectedmodule_full selectedmodulevars parameter modinfop arg xifs temp 161 local currm_path currm t myIFS myVAR
134 local module_docs module_opts module_aliases module_config 162 local module_docs module_enabled module_aliases \
135 163 module_additions module_examples module_modinfo module_opts
136 for arg in ${@}
137 do
138 selectedmodule_full="${arg}"
139 # strip the directory
140 selectedmodule="${selectedmodule_full/*\//}"
141 # convert the modulename to uppercase
142 selectedmodule="$(echo ${selectedmodule} | tr '[:lower:]' '[:upper:]')"
143 164
144 module_docs="MODULESD_${selectedmodule}_DOCS" 165 for currm_path in ${@}
166 do
167 currm=${currm_path//*\/}
168 currm=$(echo ${currm} | tr '[:lower:]' '[:upper:]')
169
170 module_docs="$(eval echo \${MODULESD_${currm}_DOCS})"
171 module_enabled="$(eval echo \${MODULESD_${currm}_ENABLED})"
145 module_aliases="$(eval echo \$\{#MODULESD_${selectedmodule}_ALIASES[*]\})" 172 module_aliases="$(eval echo \${#MODULESD_${currm}_ALIASES[*]})"
173 module_additions="$(eval echo \${#MODULESD_${currm}_ADDITIONS[*]})"
174 module_examples="$(eval echo \${#MODULESD_${currm}_EXAMPLES[*]})"
175
146 [ ${module_aliases} == 0 ] && unset module_aliases 176 [ ${module_aliases} -eq 0 ] && unset module_aliases
147 module_docs="${!module_docs}" 177 [ ${module_additions} -eq 0 ] && unset module_additions
148 modinfop="$(modinfo -p ${selectedmodule_full}.${KV_OBJ})" 178 [ ${module_examples} -eq 0 ] && unset module_examples
149 179
150 # By now we know if there is anything we can use to generate a file with 180 # If we specify we dont want it, then lets exit, otherwise we assume
151 # so unset empty vars and bail out if we find nothing. 181 # that if its set, we do want it.
182 [[ ${module_enabled} == no ]] && return 0
183
184 # unset any unwanted variables.
152 for parameter in ${!module_*} 185 for t in ${!module_*}
153 do 186 do
154 [ -z "${!parameter}" ] && unset ${parameter} 187 [[ -z ${!t} ]] && unset ${t}
155 done 188 done
156 [ -z "${!module_*}" -a -z "${modinfop}" ] && return
157 189
158 #so now we can set the configfilevar 190 [[ -z ${!module_*} ]] && return 0
191
192 # OK so now if we have got this far, then we know we want to continue
193 # and generate the modules.d file.
194 module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})"
159 module_config="${T}/modulesd-${selectedmodule}" 195 module_config="${T}/modulesd-${currm}"
160 196
161 # and being working on things.
162 ebegin "Preparing file for modules.d" 197 ebegin "Preparing file for modules.d"
198 #-----------------------------------------------------------------------
163 echo "# modules.d config file for ${selectedmodule}" >> ${module_config} 199 echo "# modules.d configuration file for ${currm}" >> ${module_config}
164 echo "# this file was automatically generated from linux-mod.eclass" >> ${module_config} 200 #-----------------------------------------------------------------------
201 [[ -n ${module_docs} ]] && \
202 echo "# For more information please read:" >> ${module_config}
165 for temp in ${module_docs} 203 for t in ${module_docs}
166 do 204 do
167 echo "# Please read ${temp/*\//} for more info" >> ${module_config} 205 echo "# ${t//*\/}" >> ${module_config}
168 done 206 done
169
170 if [ ${module_aliases} > 0 ];
171 then
172 echo >> ${module_config} 207 echo >> ${module_config}
208
209 #-----------------------------------------------------------------------
210 if [ ${module_aliases} -gt 0 ]
211 then
173 echo "# Internal Aliases - Do not edit" >> ${module_config} 212 echo "# Internal Aliases - Do not edit" >> ${module_config}
174 echo "# ------------------------------" >> ${module_config} 213 echo "# ------------------------------" >> ${module_config}
175 214
176 (( module_aliases-- )) 215 for((t=0; t<${module_aliases}; t++))
177 for temp in $(seq 0 ${module_aliases})
178 do 216 do
179 echo "alias $(eval echo \$\{MODULESD_${selectedmodule}_ALIASES[$temp]\})" >> ${module_config} 217 echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \
218 >> ${module_config}
180 done 219 done
220 echo '' >> ${module_config}
181 fi 221 fi
182 222
183 # and then stating any module parameters defined from the module 223 #-----------------------------------------------------------------------
184 if [ -n "${modinfop}" ]; 224 if [[ -n ${module_modinfo} ]]
185 then 225 then
186 echo >> ${module_config} 226 echo >> ${module_config}
187 echo "# Configurable module parameters" >> ${module_config} 227 echo "# Configurable module parameters" >> ${module_config}
188 echo "# ------------------------------" >> ${module_config} 228 echo "# ------------------------------" >> ${module_config}
189 229 myIFS="${IFS}"
190 xifs="${IFS}"
191 IFS="$(echo -en "\n\b")" 230 IFS="$(echo -en "\n\b")"
192 for parameter in ${modinfop} 231
232 for t in ${module_modinfo}
193 do 233 do
194 temp="$(echo ${parameter#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" 234 myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")"
195 if [ -n "${temp}" ]; 235 if [[ -n ${myVAR} ]]
196 then 236 then
197 module_opts="${module_opts} ${parameter%%:*}:${temp}" 237 module_opts="${module_opts} ${t%%:*}:${myVAR}"
198 fi 238 fi
199 echo -e "# ${parameter%%:*}:\t${parameter#*:}" >> ${module_config} 239 echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config}
240 done
241 IFS="${myIFS}"
242 echo '' >> ${module_config}
243 fi
244
245 #-----------------------------------------------------------------------
246 if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]]
247 then
248 # So lets do some guesswork eh?
249 if [[ -n ${module_opts} ]]
250 then
251 echo "# For Example..." >> ${module_config}
252 echo "# --------------" >> ${module_config}
253 for t in ${module_opts}
254 do
255 echo "# options ${currm} ${t//:*}=${t//*:}" >> ${module_config}
256 done
257 echo '' >> ${module_config}
258 fi
259 elif [ ${module_examples} -gt 0 ]
260 then
261 echo "# For Example..." >> ${module_config}
262 echo "# --------------" >> ${module_config}
263 for((t=0; t<${module_examples}; t++))
264 do
265 echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \
266 >> ${module_config}
200 done 267 done
201 IFS="${xifs}" 268 echo '' >> ${module_config}
269 fi
270
271 #-----------------------------------------------------------------------
272 if [ ${module_additions} -gt 0 ]
273 then
274 for((t=0; t<${module_additions}; t++))
275 do
276 echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \
277 >> ${module_config}
278 done
279 echo '' >> ${module_config}
202 fi 280 fi
203 281
204 # and any examples we can gather from them 282 #-----------------------------------------------------------------------
205 if [ -n "${module_opts}" ]; 283
206 then
207 echo >> ${module_config}
208 echo "# For Example..." >> ${module_config}
209 echo "# ------------------------------" >> ${module_config}
210 for parameter in ${module_opts}
211 do
212 echo "# options ${selectedmodule_full/*\//} ${parameter//:*}=${parameter//*:}" >> ${module_config}
213 done
214 fi
215
216 # then we install it 284 # then we install it
217 insinto /etc/modules.d 285 insinto /etc/modules.d
218 newins ${module_config} ${selectedmodule_full/*\//} 286 newins ${module_config} ${currm_path}
219 287
220 # and install any documentation we might have. 288 # and install any documentation we might have.
221 [ -n "${module_docs}" ] && dodoc ${module_docs} 289 [[ -n ${module_docs} ]] && dodoc ${module_docs}
222 done 290 done
223 eend 0 291 eend 0
292 return 0
224} 293}
225 294
226display_postinst() { 295display_postinst() {
227 # if we haven't determined the version yet, we need too. 296 # if we haven't determined the version yet, we need too.
228 get_version; 297 get_version;
302 check_kernel_built; 371 check_kernel_built;
303 check_modules_supported; 372 check_modules_supported;
304 set_kvobj; 373 set_kvobj;
305} 374}
306 375
376linux-mod_src_compile_userland() {
377 return 0
378}
379
380linux-mod_src_install_userland() {
381 return 0
382}
383
307linux-mod_src_compile() { 384linux-mod_src_compile() {
308 local modulename libdir srcdir objdir i n myARCH=${ARCH} 385 local modulename libdir srcdir objdir i n myARCH="${ARCH}"
309 unset ARCH 386 unset ARCH
310 387
311 BUILD_TARGETS=${BUILD_TARGETS:-clean module} 388 BUILD_TARGETS=${BUILD_TARGETS:-clean module}
312 389
313 for i in ${MODULE_IGNORE} 390 for i in ${MODULE_IGNORE}
314 do 391 do
315 MODULE_NAMES=${MODULE_NAMES//${i}(*} 392 MODULE_NAMES=${MODULE_NAMES//${i}(*}
341 ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}." 418 ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}."
342 touch ${srcdir}/.built 419 touch ${srcdir}/.built
343 cd ${OLDPWD} 420 cd ${OLDPWD}
344 fi 421 fi
345 done 422 done
346 423
347 ARCH=${myARCH} 424 ARCH="${myARCH}"
348} 425}
349 426
350linux-mod_src_install() { 427linux-mod_src_install() {
351 local modulename libdir srcdir objdir i n 428 local modulename libdir srcdir objdir i n
352 429
366 srcdir=${srcdir:-${S}} 443 srcdir=${srcdir:-${S}}
367 objdir=${objdir:-${srcdir}} 444 objdir=${objdir:-${srcdir}}
368 445
369 einfo "Installing ${modulename} module" 446 einfo "Installing ${modulename} module"
370 cd ${objdir} 447 cd ${objdir}
371
372 insinto /lib/modules/${KV_FULL}/${libdir} 448 insinto ${ROOT}lib/modules/${KV_FULL}/${libdir}
373 doins ${modulename}.${KV_OBJ} 449 doins ${modulename}.${KV_OBJ}
374 cd ${OLDPWD} 450 cd ${OLDPWD}
375 451
376 [ -z "${NO_MODULESD}" ] && generate_modulesd ${objdir}/${modulename} 452 generate_modulesd ${objdir}/${modulename}
377 done 453 done
378} 454}
379 455
380linux-mod_pkg_postinst() { 456linux-mod_pkg_postinst() {
381 update_depmod; 457 update_depmod;

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.20