/[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.16 Revision 1.19
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.16 2005/01/06 17:58:59 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.19 2005/01/15 21:19:02 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.
59 59
60DESCRIPTION="Based on the $ECLASS eclass" 60DESCRIPTION="Based on the $ECLASS eclass"
61SLOT=0 61SLOT=0
62DEPEND="virtual/linux-sources 62DEPEND="virtual/linux-sources
63 sys-apps/sed 63 sys-apps/sed
64 sys-apps/module-init-tools" 64 virtual/modutils"
65 65
66# eclass utilities 66# eclass utilities
67# ---------------------------------- 67# ----------------------------------
68 68
69use_m() { 69use_m() {
92 92
93 ebegin "Updating module dependencies for ${KV_FULL}" 93 ebegin "Updating module dependencies for ${KV_FULL}"
94 if [ -r ${KV_OUT_DIR}/System.map ] 94 if [ -r ${KV_OUT_DIR}/System.map ]
95 then 95 then
96 depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL} 96 depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL}
97 eend $?
97 else 98 else
98 ewarn 99 ewarn
99 ewarn "${KV_OUT_DIR}/System.map not found." 100 ewarn "${KV_OUT_DIR}/System.map not found."
100 ewarn "You must manually update the kernel module dependencies using depmod." 101 ewarn "You must manually update the kernel module dependencies using depmod."
102 eend 1
101 ewarn 103 ewarn
102 fi 104 fi
103 eend $?
104} 105}
105 106
106update_modules() { 107update_modules() {
107 if [ -x /sbin/modules-update ] ; 108 if [ -x /sbin/modules-update ] ;
108 then 109 then
245 einfo " # echo \"${modulename}\" >> ${file}" 246 einfo " # echo \"${modulename}\" >> ${file}"
246 done 247 done
247 echo 248 echo
248} 249}
249 250
251find_module_params() {
252 local matched_offset=0 matched_opts=0 test="${@}" temp_var result
253 local i=0 y=0 z=0
254
255 for((i=0; i<=${#test}; i++))
256 do
257 case ${test:${i}:1} in
258 \() matched_offset[0]=${i};;
259 \:) matched_opts=$((${matched_opts} + 1));
260 matched_offset[${matched_opts}]="${i}";;
261 \)) matched_opts=$((${matched_opts} + 1));
262 matched_offset[${matched_opts}]="${i}";;
263 esac
264 done
265
266 for((i=0; i<=${matched_opts}; i++))
267 do
268 # i = offset were working on
269 # y = last offset
270 # z = current offset - last offset
271 # temp_var = temporary name
272 case ${i} in
273 0) tempvar=${test:0:${matched_offset[0]}};;
274 *) y=$((${matched_offset[$((${i} - 1))]} + 1))
275 z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]}));
276 z=$((${z} - 1))
277 tempvar=${test:${y}:${z}};;
278 esac
279
280 case ${i} in
281 0) result="${result} modulename:${tempvar}";;
282 1) result="${result} libdir:${tempvar}";;
283 2) result="${result} srcdir:${tempvar}";;
284 3) result="${result} objdir:${tempvar}";;
285 esac
286 done
287
288 echo ${result}
289}
290
250# default ebuild functions 291# default ebuild functions
251# -------------------------------- 292# --------------------------------
252 293
253linux-mod_pkg_setup() { 294linux-mod_pkg_setup() {
254 linux-info_pkg_setup; 295 linux-info_pkg_setup;
256 check_modules_supported; 297 check_modules_supported;
257 set_kvobj; 298 set_kvobj;
258} 299}
259 300
260linux-mod_src_compile() { 301linux-mod_src_compile() {
261 local modulename moduledir sourcedir moduletemp xarch i 302 local modulename libdir srcdir objdir i n
262 xarch="${ARCH}"
263 unset ARCH
264 303
265 BUILD_TARGETS=${BUILD_TARGETS:-clean module} 304 BUILD_TARGETS=${BUILD_TARGETS:-clean module}
305 MODULE_NAMES=${MODULE_NAMES//${MODULE_IGNORE}}
266 306
267 for i in ${MODULE_NAMES} 307 for i in ${MODULE_NAMES}
268 do 308 do
269 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")" 309 for n in $(find_module_params ${i})
270 modulename="${moduletemp/ */}" 310 do
271 moduletemp="${moduletemp/* /}" 311 eval ${n/:*}=${n/*:/}
272 # if we specify two args, then we can set moduledir 312 done
273 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}" 313 libdir=${libdir:-misc}
274 # if we didnt pass the brackets, then we shouldnt accept anything
275 [ -n "${moduletemp/${modulename}/}" ] && sourcedir="${moduletemp/*:/}"
276 moduledir="${moduledir:-misc}"
277 sourcedir="${sourcedir:-${S}}" 314 srcdir=${srcdir:-${S}}
315 objdir=${objdir:-${srcdir}}
278 316
279 if [ ! -f "${sourcedir}/.built" ]; 317 if [ ! -f "${srcdir}/.built" ];
280 then 318 then
281 cd ${sourcedir} 319 cd ${srcdir}
282 einfo "Preparing ${modulename} module" 320 einfo "Preparing ${modulename} module"
283 emake ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} || \ 321 env -u ARCH emake ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} \
322 || die "Unable to make \
284 die Unable to make ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}. 323 ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}."
285 touch ${sourcedir}/.built 324 touch ${srcdir}/.built
286 cd ${OLDPWD} 325 cd ${OLDPWD}
287 fi 326 fi
288 done 327 done
289 ARCH="${xarch}"
290} 328}
291 329
292linux-mod_src_install() { 330linux-mod_src_install() {
293 local modulename moduledir sourcedir moduletemp i 331 local modulename libdir srcdir objdir i n
294 332
295 for i in ${MODULE_NAMES} 333 for i in ${MODULE_NAMES}
296 do 334 do
297 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")" 335 for n in $(find_module_params ${i})
298 modulename="${moduletemp/ */}" 336 do
299 moduletemp="${moduletemp/* /}" 337 eval ${n/:*}=${n/*:/}
300 # if we specify two args, then we can set moduledir 338 done
301 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}" 339 libdir=${libdir:-misc}
302 # if we didnt pass the brackets, then we shouldnt accept anything
303 [ -n "${moduletemp/${modulename}/}" ] && sourcedir="${moduletemp/*:/}"
304 moduledir="${moduledir:-misc}"
305 sourcedir="${sourcedir:-${S}}" 340 srcdir=${srcdir:-${S}}
341 objdir=${objdir:-${srcdir}}
306 342
307 einfo "Installing ${modulename} module" 343 einfo "Installing ${modulename} module"
308 cd ${sourcedir} 344 cd ${objdir}
345
309 insinto /lib/modules/${KV_FULL}/${moduledir} 346 insinto /lib/modules/${KV_FULL}/${libdir}
310 doins ${modulename}.${KV_OBJ} 347 doins ${modulename}.${KV_OBJ}
311 cd ${OLDPWD} 348 cd ${OLDPWD}
312 349
313 [ -z "${NO_MODULESD}" ] && generate_modulesd ${sourcedir}/${modulename} 350 [ -z "${NO_MODULESD}" ] && generate_modulesd ${objdir}/${modulename}
314 done 351 done
315} 352}
316 353
317linux-mod_pkg_postinst() { 354linux-mod_pkg_postinst() {
318 update_depmod; 355 update_depmod;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.20