| 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.10 2004/12/14 18:56:46 johnm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.11 2004/12/18 16:00:10 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. |
| … | |
… | |
| 54 | EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile |
54 | EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile |
| 55 | |
55 | |
| 56 | DESCRIPTION="Based on the $ECLASS eclass" |
56 | DESCRIPTION="Based on the $ECLASS eclass" |
| 57 | SLOT=0 |
57 | SLOT=0 |
| 58 | DEPEND="virtual/linux-sources |
58 | DEPEND="virtual/linux-sources |
| 59 | sys-apps/sed" |
59 | sys-apps/sed |
|
|
60 | sys-apps/module-init-tools" |
| 60 | |
61 | |
| 61 | # eclass utilities |
62 | # eclass utilities |
| 62 | # ---------------------------------- |
63 | # ---------------------------------- |
| 63 | |
64 | |
| 64 | use_m() { |
65 | use_m() { |
| … | |
… | |
| 113 | KV_OBJ="ko" |
114 | KV_OBJ="ko" |
| 114 | else |
115 | else |
| 115 | KV_OBJ="o" |
116 | KV_OBJ="o" |
| 116 | fi |
117 | fi |
| 117 | einfo "Using KV_OBJ=${KV_OBJ}" |
118 | einfo "Using KV_OBJ=${KV_OBJ}" |
|
|
119 | } |
|
|
120 | |
|
|
121 | generate_modulesd() { |
|
|
122 | # This function will generate the neccessary modules.d file from the |
|
|
123 | # information contained in the modules exported parms |
|
|
124 | |
|
|
125 | local selectedmodule selectedmodule_full selectedmodulevars parameter modinfop arg xifs temp |
|
|
126 | local module_docs module_opts module_aliases module_config |
|
|
127 | |
|
|
128 | for arg in ${@} |
|
|
129 | do |
|
|
130 | # convert the modulename to uppercase |
|
|
131 | selectedmodule_full="${arg}" |
|
|
132 | selectedmodule="${selectedmodule_full/*\//}" |
|
|
133 | selectedmodule="$(echo ${selectedmodule} | tr '[:lower:]' '[:upper:]')" |
|
|
134 | |
|
|
135 | module_docs="MODULESD_${selectedmodule}_DOCS" |
|
|
136 | module_aliases="$(eval echo \$\{#MODULESD_${selectedmodule}_ALIASES[*]\})" |
|
|
137 | module_docs="${!module_docs}" |
|
|
138 | |
|
|
139 | for parameter in ${!module_*} |
|
|
140 | do |
|
|
141 | [ -z "${!parameter}" ] && unset ${parameter} |
|
|
142 | done |
|
|
143 | |
|
|
144 | # OK, so now ${!module_*} only contains stuff from the ebuild. |
|
|
145 | # now we can do some proper work! |
|
|
146 | [ -z "${!module_*}" ] && return |
|
|
147 | |
|
|
148 | module_config="${T}/modulesd-${selectedmodule}" |
|
|
149 | |
|
|
150 | ebegin "Preparing file for modules.d" |
|
|
151 | echo "# modules.d config file for ${selectedmodule}" >> ${module_config} |
|
|
152 | echo "# this file was automatically generated from linux-mod.eclass" >> ${module_config} |
|
|
153 | echo "# on behalf of ${EBUILD/*\//}" >> ${module_config} |
|
|
154 | for temp in ${module_docs} |
|
|
155 | do |
|
|
156 | echo "# Please read ${temp/*\//} for more info" >> ${module_config} |
|
|
157 | done |
|
|
158 | |
|
|
159 | if [ ${module_aliases} -gt 0 ]; |
|
|
160 | then |
|
|
161 | echo "# Internal Aliases - Do not edit" >> ${module_config} |
|
|
162 | echo "# ------------------------------" >> ${module_config} |
|
|
163 | |
|
|
164 | (( module_aliases-- )) |
|
|
165 | for temp in $(seq 0 ${module_aliases}) |
|
|
166 | do |
|
|
167 | echo "alias $(eval echo \$\{MODULESD_${selectedmodule}_ALIASES[$temp]\})" >> ${module_config} |
|
|
168 | |
|
|
169 | done |
|
|
170 | fi |
|
|
171 | |
|
|
172 | modinfop="$(modinfo -p ${selectedmodule_full}.${KV_OBJ})" |
|
|
173 | if [ -n "${modinfop}" ]; |
|
|
174 | then |
|
|
175 | echo >> ${module_config} |
|
|
176 | echo "# Configurable module parameters" >> ${module_config} |
|
|
177 | echo "# ------------------------------" >> ${module_config} |
|
|
178 | |
|
|
179 | xifs="${IFS}" |
|
|
180 | IFS="$(echo -en "\n\b")" |
|
|
181 | for parameter in ${modinfop} |
|
|
182 | do |
|
|
183 | temp="$(echo ${parameter#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
|
|
184 | if [ -n "${temp}" ]; |
|
|
185 | then |
|
|
186 | module_opts="${module_opts} ${parameter%%:*}:${temp}" |
|
|
187 | fi |
|
|
188 | echo -e "# ${parameter%%:*}:\t${parameter#*:}" >> ${module_config} |
|
|
189 | done |
|
|
190 | IFS="${xifs}" |
|
|
191 | fi |
|
|
192 | |
|
|
193 | if [ -n "${module_opts}" ]; |
|
|
194 | then |
|
|
195 | echo >> ${module_config} |
|
|
196 | echo "# For Example..." >> ${module_config} |
|
|
197 | echo "# ------------------------------" >> ${module_config} |
|
|
198 | for parameter in ${module_opts} |
|
|
199 | do |
|
|
200 | echo "# options ${selectedmodule_full/*\//} ${parameter//:*}=${parameter//*:}" >> ${module_config} |
|
|
201 | done |
|
|
202 | fi |
|
|
203 | |
|
|
204 | insinto /etc/modules.d |
|
|
205 | newins ${module_config} ${selectedmodule_full/*\//} |
|
|
206 | |
|
|
207 | [ -n "${module_docs}" ] && dodoc ${module_docs} |
|
|
208 | done |
|
|
209 | eend 0 |
| 118 | } |
210 | } |
| 119 | |
211 | |
| 120 | display_postinst() { |
212 | display_postinst() { |
| 121 | # if we haven't determined the version yet, we need too. |
213 | # if we haven't determined the version yet, we need too. |
| 122 | get_version; |
214 | get_version; |
| … | |
… | |
| 197 | |
289 | |
| 198 | einfo "Installing ${modulename} module" |
290 | einfo "Installing ${modulename} module" |
| 199 | cd ${sourcedir} |
291 | cd ${sourcedir} |
| 200 | insinto /lib/modules/${KV_FULL}/${moduledir} |
292 | insinto /lib/modules/${KV_FULL}/${moduledir} |
| 201 | doins ${modulename}.${KV_OBJ} |
293 | doins ${modulename}.${KV_OBJ} |
|
|
294 | |
|
|
295 | generate_modulesd ${sourcedir}/${modulename} |
| 202 | done |
296 | done |
| 203 | } |
297 | } |
| 204 | |
298 | |
| 205 | linux-mod_pkg_postinst() { |
299 | linux-mod_pkg_postinst() { |
| 206 | update_depmod; |
300 | update_depmod; |