| 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.28 2005/02/01 10:02:02 johnm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.68 2006/10/16 14:10:46 genstef 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. |
| 9 | # |
9 | # |
| 10 | # Maintainer: John Mylchreest <johnm@gentoo.org> |
10 | # Maintainer: John Mylchreest <johnm@gentoo.org>, Stefan Schweizer <genstef@gentoo.org> |
| 11 | # Copyright 2004 Gentoo Linux |
11 | # Copyright 2004 Gentoo Linux |
| 12 | # |
12 | # |
| 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 |
22 | # If this is not set, then econf |
| 23 | # isn't 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 |
25 | # BUILD_TARGETS <string> clean modules The build targets to pass to |
| 26 | # make. |
26 | # make. |
| 27 | # MODULE_NAMES <string> This is the modules which are |
27 | # MODULE_NAMES <string> This is the modules which are |
| 28 | # to be built automatically using |
28 | # to be built automatically using |
| 29 | # the default pkg_compile/install. |
29 | # the default pkg_compile/install. |
| 30 | # They are explained properly |
30 | # They are explained properly |
| 31 | # below. It will only make |
31 | # below. It will only make |
| 32 | # BUILD_TARGETS once in any |
32 | # BUILD_TARGETS once in any |
| 33 | # directory. |
33 | # directory. |
| 34 | |
34 | |
| 35 | # MODULE_NAMES - Detailed Overview |
35 | # MODULE_NAMES - Detailed Overview |
| 36 | # |
36 | # |
| 37 | # The structure of each MODULE_NAMES entry is as follows: |
37 | # The structure of each MODULE_NAMES entry is as follows: |
| 38 | # modulename(libdir:srcdir:objdir) |
38 | # modulename(libdir:srcdir:objdir) |
| 39 | # for example: |
39 | # for example: |
| 40 | # MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})" |
40 | # MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})" |
| 41 | # |
41 | # |
| 42 | # what this would do is |
42 | # what this would do is |
| 43 | # cd ${S}/pci |
43 | # cd ${S}/pci |
| 44 | # make ${BUILD_PARAMS} ${BUILD_TARGETS} |
44 | # make ${BUILD_PARAMS} ${BUILD_TARGETS} |
| 45 | # cd ${S} |
45 | # cd ${S} |
| 46 | # insinto /lib/modules/${KV_FULL}/pci |
46 | # insinto /lib/modules/${KV_FULL}/pci |
| … | |
… | |
| 76 | # Each entry is a new line. |
76 | # Each entry is a new line. |
| 77 | # MODULES_${modulename}_DOCS This is a string list which contains |
77 | # MODULES_${modulename}_DOCS This is a string list which contains |
| 78 | # the full path to any associated |
78 | # the full path to any associated |
| 79 | # documents for $modulename |
79 | # documents for $modulename |
| 80 | |
80 | |
|
|
81 | # The order of these is important as both of linux-info and eutils contain |
|
|
82 | # set_arch_to_kernel and set_arch_to_portage functions and the ones in eutils |
|
|
83 | # are deprecated in favor of the ones in linux-info. |
|
|
84 | # See http://bugs.gentoo.org/show_bug.cgi?id=127506 |
| 81 | |
85 | |
| 82 | inherit linux-info |
86 | inherit eutils linux-info multilib |
| 83 | ECLASS=linux-mod |
|
|
| 84 | INHERITED="$INHERITED $ECLASS" |
|
|
| 85 | EXPORT_FUNCTIONS pkg_setup pkg_postinst src_install src_compile \ |
87 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm |
| 86 | src_compile_userland src_install_userland |
|
|
| 87 | |
88 | |
|
|
89 | IUSE="kernel_linux" |
| 88 | SLOT="0" |
90 | SLOT="0" |
| 89 | DESCRIPTION="Based on the $ECLASS eclass" |
91 | DESCRIPTION="Based on the $ECLASS eclass" |
| 90 | DEPEND="virtual/linux-sources |
92 | RDEPEND="kernel_linux? ( virtual/modutils )" |
|
|
93 | DEPEND="${RDEPEND} |
| 91 | sys-apps/sed |
94 | sys-apps/sed" |
| 92 | virtual/modutils" |
|
|
| 93 | |
|
|
| 94 | |
95 | |
| 95 | # eclass utilities |
96 | # eclass utilities |
| 96 | # ---------------------------------- |
97 | # ---------------------------------- |
|
|
98 | |
|
|
99 | check_vermagic() { |
|
|
100 | local curr_gcc_ver=$(gcc -dumpversion) |
|
|
101 | local tmpfile old_chost old_gcc_ver result=0 |
|
|
102 | |
|
|
103 | tmpfile=`find ${KV_DIR}/ -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit` |
|
|
104 | tmpfile=${tmpfile//*usr/lib} |
|
|
105 | tmpfile=${tmpfile//\/include*} |
|
|
106 | old_chost=${tmpfile//*gcc\/} |
|
|
107 | old_chost=${old_chost//\/*} |
|
|
108 | old_gcc_ver=${tmpfile//*\/} |
|
|
109 | |
|
|
110 | if [[ -z ${old_gcc_ver} || -z ${old_chost} ]]; then |
|
|
111 | ewarn "" |
|
|
112 | ewarn "Unable to detect what version of GCC was used to compile" |
|
|
113 | ewarn "the kernel. Build will continue, but you may experience problems." |
|
|
114 | elif [[ ${curr_gcc_ver} != ${old_gcc_ver} ]]; then |
|
|
115 | ewarn "" |
|
|
116 | ewarn "The version of GCC you are using (${curr_gcc_ver}) does" |
|
|
117 | ewarn "not match the version of GCC used to compile the" |
|
|
118 | ewarn "kernel (${old_gcc_ver})." |
|
|
119 | result=1 |
|
|
120 | elif [[ ${CHOST} != ${old_chost} ]]; then |
|
|
121 | ewarn "" |
|
|
122 | ewarn "The current CHOST (${CHOST}) does not match the chost" |
|
|
123 | ewarn "used when compiling the kernel (${old_chost})." |
|
|
124 | result=1 |
|
|
125 | fi |
|
|
126 | |
|
|
127 | if [[ ${result} -gt 0 ]]; then |
|
|
128 | ewarn "" |
|
|
129 | ewarn "Build will not continue, because you will experience problems." |
|
|
130 | ewarn "To fix this either change the version of GCC you wish to use" |
|
|
131 | ewarn "to match the kernel, or recompile the kernel first." |
|
|
132 | die "GCC Version Mismatch." |
|
|
133 | fi |
|
|
134 | } |
| 97 | |
135 | |
| 98 | use_m() { |
136 | use_m() { |
| 99 | # if we haven't determined the version yet, we need too. |
137 | # if we haven't determined the version yet, we need too. |
| 100 | get_version; |
138 | get_version; |
| 101 | |
139 | |
| 102 | # if the kernel version is greater than 2.6.6 then we should use |
140 | # if the kernel version is greater than 2.6.6 then we should use |
| 103 | # M= instead of SUBDIRS= |
141 | # M= instead of SUBDIRS= |
| 104 | [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \ |
142 | [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \ |
| 105 | return 0 || return 1 |
143 | return 0 || return 1 |
| 106 | } |
144 | } |
| 107 | |
145 | |
| 108 | convert_to_m() { |
146 | convert_to_m() { |
| 109 | [ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument" |
|
|
| 110 | if use_m |
147 | if use_m |
| 111 | then |
148 | then |
|
|
149 | [ ! -f "${1}" ] && \ |
|
|
150 | die "convert_to_m() requires a filename as an argument" |
| 112 | ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" |
151 | ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" |
| 113 | sed -i 's:SUBDIRS=:M=:g' ${1} |
152 | sed -i 's:SUBDIRS=:M=:g' ${1} |
| 114 | eend $? |
153 | eend $? |
| 115 | fi |
154 | fi |
| 116 | } |
155 | } |
| 117 | |
156 | |
| 118 | update_depmod() { |
157 | update_depmod() { |
| 119 | # if we haven't determined the version yet, we need too. |
158 | # if we haven't determined the version yet, we need too. |
| 120 | get_version; |
159 | get_version; |
| 121 | |
160 | |
| 122 | ebegin "Updating module dependencies for ${KV_FULL}" |
161 | ebegin "Updating module dependencies for ${KV_FULL}" |
| 123 | if [ -r ${KV_OUT_DIR}/System.map ] |
162 | if [ -r ${KV_OUT_DIR}/System.map ] |
| 124 | then |
163 | then |
| 125 | depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL} |
164 | depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL} |
| 126 | eend $? |
165 | eend $? |
| … | |
… | |
| 132 | ewarn |
171 | ewarn |
| 133 | fi |
172 | fi |
| 134 | } |
173 | } |
| 135 | |
174 | |
| 136 | update_modules() { |
175 | update_modules() { |
| 137 | if [ -x /sbin/modules-update -a \ |
176 | if [ -x /sbin/modules-update ] && \ |
| 138 | -n "$(grep -v -e "^#" -e "^$" ${D}/etc/modules.d/*)" ] ; then |
177 | grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then |
| 139 | ebegin "Updating modules.conf" |
178 | ebegin "Updating modules.conf" |
| 140 | /sbin/modules-update |
179 | /sbin/modules-update |
| 141 | eend $? |
180 | eend $? |
|
|
181 | fi |
|
|
182 | } |
|
|
183 | |
|
|
184 | move_old_moduledb() { |
|
|
185 | local OLDDIR=${ROOT}/usr/share/module-rebuild/ |
|
|
186 | local NEWDIR=${ROOT}/var/lib/module-rebuild/ |
|
|
187 | |
|
|
188 | if [[ -f ${OLDDIR}/moduledb ]]; then |
|
|
189 | [[ ! -d ${NEWDIR} ]] && mkdir -p ${NEWDIR} |
|
|
190 | [[ ! -f ${NEWDIR}/moduledb ]] && \ |
|
|
191 | mv ${OLDDIR}/moduledb ${NEWDIR}/moduledb |
|
|
192 | rm -f ${OLDDIR}/* |
|
|
193 | rmdir ${OLDDIR} |
|
|
194 | fi |
|
|
195 | } |
|
|
196 | |
|
|
197 | update_moduledb() { |
|
|
198 | local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/ |
|
|
199 | move_old_moduledb |
|
|
200 | |
|
|
201 | if [[ ! -f ${MODULEDB_DIR}/moduledb ]]; then |
|
|
202 | [[ ! -d ${MODULEDB_DIR} ]] && mkdir -p ${MODULEDB_DIR} |
|
|
203 | touch ${MODULEDB_DIR}/moduledb |
|
|
204 | fi |
|
|
205 | if [[ -z $(grep ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb) ]]; then |
|
|
206 | einfo "Adding module to moduledb." |
|
|
207 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${MODULEDB_DIR}/moduledb |
|
|
208 | fi |
|
|
209 | } |
|
|
210 | |
|
|
211 | remove_moduledb() { |
|
|
212 | local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/ |
|
|
213 | move_old_moduledb |
|
|
214 | |
|
|
215 | if [[ -n $(grep ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb) ]]; then |
|
|
216 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb." |
|
|
217 | sed -ie "/.*${CATEGORY}\/${PN}-${PVR}.*/d" ${MODULEDB_DIR}/moduledb |
| 142 | fi |
218 | fi |
| 143 | } |
219 | } |
| 144 | |
220 | |
| 145 | set_kvobj() { |
221 | set_kvobj() { |
| 146 | if kernel_is 2 6 |
222 | if kernel_is 2 6 |
| … | |
… | |
| 152 | # Do we really need to know this? |
228 | # Do we really need to know this? |
| 153 | # Lets silence it. |
229 | # Lets silence it. |
| 154 | # einfo "Using KV_OBJ=${KV_OBJ}" |
230 | # einfo "Using KV_OBJ=${KV_OBJ}" |
| 155 | } |
231 | } |
| 156 | |
232 | |
|
|
233 | get-KERNEL_CC() { |
|
|
234 | local kernel_cc |
|
|
235 | if [ -n "${KERNEL_ABI}" ]; then |
|
|
236 | # In future, an arch might want to define CC_$ABI |
|
|
237 | #kernel_cc="$(get_abi_CC)" |
|
|
238 | #[ -z "${kernel_cc}" ] && |
|
|
239 | kernel_cc="$(tc-getCC $(ABI=${KERNEL_ABI} get_abi_CHOST))" |
|
|
240 | else |
|
|
241 | kernel_cc=$(tc-getCC) |
|
|
242 | fi |
|
|
243 | echo "${kernel_cc}" |
|
|
244 | } |
|
|
245 | |
| 157 | generate_modulesd() { |
246 | generate_modulesd() { |
| 158 | # This function will generate the neccessary modules.d file from the |
247 | # This function will generate the neccessary modules.d file from the |
| 159 | # information contained in the modules exported parms |
248 | # information contained in the modules exported parms |
| 160 | |
249 | |
| 161 | local currm_path currm t myIFS myVAR |
250 | local currm_path currm currm_t t myIFS myVAR |
| 162 | local module_docs module_enabled module_aliases \ |
251 | local module_docs module_enabled module_aliases \ |
| 163 | module_additions module_examples module_modinfo module_opts |
252 | module_additions module_examples module_modinfo module_opts |
| 164 | |
253 | |
| 165 | for currm_path in ${@} |
254 | for currm_path in ${@} |
| 166 | do |
255 | do |
| 167 | currm=${currm_path//*\/} |
256 | currm=${currm_path//*\/} |
| 168 | currm=$(echo ${currm} | tr '[:lower:]' '[:upper:]') |
257 | currm=$(echo ${currm} | tr '[:lower:]' '[:upper:]') |
|
|
258 | currm_t=${currm} |
|
|
259 | while [[ -z ${currm_t//*-*} ]]; do |
|
|
260 | currm_t=${currm_t/-/_} |
|
|
261 | done |
| 169 | |
262 | |
| 170 | module_docs="$(eval echo \${MODULESD_${currm}_DOCS})" |
263 | module_docs="$(eval echo \${MODULESD_${currm_t}_DOCS})" |
| 171 | module_enabled="$(eval echo \${MODULESD_${currm}_ENABLED})" |
264 | module_enabled="$(eval echo \${MODULESD_${currm_t}_ENABLED})" |
| 172 | module_aliases="$(eval echo \${#MODULESD_${currm}_ALIASES[*]})" |
265 | module_aliases="$(eval echo \${#MODULESD_${currm_t}_ALIASES[*]})" |
| 173 | module_additions="$(eval echo \${#MODULESD_${currm}_ADDITIONS[*]})" |
266 | module_additions="$(eval echo \${#MODULESD_${currm_t}_ADDITIONS[*]})" |
| 174 | module_examples="$(eval echo \${#MODULESD_${currm}_EXAMPLES[*]})" |
267 | module_examples="$(eval echo \${#MODULESD_${currm_t}_EXAMPLES[*]})" |
| 175 | |
268 | |
| 176 | [[ ${module_aliases} -eq 0 ]] && unset module_aliases |
269 | [[ ${module_aliases} -eq 0 ]] && unset module_aliases |
| 177 | [[ ${module_additions} -eq 0 ]] && unset module_additions |
270 | [[ ${module_additions} -eq 0 ]] && unset module_additions |
| 178 | [[ ${module_examples} -eq 0 ]] && unset module_examples |
271 | [[ ${module_examples} -eq 0 ]] && unset module_examples |
| 179 | |
272 | |
| 180 | # If we specify we dont want it, then lets exit, otherwise we assume |
273 | # If we specify we dont want it, then lets exit, otherwise we assume |
| 181 | # that if its set, we do want it. |
274 | # that if its set, we do want it. |
| 182 | [[ ${module_enabled} == no ]] && return 0 |
275 | [[ ${module_enabled} == no ]] && return 0 |
| 183 | |
276 | |
| 184 | # unset any unwanted variables. |
277 | # unset any unwanted variables. |
| 185 | for t in ${!module_*} |
278 | for t in ${!module_*} |
| … | |
… | |
| 226 | echo >> ${module_config} |
319 | echo >> ${module_config} |
| 227 | echo "# Configurable module parameters" >> ${module_config} |
320 | echo "# Configurable module parameters" >> ${module_config} |
| 228 | echo "# ------------------------------" >> ${module_config} |
321 | echo "# ------------------------------" >> ${module_config} |
| 229 | myIFS="${IFS}" |
322 | myIFS="${IFS}" |
| 230 | IFS="$(echo -en "\n\b")" |
323 | IFS="$(echo -en "\n\b")" |
| 231 | |
324 | |
| 232 | for t in ${module_modinfo} |
325 | for t in ${module_modinfo} |
| 233 | do |
326 | do |
| 234 | myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
327 | myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
| 235 | if [[ -n ${myVAR} ]] |
328 | if [[ -n ${myVAR} ]] |
| 236 | then |
329 | then |
| 237 | module_opts="${module_opts} ${t%%:*}:${myVAR}" |
330 | module_opts="${module_opts} ${t%%:*}:${myVAR}" |
| 238 | fi |
331 | fi |
| 239 | echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config} |
332 | echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config} |
| 240 | done |
333 | done |
| 241 | IFS="${myIFS}" |
334 | IFS="${myIFS}" |
| 242 | echo '' >> ${module_config} |
335 | echo '' >> ${module_config} |
| 243 | fi |
336 | fi |
| 244 | |
337 | |
| 245 | #----------------------------------------------------------------------- |
338 | #----------------------------------------------------------------------- |
| … | |
… | |
| 276 | echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \ |
369 | echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \ |
| 277 | >> ${module_config} |
370 | >> ${module_config} |
| 278 | done |
371 | done |
| 279 | echo '' >> ${module_config} |
372 | echo '' >> ${module_config} |
| 280 | fi |
373 | fi |
| 281 | |
374 | |
| 282 | #----------------------------------------------------------------------- |
375 | #----------------------------------------------------------------------- |
| 283 | |
376 | |
| 284 | # then we install it |
377 | # then we install it |
| 285 | insinto /etc/modules.d |
378 | insinto /etc/modules.d |
| 286 | newins ${module_config} ${currm_path//*\/} |
379 | newins ${module_config} ${currm_path//*\/} |
| … | |
… | |
| 290 | done |
383 | done |
| 291 | eend 0 |
384 | eend 0 |
| 292 | return 0 |
385 | return 0 |
| 293 | } |
386 | } |
| 294 | |
387 | |
| 295 | display_postinst() { |
|
|
| 296 | # if we haven't determined the version yet, we need too. |
|
|
| 297 | get_version; |
|
|
| 298 | |
|
|
| 299 | local modulename moduledir sourcedir moduletemp file i |
|
|
| 300 | |
|
|
| 301 | file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR} |
|
|
| 302 | file=${file/\/\///} |
|
|
| 303 | |
|
|
| 304 | for i in ${MODULE_IGNORE} |
|
|
| 305 | do |
|
|
| 306 | MODULE_NAMES=${MODULE_NAMES//${i}(*} |
|
|
| 307 | done |
|
|
| 308 | |
|
|
| 309 | if [[ -n ${MODULE_NAMES} ]] |
|
|
| 310 | then |
|
|
| 311 | einfo "If you would like to load this module automatically upon boot" |
|
|
| 312 | einfo "please type the following as root:" |
|
|
| 313 | for i in ${MODULE_NAMES} |
|
|
| 314 | do |
|
|
| 315 | unset libdir srcdir objdir |
|
|
| 316 | for n in $(find_module_params ${i}) |
|
|
| 317 | do |
|
|
| 318 | eval ${n/:*}=${n/*:/} |
|
|
| 319 | done |
|
|
| 320 | einfo " # echo \"${modulename}\" >> ${file}" |
|
|
| 321 | done |
|
|
| 322 | einfo |
|
|
| 323 | fi |
|
|
| 324 | } |
|
|
| 325 | |
|
|
| 326 | find_module_params() { |
388 | find_module_params() { |
| 327 | local matched_offset=0 matched_opts=0 test="${@}" temp_var result |
389 | local matched_offset=0 matched_opts=0 test="${@}" temp_var result |
| 328 | local i=0 y=0 z=0 |
390 | local i=0 y=0 z=0 |
| 329 | |
391 | |
| 330 | for((i=0; i<=${#test}; i++)) |
392 | for((i=0; i<=${#test}; i++)) |
| 331 | do |
393 | do |
| 332 | case ${test:${i}:1} in |
394 | case ${test:${i}:1} in |
| 333 | \() matched_offset[0]=${i};; |
395 | \() matched_offset[0]=${i};; |
| 334 | \:) matched_opts=$((${matched_opts} + 1)); |
396 | \:) matched_opts=$((${matched_opts} + 1)); |
| 335 | matched_offset[${matched_opts}]="${i}";; |
397 | matched_offset[${matched_opts}]="${i}";; |
| 336 | \)) matched_opts=$((${matched_opts} + 1)); |
398 | \)) matched_opts=$((${matched_opts} + 1)); |
| 337 | matched_offset[${matched_opts}]="${i}";; |
399 | matched_offset[${matched_opts}]="${i}";; |
| 338 | esac |
400 | esac |
| 339 | done |
401 | done |
| 340 | |
402 | |
| 341 | for((i=0; i<=${matched_opts}; i++)) |
403 | for((i=0; i<=${matched_opts}; i++)) |
| 342 | do |
404 | do |
| 343 | # i = offset were working on |
405 | # i = offset were working on |
| 344 | # y = last offset |
406 | # y = last offset |
| 345 | # z = current offset - last offset |
407 | # z = current offset - last offset |
| … | |
… | |
| 349 | *) y=$((${matched_offset[$((${i} - 1))]} + 1)) |
411 | *) y=$((${matched_offset[$((${i} - 1))]} + 1)) |
| 350 | z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]})); |
412 | z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]})); |
| 351 | z=$((${z} - 1)) |
413 | z=$((${z} - 1)) |
| 352 | tempvar=${test:${y}:${z}};; |
414 | tempvar=${test:${y}:${z}};; |
| 353 | esac |
415 | esac |
| 354 | |
416 | |
| 355 | case ${i} in |
417 | case ${i} in |
| 356 | 0) result="${result} modulename:${tempvar}";; |
418 | 0) result="${result} modulename:${tempvar}";; |
| 357 | 1) result="${result} libdir:${tempvar}";; |
419 | 1) result="${result} libdir:${tempvar}";; |
| 358 | 2) result="${result} srcdir:${tempvar}";; |
420 | 2) result="${result} srcdir:${tempvar}";; |
| 359 | 3) result="${result} objdir:${tempvar}";; |
421 | 3) result="${result} objdir:${tempvar}";; |
| 360 | esac |
422 | esac |
| 361 | done |
423 | done |
| 362 | |
424 | |
| 363 | echo ${result} |
425 | echo ${result} |
| 364 | } |
426 | } |
| 365 | |
427 | |
| 366 | # default ebuild functions |
428 | # default ebuild functions |
| 367 | # -------------------------------- |
429 | # -------------------------------- |
| 368 | |
430 | |
| 369 | linux-mod_pkg_setup() { |
431 | linux-mod_pkg_setup() { |
| 370 | linux-info_pkg_setup; |
432 | linux-info_pkg_setup; |
| 371 | check_kernel_built; |
433 | check_kernel_built; |
| 372 | check_modules_supported; |
434 | strip_modulenames; |
|
|
435 | [[ -n ${MODULE_NAMES} ]] && check_modules_supported |
| 373 | set_kvobj; |
436 | set_kvobj; |
|
|
437 | # Commented out with permission from johnm until a fixed version for arches |
|
|
438 | # who intentionally use different kernel and userland compilers can be |
|
|
439 | # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005 |
|
|
440 | #check_vermagic; |
| 374 | } |
441 | } |
| 375 | |
442 | |
| 376 | linux-mod_src_compile_userland() { |
443 | strip_modulenames() { |
| 377 | return 0 |
444 | local i |
| 378 | } |
|
|
| 379 | |
|
|
| 380 | linux-mod_src_install_userland() { |
|
|
| 381 | return 0 |
|
|
| 382 | } |
|
|
| 383 | |
|
|
| 384 | linux-mod_src_compile() { |
|
|
| 385 | local modulename libdir srcdir objdir i n myARCH="${ARCH}" |
|
|
| 386 | unset ARCH |
|
|
| 387 | |
|
|
| 388 | BUILD_TARGETS=${BUILD_TARGETS:-clean module} |
|
|
| 389 | |
|
|
| 390 | for i in ${MODULE_IGNORE} |
445 | for i in ${MODULE_IGNORE}; do |
| 391 | do |
|
|
| 392 | MODULE_NAMES=${MODULE_NAMES//${i}(*} |
446 | MODULE_NAMES=${MODULE_NAMES//${i}(*} |
| 393 | done |
447 | done |
|
|
448 | } |
| 394 | |
449 | |
|
|
450 | linux-mod_src_compile() { |
|
|
451 | local modulename libdir srcdir objdir i n myARCH="${ARCH}" myABI="${ABI}" |
|
|
452 | ARCH="$(tc-arch-kernel)" |
|
|
453 | ABI="${KERNEL_ABI}" |
|
|
454 | CC_HOSTCC=$(tc-getBUILD_CC) |
|
|
455 | CC_CC=$(get-KERNEL_CC) |
|
|
456 | |
|
|
457 | BUILD_TARGETS=${BUILD_TARGETS:-clean module} |
|
|
458 | strip_modulenames; |
| 395 | for i in ${MODULE_NAMES} |
459 | for i in ${MODULE_NAMES} |
| 396 | do |
460 | do |
| 397 | unset libdir srcdir objdir |
461 | unset libdir srcdir objdir |
| 398 | for n in $(find_module_params ${i}) |
462 | for n in $(find_module_params ${i}) |
| 399 | do |
463 | do |
| 400 | eval ${n/:*}=${n/*:/} |
464 | eval ${n/:*}=${n/*:/} |
| 401 | done |
465 | done |
| 402 | libdir=${libdir:-misc} |
466 | libdir=${libdir:-misc} |
| 403 | srcdir=${srcdir:-${S}} |
467 | srcdir=${srcdir:-${S}} |
| 404 | objdir=${objdir:-${srcdir}} |
468 | objdir=${objdir:-${srcdir}} |
| 405 | |
469 | |
| 406 | if [ ! -f "${srcdir}/.built" ]; |
470 | if [ ! -f "${srcdir}/.built" ]; |
| 407 | then |
471 | then |
| 408 | cd ${srcdir} |
472 | cd ${srcdir} |
| 409 | einfo "Preparing ${modulename} module" |
473 | einfo "Preparing ${modulename} module" |
| 410 | if [[ -n ${ECONF_PARAMS} ]] |
474 | if [[ -n ${ECONF_PARAMS} ]] |
| 411 | then |
475 | then |
| 412 | econf ${ECONF_PARAMS} || \ |
476 | econf ${ECONF_PARAMS} || \ |
| 413 | die "Unable to run econf ${ECONF_PARAMS}" |
477 | die "Unable to run econf ${ECONF_PARAMS}" |
| 414 | fi |
478 | fi |
| 415 | |
479 | |
| 416 | emake ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} \ |
480 | emake HOSTCC=${CC_HOSTCC} CC=${CC_CC} LDFLAGS="$(get_abi_LDFLAGS)" \ |
| 417 | || die "Unable to make \ |
|
|
| 418 | ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}." |
481 | ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} \ |
|
|
482 | || die "Unable to make ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}." |
| 419 | touch ${srcdir}/.built |
483 | touch ${srcdir}/.built |
| 420 | cd ${OLDPWD} |
484 | cd ${OLDPWD} |
| 421 | fi |
485 | fi |
| 422 | done |
486 | done |
| 423 | |
487 | |
| 424 | ARCH="${myARCH}" |
488 | ARCH="${myARCH}" |
|
|
489 | ABI="${myABI}" |
| 425 | } |
490 | } |
| 426 | |
491 | |
| 427 | linux-mod_src_install() { |
492 | linux-mod_src_install() { |
| 428 | local modulename libdir srcdir objdir i n |
493 | local modulename libdir srcdir objdir i n |
| 429 | |
|
|
| 430 | for i in ${MODULE_IGNORE} |
|
|
| 431 | do |
|
|
| 432 | MODULE_NAMES=${MODULE_NAMES//${i}(*} |
|
|
| 433 | done |
|
|
| 434 | |
494 | |
|
|
495 | strip_modulenames; |
| 435 | for i in ${MODULE_NAMES} |
496 | for i in ${MODULE_NAMES} |
| 436 | do |
497 | do |
| 437 | unset libdir srcdir objdir |
498 | unset libdir srcdir objdir |
| 438 | for n in $(find_module_params ${i}) |
499 | for n in $(find_module_params ${i}) |
| 439 | do |
500 | do |
| … | |
… | |
| 442 | libdir=${libdir:-misc} |
503 | libdir=${libdir:-misc} |
| 443 | srcdir=${srcdir:-${S}} |
504 | srcdir=${srcdir:-${S}} |
| 444 | objdir=${objdir:-${srcdir}} |
505 | objdir=${objdir:-${srcdir}} |
| 445 | |
506 | |
| 446 | einfo "Installing ${modulename} module" |
507 | einfo "Installing ${modulename} module" |
| 447 | cd ${objdir} |
508 | cd ${objdir} || die "${objdir} does not exist" |
| 448 | insinto ${ROOT}lib/modules/${KV_FULL}/${libdir} |
509 | insinto /lib/modules/${KV_FULL}/${libdir} |
| 449 | doins ${modulename}.${KV_OBJ} |
510 | doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
| 450 | cd ${OLDPWD} |
511 | cd ${OLDPWD} |
| 451 | |
512 | |
| 452 | generate_modulesd ${objdir}/${modulename} |
513 | generate_modulesd ${objdir}/${modulename} |
| 453 | done |
514 | done |
| 454 | } |
515 | } |
| 455 | |
516 | |
|
|
517 | linux-mod_pkg_preinst() { |
|
|
518 | [ -d ${IMAGE}/lib/modules ] && UPDATE_DEPMOD=true || UPDATE_DEPMOD=false |
|
|
519 | [ -d ${IMAGE}/etc/modules.d ] && UPDATE_MODULES=true || UPDATE_MODULES=false |
|
|
520 | [ -d ${IMAGE}/lib/modules ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false |
|
|
521 | } |
|
|
522 | |
| 456 | linux-mod_pkg_postinst() { |
523 | linux-mod_pkg_postinst() { |
| 457 | update_depmod; |
524 | ${UPDATE_DEPMOD} && update_depmod; |
| 458 | update_modules; |
525 | ${UPDATE_MODULES} && update_modules; |
| 459 | display_postinst; |
526 | ${UPDATE_MODULEDB} && update_moduledb; |
| 460 | } |
527 | } |
|
|
528 | |
|
|
529 | linux-mod_pkg_postrm() { |
|
|
530 | remove_moduledb; |
|
|
531 | } |