Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 217560
Collapse All | Expand All

(-)linux-mod.eclass.orig (-61 / +189 lines)
Lines 1-11 Link Here
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.81 2008/04/03 16:11:24 cardoe Exp $
3
# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.81 2008/04/03 16:11:24 cardoe Exp $
4
5
# Description: This eclass is used to interface with linux-info in such a way
6
#              to provide the functionality required and initial functions
7
#			   required to install external modules against a kernel source
8
#			   tree.
9
#
4
#
10
# Author(s): John Mylchreest <johnm@gentoo.org>,
5
# Author(s): John Mylchreest <johnm@gentoo.org>,
11
#            Stefan Schweizer <genstef@gentoo.org>
6
#            Stefan Schweizer <genstef@gentoo.org>
Lines 13-83 Link Here
13
#
8
#
14
# Please direct your bugs to the current eclass maintainer :)
9
# Please direct your bugs to the current eclass maintainer :)
15
10
11
# @ECLASS: linux-mod.eclass
12
# @MAINTAINER:
13
# kernel-misc@gentoo.org
14
# @BLURB: It provides the functionality required to install external modules against a kernel source tree.
15
# @DESCRIPTION:
16
# This eclass is used to interface with linux-info.eclass in such a way
17
# to provide the functionality and initial functions
18
# required to install external modules against a kernel source
19
# tree.
20
16
# A Couple of env vars are available to effect usage of this eclass
21
# A Couple of env vars are available to effect usage of this eclass
17
# These are as follows:
22
# These are as follows:
18
#
19
# Env Var		Option		Default		Description
20
# KERNEL_DIR		<string>	/usr/src/linux	The directory containing kernel
21
#							the target kernel sources.
22
# ECONF_PARAMS		<string>			The parameters to pass to econf.
23
#							If this is not set, then econf
24
#							isn't run.
25
# BUILD_PARAMS		<string>			The parameters to pass to emake.
26
# BUILD_TARGETS		<string>	clean modules	The build targets to pass to
27
#							make.
28
# MODULE_NAMES		<string>			This is the modules which are
29
#							to be built automatically using
30
#							the default pkg_compile/install.
31
#							They are explained properly
32
#							below. It will only make
33
#							BUILD_TARGETS once in any
34
#							directory.
35
23
36
# MODULE_NAMES - Detailed Overview
24
# @ECLASS-VARIABLE: KERNEL_DIR
25
# @DESCRIPTION:
26
# A string containing the directory of the target kernel sources. The default value is
27
# "/usr/src/linux"
28
29
# @ECLASS-VARIABLE: ECONF_PARAMS
30
# @DESCRIPTION:
31
# It's a string containing the parameters to pass to econf.
32
# If this is not set, then econf isn't run.
33
34
# @ECLASS-VARIABLE: BUILD_PARAMS
35
# @DESCRIPTION:
36
# It's a string with the parameters to pass to emake.
37
38
# @ECLASS-VARIABLE: BUILD_TARGETS
39
# @DESCRIPTION:
40
# It's a string with the build targets to pass to make. The default value is "clean modules"
41
42
# @ECLASS-VARIABLE: MODULE_NAMES
43
# @DESCRIPTION:
44
# It's a string containing the modules to be built automatically using the default
45
# src_compile/src_install. It will only make ${BUILD_TARGETS} once in any directory.
37
#
46
#
38
# The structure of each MODULE_NAMES entry is as follows:
47
# The structure of each MODULE_NAMES entry is as follows:
39
# modulename(libdir:srcdir:objdir)
48
#
40
# for example:
49
#   modulename(libdir:srcdir:objdir)
41
# MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})"
50
#
51
# where
52
#
53
#   modulename = name of the module file excluding the extension
54
#   libdir     = subdir inside /lib/modules/${KV_FULL}/ where to install the modules (by default it's misc)
55
#   srcdir     = place with the sources of the module (by default it's "${S}")
56
#   objdir     = directory where the kernel objects are placed during the compilation (by default it's set to srcdir)
57
#
58
# For example:
59
#
60
#   MODULE_NAMES="module_pci(pci:"${S}"/pci:"${S}") module_usb(usb:"${S}"/usb:"${S}")"
42
#
61
#
43
# what this would do is
62
# what this would do is
44
#  cd ${S}/pci
63
#
45
#  make ${BUILD_PARAMS} ${BUILD_TARGETS}
64
#   cd "${S}"/pci
46
#  cd ${S}
65
#   make ${BUILD_PARAMS} ${BUILD_TARGETS}
47
#  insinto /lib/modules/${KV_FULL}/pci
66
#   cd "${S}"
48
#  doins module_pci.${KV_OBJ}
67
#   insinto /lib/modules/${KV_FULL}/pci
49
#
68
#   doins module_pci.${KV_OBJ}
50
#  cd ${S}/usb
69
#
51
#  make ${BUILD_PARAMS} ${BUILD_TARGETS}
70
#   cd "${S}"/usb
52
#  cd ${S}
71
#   make ${BUILD_PARAMS} ${BUILD_TARGETS}
53
#  insinto /lib/modules/${KV_FULL}/usb
72
#   cd "${S}"
54
#  doins module_usb.${KV_OBJ}
73
#   insinto /lib/modules/${KV_FULL}/usb
55
#
74
#   doins module_usb.${KV_OBJ}
56
# if the srcdir isnt specified, it assumes ${S}
57
# if the libdir isnt specified, it assumes misc.
58
# if the objdir isnt specified, it assumes srcdir
59
75
60
# There is also support for automated modprobe.d/modules.d(2.4) file generation.
76
# There is also support for automated modprobe.d/modules.d(2.4) file generation.
61
# This can be explicitly enabled by setting any of the following variables.
77
# This can be explicitly enabled by setting any of the following variables.
78
79
# @ECLASS-VARIABLE: MODULESD_<modulename>_ENABLED
80
# @DESCRIPTION:
81
# This is used to disable the modprobe.d/modules.d file generation otherwise the file will be
82
# always generated (unless no MODULESD_<modulename>_* variable is provided). Set to "no" to disable
83
# the generation of the file and the installation of the documentation.
84
85
# @ECLASS-VARIABLE: MODULESD_<modulename>_EXAMPLES
86
# @DESCRIPTION:
87
# This is a bash array containing a list of examples which should
88
# be used. If you want us to try and take a guess set this to "guess".
89
#
90
# For each array_component it's added an options line in the modprobe.d/modules.d file
62
#
91
#
92
#   options array_component
63
#
93
#
64
# MODULESD_${modulename}_ENABLED		This enables the modules.d file
94
# where array_component is "<modulename> options" (see modprobe.conf(5))
65
#						generation even if we dont
95
66
#						specify any additional info.
96
# @ECLASS-VARIABLE: MODULESD_<modulename>_ALIASES
67
# MODULESD_${modulename}_EXAMPLES		This is a bash array containing
97
# @DESCRIPTION:
68
#						a list of examples which should
98
# This is a bash array containing a list of associated aliases.
69
#						be used. If you want us to try and
99
#
70
#						take a guess. Set this to "guess"
100
# For each array_component it's added an alias line in the modprobe.d/modules.d file
71
# MODULESD_${modulename}_ALIASES		This is a bash array containing
101
#
72
#						a list of associated aliases.
102
#   alias array_component
73
# MODULESD_${modulename}_ADDITIONS		This is a bash array containing
103
#
74
#						A list of additional things to
104
# where array_component is "wildcard <modulename>" (see modprobe.conf(5))
75
#						add to the bottom of the file.
105
76
#						This can be absolutely anything.
106
# @ECLASS-VARIABLE: MODULESD_<modulename>_ADDITIONS
77
#						Each entry is a new line.
107
# @DESCRIPTION:
78
# MODULES_${modulename}_DOCS			This is a string list which contains
108
# This is a bash array containing a list of additional things to
79
#						the full path to any associated
109
# add to the bottom of the file. This can be absolutely anything.
80
#						documents for $modulename
110
# Each entry is a new line.
111
112
# @ECLASS-VARIABLE: MODULESD_<modulename>_DOCS
113
# @DESCRIPTION:
114
# This is a string list which contains the full path to any associated
115
# documents for <modulename>. These files are installed in the live tree.
116
117
# @ECLASS-VARIABLE: KV_OBJ
118
# @DESCRIPTION:
119
# It's a read-only variable. It contains the extension of the kernel modules.
81
120
82
# The order of these is important as both of linux-info and eutils contain
121
# The order of these is important as both of linux-info and eutils contain
83
# set_arch_to_kernel and set_arch_to_portage functions and the ones in eutils
122
# set_arch_to_kernel and set_arch_to_portage functions and the ones in eutils
Lines 136-141 Link Here
136
	fi
