/[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.17 Revision 1.18
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.17 2005/01/09 19:10:55 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.18 2005/01/15 20:40:14 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.
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}
266 305
267 for i in ${MODULE_NAMES} 306 for i in ${MODULE_NAMES}
268 do 307 do
269 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")" 308 for n in $(find_module_params ${i})
270 modulename="${moduletemp/ */}" 309 do
271 moduletemp="${moduletemp/* /}" 310 eval ${n/:*}=${n/*:/}
272 # if we specify two args, then we can set moduledir 311 done
273 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}" 312 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}}" 313 srcdir=${srcdir:-${S}}
314 objdir=${objdir:-${srcdir}}
278 315
279 if [ ! -f "${sourcedir}/.built" ]; 316 if [ ! -f "${srcdir}/.built" ];
280 then 317 then
281 cd ${sourcedir} 318 cd ${srcdir}
282 einfo "Preparing ${modulename} module" 319 einfo "Preparing ${modulename} module"
283 emake ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} || \ 320 env -u ARCH emake ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} \
321 || die "Unable to make \
284 die Unable to make ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}. 322 ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}."
285 touch ${sourcedir}/.built 323 touch ${srcdir}/.built
286 cd ${OLDPWD} 324 cd ${OLDPWD}
287 fi 325 fi
288 done 326 done
289 ARCH="${xarch}"
290} 327}
291 328
292linux-mod_src_install() { 329linux-mod_src_install() {
293 local modulename moduledir sourcedir moduletemp i 330 local modulename libdir srcdir objdir i n
294 331
295 for i in ${MODULE_NAMES} 332 for i in ${MODULE_NAMES}
296 do 333 do
297 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")" 334 for n in $(find_module_params ${i})
298 modulename="${moduletemp/ */}" 335 do
299 moduletemp="${moduletemp/* /}" 336 eval ${n/:*}=${n/*:/}
300 # if we specify two args, then we can set moduledir 337 done
301 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}" 338 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}}" 339 srcdir=${srcdir:-${S}}
340 objdir=${objdir:-${srcdir}}
306 341
307 einfo "Installing ${modulename} module" 342 einfo "Installing ${modulename} module"
308 cd ${sourcedir} 343 cd ${objdir}
344
309 insinto /lib/modules/${KV_FULL}/${moduledir} 345 insinto /lib/modules/${KV_FULL}/${libdir}
310 doins ${modulename}.${KV_OBJ} 346 doins ${modulename}.${KV_OBJ}
311 cd ${OLDPWD} 347 cd ${OLDPWD}
312 348
313 [ -z "${NO_MODULESD}" ] && generate_modulesd ${sourcedir}/${modulename} 349 [ -z "${NO_MODULESD}" ] && generate_modulesd ${objdir}/${modulename}
314 done 350 done
315} 351}
316 352
317linux-mod_pkg_postinst() { 353linux-mod_pkg_postinst() {
318 update_depmod; 354 update_depmod;

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.20