/[gentoo-x86]/eclass/linux-info.eclass
Gentoo

Contents of /eclass/linux-info.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.55 - (hide annotations) (download)
Fri Mar 21 11:11:27 2008 UTC (6 years, 6 months ago) by dsd
Branch: MAIN
Changes since 1.54: +4 -4 lines
move get_version call to more sensible place, thanks to Jakub Moc and Sok Ann Yap in bug #213978

1 vapier 1.37 # Copyright 1999-2006 Gentoo Foundation
2 johnm 1.1 # Distributed under the terms of the GNU General Public License v2
3 dsd 1.55 # $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.54 2008/01/23 20:58:08 dsd Exp $
4 johnm 1.1 #
5 johnm 1.10 # Description: This eclass is used as a central eclass for accessing kernel
6     # related information for sources already installed.
7     # It is vital for linux-mod to function correctly, and is split
8     # out so that any ebuild behaviour "templates" are abstracted out
9     # using additional eclasses.
10 johnm 1.1 #
11 phreak 1.52 # Original author: John Mylchreest <johnm@gentoo.org>
12     # Maintainer: kernel-misc@gentoo.org
13 johnm 1.10 #
14     # Please direct your bugs to the current eclass maintainer :)
15    
16     # A Couple of env vars are available to effect usage of this eclass
17     # These are as follows:
18 swegener 1.29 #
19 johnm 1.21 # Env Var Option Description
20 johnm 1.10 # KERNEL_DIR <string> The directory containing kernel the target kernel
21 johnm 1.21 # sources.
22 johnm 1.10 # CONFIG_CHECK <string> a list of .config options to check for before
23 johnm 1.21 # proceeding with the install. ie: CONFIG_CHECK="MTRR"
24 swegener 1.29 # You can also check that an option doesn't exist by
25 johnm 1.21 # prepending it with an exclamation mark (!).
26     # ie: CONFIG_CHECK="!MTRR"
27 vapier 1.37 # To simply warn about a missing option, prepend a '~'.
28 johnm 1.21 # ERROR_CFG <string> The error message to display when the above check
29     # fails. <CFG> should reference the appropriate option
30 johnm 1.25 # as above. ie: ERROR_MTRR="MTRR exists in the .config
31 johnm 1.21 # but shouldn't!!"
32 johnm 1.10 # KBUILD_OUTPUT <string> This is passed on commandline, or can be set from
33 johnm 1.21 # the kernel makefile. This contains the directory
34     # which is to be used as the kernel object directory.
35 johnm 1.10
36     # There are also a couple of variables which are set by this, and shouldn't be
37     # set by hand. These are as follows:
38 swegener 1.29 #
39 johnm 1.10 # Env Var Option Description
40     # KV_FULL <string> The full kernel version. ie: 2.6.9-gentoo-johnm-r1
41     # KV_MAJOR <integer> The kernel major version. ie: 2
42     # KV_MINOR <integer> The kernel minor version. ie: 6
43     # KV_PATCH <integer> The kernel patch version. ie: 9
44     # KV_EXTRA <string> The kernel EXTRAVERSION. ie: -gentoo
45     # KV_LOCAL <string> The kernel LOCALVERSION concatenation. ie: -johnm
46     # KV_DIR <string> The kernel source directory, will be null if
47 johnm 1.21 # KERNEL_DIR is invalid.
48     # KV_OUT_DIR <string> The kernel object directory. will be KV_DIR unless
49     # koutput is used. This should be used for referencing
50     # .config.
51 johnm 1.10
52 johnm 1.21 # And to ensure all the weirdness with crosscompile
53 johnm 1.23 inherit toolchain-funcs versionator
54 johnm 1.1
55 johnm 1.8 EXPORT_FUNCTIONS pkg_setup
56 johnm 1.1
57 exg 1.40 DEPEND="kernel_linux? ( virtual/linux-sources )"
58 brix 1.39 RDEPEND=""
59    
60 johnm 1.1 # Overwritable environment Var's
61     # ---------------------------------------
62 johnm 1.21 KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
63 johnm 1.1
64 johnm 1.7
65 johnm 1.16 # Bug fixes
66     # fix to bug #75034
67     case ${ARCH} in
68 swegener 1.29 ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
69     ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
70 johnm 1.16 esac
71    
72 vapier 1.51 # @FUNCTION: set_arch_to_kernel
73     # @DESCRIPTION:
74     # Set the env ARCH to match what the kernel expects.
75     set_arch_to_kernel() { export ARCH=$(tc-arch-kernel); }
76     # @FUNCTION: set_arch_to_portage
77     # @DESCRIPTION:
78     # Set the env ARCH to match what portage expects.
79     set_arch_to_portage() { export ARCH=$(tc-arch); }
80 johnm 1.11
81     # qeinfo "Message"
82     # -------------------
83 johnm 1.21 # qeinfo is a quiet einfo call when EBUILD_PHASE
84 johnm 1.11 # should not have visible output.
85 johnm 1.21 qout() {
86     local outputmsg type
87     type=${1}
88     shift
89     outputmsg="${@}"
90 wolf31o2 1.26 case "${EBUILD_PHASE}" in
91     depend) unset outputmsg;;
92     clean) unset outputmsg;;
93     preinst) unset outputmsg;;
94     esac
95     [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
96 johnm 1.11 }
97    
98 johnm 1.21 qeinfo() { qout einfo "${@}" ; }
99     qeerror() { qout eerror "${@}" ; }
100 johnm 1.11
101 johnm 1.1 # File Functions
102     # ---------------------------------------
103    
104     # getfilevar accepts 2 vars as follows:
105     # getfilevar <VARIABLE> <CONFIGFILE>
106    
107     getfilevar() {
108 johnm 1.21 local ERROR workingdir basefname basedname myARCH="${ARCH}"
109 johnm 1.1 ERROR=0
110 johnm 1.16
111 johnm 1.1 [ -z "${1}" ] && ERROR=1
112     [ ! -f "${2}" ] && ERROR=1
113    
114     if [ "${ERROR}" = 1 ]
115     then
116 johnm 1.6 echo -e "\n"
117 johnm 1.1 eerror "getfilevar requires 2 variables, with the second a valid file."
118     eerror " getfilevar <VARIABLE> <CONFIGFILE>"
119     else
120 johnm 1.34 workingdir="${PWD}"
121     basefname="$(basename ${2})"
122     basedname="$(dirname ${2})"
123 johnm 1.6 unset ARCH
124 johnm 1.21
125 johnm 1.34 cd "${basedname}"
126 johnm 1.42 echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \
127 dsd 1.50 make M="${S}" ${BUILD_FIXES} -s -f - 2>/dev/null
128 johnm 1.34 cd "${workingdir}"
129 johnm 1.21
130     ARCH=${myARCH}
131 johnm 1.1 fi
132     }
133    
134 dsd 1.53
135     linux_config_exists() {
136     [ -s "${KV_OUT_DIR}/.config" ]
137     }
138    
139     require_configured_kernel() {
140     if ! linux_config_exists; then
141     qeerror "Could not find a usable .config in the kernel source directory."
142     qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
143     qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
144     qeerror "it points to the necessary object directory so that it might find .config."
145     die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
146     fi
147     }
148    
149 johnm 1.7 linux_chkconfig_present() {
150 johnm 1.1 local RESULT
151 dsd 1.53 require_configured_kernel
152 johnm 1.7 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
153 johnm 1.1 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
154     }
155    
156 johnm 1.7 linux_chkconfig_module() {
157 johnm 1.1 local RESULT
158 dsd 1.53 require_configured_kernel
159 johnm 1.7 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
160 johnm 1.1 [ "${RESULT}" = "m" ] && return 0 || return 1
161     }
162    
163 johnm 1.7 linux_chkconfig_builtin() {
164 johnm 1.1 local RESULT
165 dsd 1.53 require_configured_kernel
166 johnm 1.7 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
167 johnm 1.1 [ "${RESULT}" = "y" ] && return 0 || return 1
168     }
169    
170 johnm 1.7 linux_chkconfig_string() {
171 dsd 1.53 require_configured_kernel
172 johnm 1.7 getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config"
173     }
174    
175 johnm 1.1 # Versioning Functions
176     # ---------------------------------------
177    
178     # kernel_is returns true when the version is the same as the passed version
179     #
180     # For Example where KV = 2.6.9
181     # kernel_is 2 4 returns false
182     # kernel_is 2 returns true
183     # kernel_is 2 6 returns true
184     # kernel_is 2 6 8 returns false
185     # kernel_is 2 6 9 returns true
186 johnm 1.3 #
187 johnm 1.1 # got the jist yet?
188    
189     kernel_is() {
190 dsd 1.53 # if we haven't determined the version yet, we need to.
191     get_version
192 johnm 1.23 local operator test value x=0 y=0 z=0
193    
194     case ${1} in
195     lt) operator="-lt"; shift;;
196     gt) operator="-gt"; shift;;
197     le) operator="-le"; shift;;
198     ge) operator="-ge"; shift;;
199     eq) operator="-eq"; shift;;
200     *) operator="-eq";;
201     esac
202    
203     for x in ${@}; do
204     for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
205     value="${value}${x}"
206     z=$((${z} + 1))
207    
208     case ${z} in
209     1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do test="${test}0"; done;
210     test="${test}${KV_MAJOR}";;
211     2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do test="${test}0"; done;
212     test="${test}${KV_MINOR}";;
213     3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
214     test="${test}${KV_PATCH}";;
215     *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
216     esac
217     done
218 johnm 1.12
219 swegener 1.29 [ ${test} ${operator} ${value} ] && return 0 || return 1
220 johnm 1.1 }
221    
222 johnm 1.30 get_localversion() {
223     local lv_list i x
224    
225     # ignore files with ~ in it.
226     for i in $(ls ${1}/localversion* 2>/dev/null); do
227     [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}"
228     done
229    
230     for i in ${lv_list}; do
231     x="${x}$(<${i})"
232     done
233     x=${x/ /}
234     echo ${x}
235     }
236    
237 johnm 1.1 get_version() {
238 johnm 1.4 local kbuild_output
239 swegener 1.29
240 johnm 1.1 # no need to execute this twice assuming KV_FULL is populated.
241     # we can force by unsetting KV_FULL
242 johnm 1.19 [ -n "${KV_FULL}" ] && return 0
243 johnm 1.1
244     # if we dont know KV_FULL, then we need too.
245     # make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR
246     unset KV_DIR
247    
248     # KV_DIR will contain the full path to the sources directory we should use
249 johnm 1.11 qeinfo "Determining the location of the kernel source code"
250 johnm 1.1 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
251     [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
252 swegener 1.29
253 johnm 1.1 if [ -z "${KV_DIR}" ]
254     then
255 johnm 1.11 qeerror "Unable to find kernel sources at ${KERNEL_DIR}"
256     qeinfo "This package requires Linux sources."
257 johnm 1.7 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then
258 johnm 1.11 qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, "
259     qeinfo "(or the kernel you wish to build against)."
260     qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location"
261 johnm 1.7 else
262 johnm 1.11 qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against."
263 johnm 1.7 fi
264 johnm 1.19 return 1
265 johnm 1.7 fi
266    
267 johnm 1.11 qeinfo "Found kernel source directory:"
268     qeinfo " ${KV_DIR}"
269 johnm 1.7
270     if [ ! -s "${KV_DIR}/Makefile" ]
271     then
272 johnm 1.11 qeerror "Could not find a Makefile in the kernel source directory."
273     qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources"
274 johnm 1.19 return 1
275 johnm 1.7 fi
276 swegener 1.29
277 johnm 1.4 # OK so now we know our sources directory, but they might be using
278     # KBUILD_OUTPUT, and we need this for .config and localversions-*
279     # so we better find it eh?
280     # do we pass KBUILD_OUTPUT on the CLI?
281     OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}"
282 swegener 1.29
283 johnm 1.6 # And if we didn't pass it, we can take a nosey in the Makefile
284 johnm 1.4 kbuild_output="$(getfilevar KBUILD_OUTPUT ${KV_DIR}/Makefile)"
285     OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"
286 swegener 1.29
287 johnm 1.1 # And contrary to existing functions I feel we shouldn't trust the
288     # directory name to find version information as this seems insane.
289     # so we parse ${KV_DIR}/Makefile
290     KV_MAJOR="$(getfilevar VERSION ${KV_DIR}/Makefile)"
291     KV_MINOR="$(getfilevar PATCHLEVEL ${KV_DIR}/Makefile)"
292     KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)"
293     KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)"
294 swegener 1.29
295 johnm 1.7 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]
296     then
297 johnm 1.11 qeerror "Could not detect kernel version."
298 johnm 1.19 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources."
299     return 1
300 johnm 1.7 fi
301 swegener 1.29
302 johnm 1.1 # and in newer versions we can also pull LOCALVERSION if it is set.
303 johnm 1.4 # but before we do this, we need to find if we use a different object directory.
304     # This *WILL* break if the user is using localversions, but we assume it was
305     # caught before this if they are.
306 genstef 1.49 [ "${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}" == "$(uname -r)" ] && \
307     OUTPUT_DIR="${OUTPUT_DIR:-/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build}"
308 johnm 1.4
309     [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})"
310     [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
311     if [ -n "${KV_OUT_DIR}" ];
312     then
313 johnm 1.11 qeinfo "Found kernel object directory:"
314     qeinfo " ${KV_OUT_DIR}"
315 swegener 1.29
316 johnm 1.30 KV_LOCAL="$(get_localversion ${KV_OUT_DIR})"
317 johnm 1.4 fi
318 johnm 1.41 # and if we STILL have not got it, then we better just set it to KV_DIR
319 johnm 1.4 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
320 johnm 1.21
321 dsd 1.53 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
322     if linux_config_exists; then
323     KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
324     KV_LOCAL="${KV_LOCAL//\"/}"
325    
326     # For things like git that can append extra stuff:
327     [ -e ${KV_DIR}/scripts/setlocalversion ] &&
328     linux_chkconfig_builtin LOCALVERSION_AUTO &&
329     KV_LOCAL="${KV_LOCAL}$(sh ${KV_DIR}/scripts/setlocalversion ${KV_DIR})"
330 johnm 1.41 fi
331    
332 johnm 1.1 # And we should set KV_FULL to the full expanded version
333     KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
334 johnm 1.21
335 johnm 1.11 qeinfo "Found sources for kernel version:"
336     qeinfo " ${KV_FULL}"
337 johnm 1.21
338 johnm 1.19 return 0
339 johnm 1.1 }
340    
341 johnm 1.23 get_running_version() {
342     KV_FULL=$(uname -r)
343 johnm 1.1
344 johnm 1.23 if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
345     KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
346     unset KV_FULL
347     get_version
348     return $?
349     elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
350     KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
351     unset KV_FULL
352     get_version
353     return $?
354     else
355     KV_MAJOR=$(get_version_component_range 1 ${KV_FULL})
356     KV_MINOR=$(get_version_component_range 2 ${KV_FULL})
357     KV_PATCH=$(get_version_component_range 3- ${KV_FULL})
358     KV_PATCH=${KV_PATCH//-*}
359     [[ -n ${KV_FULL#*-} ]] && [[ -n ${KV_FULL//${KV_FULL#*-}} ]] \
360     && KV_EXTRA="-${KV_FULL#*-}"
361     fi
362     return 0
363     }
364 johnm 1.1
365    
366     # ebuild check functions
367     # ---------------------------------------
368    
369     check_kernel_built() {
370 dsd 1.53 # if we haven't determined the version yet, we need to
371 dsd 1.54 require_configured_kernel
372 dsd 1.53 get_version
373 swegener 1.29
374 johnm 1.16 if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ]
375 johnm 1.1 then
376 johnm 1.16 eerror "These sources have not yet been prepared."
377     eerror "We cannot build against an unprepared tree."
378 johnm 1.1 eerror "To resolve this, please type the following:"
379     eerror
380     eerror "# cd ${KV_DIR}"
381     eerror "# make oldconfig"
382 johnm 1.16 eerror "# make modules_prepare"
383 johnm 1.1 eerror
384     eerror "Then please try merging this module again."
385     die "Kernel sources need compiling first"
386     fi
387     }
388    
389     check_modules_supported() {
390     # if we haven't determined the version yet, we need too.
391 dsd 1.53 require_configured_kernel
392     get_version
393 swegener 1.29
394 johnm 1.7 if ! linux_chkconfig_builtin "MODULES"
395 johnm 1.1 then
396     eerror "These sources do not support loading external modules."
397     eerror "to be able to use this module please enable \"Loadable modules support\""
398     eerror "in your kernel, recompile and then try merging this module again."
399 johnm 1.7 die "No support for external modules in ${KV_FULL} config"
400 johnm 1.3 fi
401     }
402    
403     check_extra_config() {
404 mrness 1.45 local config negate die error reworkmodulenames
405 dsd 1.53 local soft_errors_count=0 hard_errors_count=0 config_required=0
406    
407 dsd 1.55 # if we haven't determined the version yet, we need to
408     get_version
409    
410 dsd 1.53 # Determine if we really need a .config. The only time when we don't need
411     # one is when all of the CONFIG_CHECK options are prefixed with "~".
412     for config in ${CONFIG_CHECK}
413     do
414     if [[ "${config:0:1}" != "~" ]]; then
415     config_required=1
416     break
417     fi
418     done
419    
420     if [[ ${config_required} == 0 ]]; then
421     # In the case where we don't require a .config, we can now bail out
422     # if the user has no .config as there is nothing to do. Otherwise
423     # code later will cause a failure due to missing .config.
424     if ! linux_config_exists; then
425     return 0
426     fi
427     else
428     require_configured_kernel
429     fi
430 johnm 1.3
431 mrness 1.45 einfo "Checking for suitable kernel configuration options..."
432 dsd 1.53
433 johnm 1.3 for config in ${CONFIG_CHECK}
434     do
435 johnm 1.31 # if we specify any fatal, ensure we honor them
436     die=1
437     error=0
438     negate=0
439     reworkmodulenames=0
440    
441 dsd 1.53 if [[ ${config:0:1} == "~" ]]; then
442 mrness 1.45 die=0
443 johnm 1.31 config=${config:1}
444 dsd 1.53 elif [[ ${config:0:1} == "@" ]]; then
445 mrness 1.45 die=0
446 johnm 1.31 reworkmodulenames=1
447     config=${config:1}
448     fi
449 dsd 1.53 if [[ ${config:0:1} == "!" ]]; then
450 mrness 1.45 negate=1
451 johnm 1.44 config=${config:1}
452     fi
453 johnm 1.17
454 johnm 1.31 if [[ ${negate} == 1 ]]; then
455     linux_chkconfig_present ${config} && error=2
456     elif [[ ${reworkmodulenames} == 1 ]]; then
457 mrness 1.45 local temp_config="${config//*:}" i n
458 johnm 1.17 config="${config//:*}"
459 johnm 1.31 if linux_chkconfig_present ${config}; then
460     for i in ${MODULE_NAMES}; do
461 johnm 1.17 n="${i//${temp_config}}"
462 dsd 1.38 [[ -z ${n//\(*} ]] && \
463 johnm 1.31 MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}"
464 johnm 1.17 done
465 johnm 1.31 error=2
466 johnm 1.17 fi
467 johnm 1.3 else
468 johnm 1.31 linux_chkconfig_present ${config} || error=1
469     fi
470    
471 mrness 1.45 if [[ ${error} > 0 ]]; then
472     local report_func="eerror" local_error
473     local_error="ERROR_${config}"
474     local_error="${!local_error}"
475    
476     if [[ -z "${local_error}" ]]; then
477     # using old, deprecated format.
478     local_error="${config}_ERROR"
479     local_error="${!local_error}"
480     fi
481     if [[ ${die} == 0 && -z "${local_error}" ]]; then
482     #soft errors can be warnings
483     local_error="WARNING_${config}"
484 johnm 1.7 local_error="${!local_error}"
485 mrness 1.45 if [[ -n "${local_error}" ]] ; then
486     report_func="ewarn"
487 johnm 1.44 fi
488 mrness 1.45 fi
489 johnm 1.44
490 mrness 1.45 if [[ -z "${local_error}" ]]; then
491     [[ ${error} == 1 ]] \
492     && local_error="is not set when it should be." \
493     || local_error="should not be set. But it is."
494     local_error="CONFIG_${config}:\t ${local_error}"
495     fi
496     if [[ ${die} == 0 ]]; then
497     ${report_func} " ${local_error}"
498     soft_errors_count=$[soft_errors_count + 1]
499     else
500     ${report_func} " ${local_error}"
501     hard_errors_count=$[hard_errors_count + 1]
502 johnm 1.3 fi
503     fi
504     done
505    
506 mrness 1.45 if [[ ${hard_errors_count} > 0 ]]; then
507 johnm 1.3 eerror "Please check to make sure these options are set correctly."
508 johnm 1.31 eerror "Failure to do so may cause unexpected problems."
509 mrness 1.45 eerror "Once you have satisfied these options, please try merging"
510     eerror "this package again."
511     die "Incorrect kernel configuration options"
512     elif [[ ${soft_errors_count} > 0 ]]; then
513     ewarn "Please check to make sure these options are set correctly."
514     ewarn "Failure to do so may cause unexpected problems."
515     else
516     eend 0
517 johnm 1.1 fi
518     }
519    
520     check_zlibinflate() {
521 dsd 1.53 # if we haven't determined the version yet, we need to
522     require_configured_kernel
523     get_version
524 swegener 1.29
525 johnm 1.1 # although I restructured this code - I really really really dont support it!
526    
527     # bug #27882 - zlib routines are only linked into the kernel
528     # if something compiled into the kernel calls them
529     #
530     # plus, for the cloop module, it appears that there's no way
531     # to get cloop.o to include a static zlib if CONFIG_MODVERSIONS
532     # is on
533 swegener 1.29
534     local INFLATE
535     local DEFLATE
536 johnm 1.1
537     einfo "Determining the usability of ZLIB_INFLATE support in your kernel"
538 swegener 1.29
539 johnm 1.1 ebegin "checking ZLIB_INFLATE"
540     getfilevar_isbuiltin CONFIG_ZLIB_INFLATE ${KV_DIR}/.config
541     eend $?
542     [ "$?" != 0 ] && die
543 swegener 1.29
544 johnm 1.1 ebegin "checking ZLIB_DEFLATE"
545     getfilevar_isbuiltin CONFIG_ZLIB_DEFLATE ${KV_DIR}/.config
546     eend $?
547     [ "$?" != 0 ] && die
548 swegener 1.29
549 johnm 1.1 local LINENO_START
550     local LINENO_END
551     local SYMBOLS
552     local x
553 swegener 1.29
554 johnm 1.1 LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)"
555     LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)"
556     (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ))
557     (( LINENO_END = $LINENO_END - 1 ))
558 johnm 1.4 SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')"
559 johnm 1.1
560     # okay, now we have a list of symbols
561     # we need to check each one in turn, to see whether it is set or not
562     for x in $SYMBOLS ; do
563     if [ "${!x}" = "y" ]; then
564     # we have a winner!
565     einfo "${x} ensures zlib is linked into your kernel - excellent"
566     return 0
567     fi
568     done
569 swegener 1.29
570 johnm 1.1 eerror
571     eerror "This kernel module requires ZLIB library support."
572     eerror "You have enabled zlib support in your kernel, but haven't enabled"
573     eerror "enabled any option that will ensure that zlib is linked into your"
574     eerror "kernel."
575     eerror
576     eerror "Please ensure that you enable at least one of these options:"
577     eerror
578    
579     for x in $SYMBOLS ; do
580     eerror " * $x"
581     done
582    
583     eerror
584     eerror "Please remember to recompile and install your kernel, and reboot"
585     eerror "into your new kernel before attempting to load this kernel module."
586    
587     die "Kernel doesn't include zlib support"
588     }
589 johnm 1.8
590     ################################
591     # Default pkg_setup
592     # Also used when inheriting linux-mod to force a get_version call
593    
594     linux-info_pkg_setup() {
595 johnm 1.19 get_version || die "Unable to calculate Linux Kernel version"
596 phreak 1.48
597     if kernel_is 2 4; then
598     if [ "$( gcc-major-version )" -eq "4" ] ; then
599     echo
600     ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with"
601     ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!"
602     echo
603     ewarn "Either switch to another gcc-version (via gcc-config) or use a"
604     ewarn "newer kernel that supports gcc-4."
605     echo
606     ewarn "Also be aware that bugreports about gcc-4 not working"
607     ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
608     echo
609     epause 10
610     fi
611     fi
612    
613 johnm 1.10 [ -n "${CONFIG_CHECK}" ] && check_extra_config;
614 johnm 1.8 }

  ViewVC Help
Powered by ViewVC 1.1.20