175
	fi
137
}
176
}
138
177
178
# @FUNCTION: use_m
179
# @RETURN: true or false
180
# @DESCRIPTION:
181
# It checks if the kernel version is greater than 2.6.5.
139
use_m() {
182
use_m() {
140
	debug-print-function ${FUNCNAME} $*
183
	debug-print-function ${FUNCNAME} $*
141
184
Lines 148-153 Link Here
148
		return 0 || return 1
191
		return 0 || return 1
149
}
192
}
150
193
194
# @FUNCTION: convert_to_m
195
# @USAGE: /path/to/the/file
196
# @DESCRIPTION:
197
# It converts a file (e.g. a makefile) to use M= instead of SUBDIRS=
151
convert_to_m() {
198
convert_to_m() {
152
	debug-print-function ${FUNCNAME} $*
199
	debug-print-function ${FUNCNAME} $*
153
200
Lines 161-166 Link Here
161
	fi
208
	fi
162
}
209
}
163
210
211
# internal function
212
#
213
# FUNCTION: update_depmod
214
# DESCRIPTION:
215
# It updates the modules.dep file for the current kernel.
164
update_depmod() {
216
update_depmod() {
165
	debug-print-function ${FUNCNAME} $*
217
	debug-print-function ${FUNCNAME} $*
166
218
Lines 181-186 Link Here
181
	fi
233
	fi
182
}
234
}
183
235
236
# internal function
237
#
238
# FUNCTION: update_modules
239
# DESCRIPTION:
240
# It calls the update-modules utility.
184
update_modules() {
241
update_modules() {
185
	debug-print-function ${FUNCNAME} $*
242
	debug-print-function ${FUNCNAME} $*
186
243
Lines 197-202 Link Here
197
	fi
254
	fi
198
}
255
}
199
256
257
# internal function
258
#
259
# FUNCTION: move_old_moduledb
260
# DESCRIPTION:
261
# It updates the location of the database used by the module-rebuild utility.
200
move_old_moduledb() {
262
move_old_moduledb() {
201
	debug-print-function ${FUNCNAME} $*
263
	debug-print-function ${FUNCNAME} $*
202
264
Lines 212-217 Link Here
212
	fi
274
	fi
213
}
275
}
214
276
277
# internal function
278
#
279
# FUNCTION: update_moduledb
280
# DESCRIPTION:
281
# It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility.
215
update_moduledb() {
282
update_moduledb() {
216
	debug-print-function ${FUNCNAME} $*
283
	debug-print-function ${FUNCNAME} $*
217
284
Lines 229-234 Link Here
229
	fi
296
	fi
230
}
297
}
231
298
299
# internal function
300
#
301
# FUNCTION: remove_moduledb
302
# DESCRIPTION:
303
# It removes the package from the /var/lib/module-rebuild/moduledb database used by
304
# the module-rebuild utility.
232
remove_moduledb() {
305
remove_moduledb() {
233
	debug-print-function ${FUNCNAME} $*
306
	debug-print-function ${FUNCNAME} $*
234
307
Lines 241-246 Link Here
241
	fi
314
	fi
242
}
315
}
243
316
317
# @FUNCTION: set_kvobj
318
# @DESCRIPTION:
319
# It sets the KV_OBJ variable.
244
set_kvobj() {
320
set_kvobj() {
245
	debug-print-function ${FUNCNAME} $*
321
	debug-print-function ${FUNCNAME} $*
246
322
Lines 270-281 Link Here
270
	echo "${kernel_cc}"
346
	echo "${kernel_cc}"
271
}
347
}
272
348
349
# internal function
350
#
351
# FUNCTION:
352
# USAGE: /path/to/the/modulename_without_extension
353
# RETURN: A file in /etc/modules.d/ (kernel < 2.6) or /etc/modprobe.d/ (kernel >= 2.6)
354
# DESCRIPTION:
355
# This function will generate and install the neccessary modprobe.d/modules.d file from the
356
# information contained in the modules exported parms.
357
# (see the variables MODULESD_<modulename>_ENABLED, MODULESD_<modulename>_EXAMPLES,
358
# MODULESD_<modulename>_ALIASES, MODULESD_<modulename>_ADDITION and MODULESD_<modulename>_DOCS).
359
#
360
# At the end the documentation specified with MODULESD_<modulename>_DOCS is installed.
273
generate_modulesd() {
361
generate_modulesd() {
274
	debug-print-function ${FUNCNAME} $*
362
	debug-print-function ${FUNCNAME} $*
275
363
276
	# This function will generate the neccessary modules.d file from the
277
	# information contained in the modules exported parms
278
279
	local 	currm_path currm currm_t t myIFS myVAR
364
	local 	currm_path currm currm_t t myIFS myVAR
280
	local 	module_docs module_enabled module_aliases \
365
	local 	module_docs module_enabled module_aliases \
281
			module_additions module_examples module_modinfo module_opts
366
			module_additions module_examples module_modinfo module_opts
Lines 418-423 Link Here
418
	return 0
503
	return 0
419
}
504
}
420
505
506
# internal function
507
#
508
# FUNCTION: find_module_params
509
# USAGE: A string "NAME(LIBDIR:SRCDIR:OBJDIR)"
510
# RETURN: The string "modulename:NAME libdir:LIBDIR srcdir:SRCDIR objdir:OBJDIR"
511
# DESCRIPTION:
512
# Analyze the specification NAME(LIBDIR:SRCDIR:OBJDIR) of one module as described in MODULE_NAMES.
421
find_module_params() {
513
find_module_params() {
422
	debug-print-function ${FUNCNAME} $*
514
	debug-print-function ${FUNCNAME} $*
423
515
Lines 463-468 Link Here
463
# default ebuild functions
555
# default ebuild functions
464
# --------------------------------
556
# --------------------------------
465
557
558
# @FUNCTION: linux-mod_pkg_setup
559
# @DESCRIPTION:
560
# It checks the CONFIG_CHECK options (see linux-info.eclass(5)), verifies that the kernel is
561
# configured, verifies that the sources are prepared, verifies that the modules support is builtin
562
# in the kernel and sets the object extension KV_OBJ.
466
linux-mod_pkg_setup() {
563
linux-mod_pkg_setup() {
467
	debug-print-function ${FUNCNAME} $*
564
	debug-print-function ${FUNCNAME} $*
468
565
Lines 487-492 Link Here
487
	done
584
	done
488
}
585
}
489
586
587
# @FUNCTION: linux-mod_src_compile
588
# @DESCRIPTION:
589
# It compiles all the modules specified in MODULE_NAMES. For each module the econf command is
590
# executed only if ECONF_PARAMS is defined, the name of the target is specified by BUILD_TARGETS
591
# while the options are in BUILD_PARAMS (all the modules share these variables). The compilation
592
# happens inside ${srcdir}.
593
#
594
# Look at the description of these variables for more details.
490
linux-mod_src_compile() {
595
linux-mod_src_compile() {
491
	debug-print-function ${FUNCNAME} $*
596
	debug-print-function ${FUNCNAME} $*
492
597
Lines 539-544 Link Here
539
	ABI="${myABI}"
644
	ABI="${myABI}"
540
}
645
}
541
646
647
# @FUNCTION: linux-mod_src_install
648
# @DESCRIPTION:
649
# It install the modules specified in MODULES_NAME. The modules should be inside the ${objdir}
650
# directory and they are installed inside /lib/modules/${KV_FULL}/${libdir}.
651
#
652
# The modprobe.d/modules.d configuration file is automatically generated if the
653
# MODULESD_<modulename>_* variables are defined. The only way to stop this process is by
654
# setting MODULESD_<modulename>_ENABLED=no. At the end the documentation specified via
655
# MODULESD_<modulename>_DOCS is also installed.
656
#
657
# Look at the description of these variables for more details.
542
linux-mod_src_install() {
658
linux-mod_src_install() {
543
	debug-print-function ${FUNCNAME} $*
659
	debug-print-function ${FUNCNAME} $*
544
660
Lines 566-571 Link Here
566
	done
682
	done
567
}
683
}
568
684
685
# @FUNCTION: linux-mod_pkg_preinst
686
# @DESCRIPTION:
687
# It checks what to do after having merged the package.
569
linux-mod_pkg_preinst() {
688
linux-mod_pkg_preinst() {
570
	debug-print-function ${FUNCNAME} $*
689
	debug-print-function ${FUNCNAME} $*
571
690
Lines 574-579 Link Here
574
	[ -d "${D}lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false
693
	[ -d "${D}lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false
575
}
694
}
576
695
696
# @FUNCTION: linux-mod_pkg_postinst
697
# @DESCRIPTION:
698
# It executes /sbin/depmod and adds the package to the /var/lib/module-rebuild/moduledb
699
# database (if ${D}/lib/modules is created) and it runs /sbin/update-modules
700
# (if ${D}/etc/modules.d is created).
577
linux-mod_pkg_postinst() {
701
linux-mod_pkg_postinst() {
578
	debug-print-function ${FUNCNAME} $*
702
	debug-print-function ${FUNCNAME} $*
579
703
Lines 582-587 Link Here
582
	${UPDATE_MODULEDB} && update_moduledb;
706
	${UPDATE_MODULEDB} && update_moduledb;
583
}
707
}
584
708
709
# @FUNCTION: linux-mod_pkg_postrm
710
# @DESCRIPTION:
711
# It removes the package from the /var/lib/module-rebuild/moduledb database but it doens't
712
# call /sbin/depmod and /sbin/update-modules because the modules are still installed.
585
linux-mod_pkg_postrm() {
713
linux-mod_pkg_postrm() {
586
	debug-print-function ${FUNCNAME} $*
714
	debug-print-function ${FUNCNAME} $*
587
	remove_moduledb;
715
	remove_moduledb;

Return to bug 217560