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

Diff of /eclass/linux-info.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.63 Revision 1.74
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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-info.eclass,v 1.63 2009/09/06 23:04:37 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.74 2009/12/11 20:42:51 robbat2 Exp $
4# 4#
5# Original author: John Mylchreest <johnm@gentoo.org> 5# Original author: John Mylchreest <johnm@gentoo.org>
6# Maintainer: kernel-misc@gentoo.org 6# Maintainer: kernel-misc@gentoo.org
7# 7#
8# Please direct your bugs to the current eclass maintainer :) 8# Please direct your bugs to the current eclass maintainer :)
108# And to ensure all the weirdness with crosscompile 108# And to ensure all the weirdness with crosscompile
109inherit toolchain-funcs versionator 109inherit toolchain-funcs versionator
110 110
111EXPORT_FUNCTIONS pkg_setup 111EXPORT_FUNCTIONS pkg_setup
112 112
113DEPEND=""
114RDEPEND=""
115
116[ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && \
113DEPEND="kernel_linux? ( virtual/linux-sources )" 117DEPEND="kernel_linux? ( virtual/linux-sources )"
114RDEPEND=""
115 118
116# Overwritable environment Var's 119# Overwritable environment Var's
117# --------------------------------------- 120# ---------------------------------------
118KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}" 121KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
119 122
200 ERROR=0 203 ERROR=0
201 mycat='cat' 204 mycat='cat'
202 205
203 [ -z "${1}" ] && ERROR=1 206 [ -z "${1}" ] && ERROR=1
204 [ ! -f "${2}" ] && ERROR=1 207 [ ! -f "${2}" ] && ERROR=1
205 [ "${2#.gz}" != "${2}" ] && mycat='zcat' 208 [ "${2%.gz}" != "${2}" ] && mycat='zcat'
206 209
207 if [ "${ERROR}" = 1 ] 210 if [ "${ERROR}" = 1 ]
208 then 211 then
209 echo -e "\n" 212 echo -e "\n"
210 eerror "getfilevar_noexec requires 2 variables, with the second a valid file." 213 eerror "getfilevar_noexec requires 2 variables, with the second a valid file."
232# @FUNCTION: linux_config_bin_exists 235# @FUNCTION: linux_config_bin_exists
233# @RETURN: true or false 236# @RETURN: true or false
234# @DESCRIPTION: 237# @DESCRIPTION:
235# It returns true if .config exists in /proc, otherwise false 238# It returns true if .config exists in /proc, otherwise false
236linux_config_bin_exists() { 239linux_config_bin_exists() {
237 [ -s "/proc/config.gz" ] 240 [ -n "${I_KNOW_WHAT_I_AM_DOING}" -a -s "/proc/config.gz" ]
238} 241}
239 242
240# @FUNCTION: linux_config_exists 243# @FUNCTION: linux_config_exists
241# @RETURN: true or false 244# @RETURN: true or false
242# @DESCRIPTION: 245# @DESCRIPTION:
349 352
350# got the jist yet? 353# got the jist yet?
351 354
352kernel_is() { 355kernel_is() {
353 # if we haven't determined the version yet, we need to. 356 # if we haven't determined the version yet, we need to.
354 get_version 357 linux-info_get_any_version
358
355 local operator test value x=0 y=0 z=0 359 local operator test value x=0 y=0 z=0
356 360
357 case ${1} in 361 case ${1} in
358 lt) operator="-lt"; shift;; 362 -lt|lt) operator="-lt"; shift;;
359 gt) operator="-gt"; shift;; 363 -gt|gt) operator="-gt"; shift;;
360 le) operator="-le"; shift;; 364 -le|le) operator="-le"; shift;;
361 ge) operator="-ge"; shift;; 365 -ge|ge) operator="-ge"; shift;;
362 eq) operator="-eq"; shift;; 366 -eq|eq) operator="-eq"; shift;;
363 *) operator="-eq";; 367 *) operator="-eq";;
364 esac 368 esac
365 369
366 for x in ${@}; do 370 for x in ${@}; do
367 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done 371 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
368 value="${value}${x}" 372 value="${value}${x}"
376 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done; 380 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
377 test="${test}${KV_PATCH}";; 381 test="${test}${KV_PATCH}";;
378 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 382 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
379 esac 383 esac
380 done 384 done
381 385
382 [ ${test} ${operator} ${value} ] && return 0 || return 1 386 [ ${test} ${operator} ${value} ] && return 0 || return 1
383} 387}
384 388
385get_localversion() { 389get_localversion() {
386 local lv_list i x 390 local lv_list i x
505 fi 509 fi
506 # and if we STILL have not got it, then we better just set it to KV_DIR 510 # and if we STILL have not got it, then we better just set it to KV_DIR
507 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 511 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
508 512
509 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})" 513 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
510 if linux_config_exists; then 514 if linux_config_src_exists; then
511 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)" 515 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
512 KV_LOCAL="${KV_LOCAL//\"/}" 516 KV_LOCAL="${KV_LOCAL//\"/}"
513 517
514 # For things like git that can append extra stuff: 518 # For things like git that can append extra stuff:
515 [ -e ${KV_DIR}/scripts/setlocalversion ] && 519 [ -e ${KV_DIR}/scripts/setlocalversion ] &&
552 && KV_EXTRA="-${KV_FULL#*-}" 556 && KV_EXTRA="-${KV_FULL#*-}"
553 fi 557 fi
554 return 0 558 return 0
555} 559}
556 560
561# This next function is named with the eclass prefix to avoid conflicts with
562# some old versionator-like eclass functions.
563
564# @FUNCTION: linux-info_get_any_version
565# @DESCRIPTION:
566# This attempts to find the version of the sources, and otherwise falls back to
567# the version of the running kernel.
568linux-info_get_any_version() {
569 get_version
570 if [[ $? -ne 0 ]]; then
571 ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
572 get_running_version
573 fi
574}
575
557 576
558# ebuild check functions 577# ebuild check functions
559# --------------------------------------- 578# ---------------------------------------
560 579
561# @FUNCTION: check_kernel_built 580# @FUNCTION: check_kernel_built
605check_extra_config() { 624check_extra_config() {
606 local config negate die error reworkmodulenames 625 local config negate die error reworkmodulenames
607 local soft_errors_count=0 hard_errors_count=0 config_required=0 626 local soft_errors_count=0 hard_errors_count=0 config_required=0
608 627
609 # if we haven't determined the version yet, we need to 628 # if we haven't determined the version yet, we need to
610 get_version 629 linux-info_get_any_version
611 630
612 # Determine if we really need a .config. The only time when we don't need 631 # Determine if we really need a .config. The only time when we don't need
613 # one is when all of the CONFIG_CHECK options are prefixed with "~". 632 # one is when all of the CONFIG_CHECK options are prefixed with "~".
614 for config in ${CONFIG_CHECK} 633 for config in ${CONFIG_CHECK}
615 do 634 do
617 config_required=1 636 config_required=1
618 break 637 break
619 fi 638 fi
620 done 639 done
621 640
641 # TODO: After we enable the new code for /proc/config.gz, we need to
642 # change this back to linux_config_exists.
622 if [[ ${config_required} == 0 ]]; then 643 if [[ ${config_required} == 0 ]]; then
623 # In the case where we don't require a .config, we can now bail out 644 # In the case where we don't require a .config, we can now bail out
624 # if the user has no .config as there is nothing to do. Otherwise 645 # if the user has no .config as there is nothing to do. Otherwise
625 # code later will cause a failure due to missing .config. 646 # code later will cause a failure due to missing .config.
626 if ! linux_config_exists; then 647 if ! linux_config_src_exists; then
627 ewarn "Unable to check for the following kernel config options due" 648 ewarn "Unable to check for the following kernel config options due"
628 ewarn "to absence of any configured kernel sources:" 649 ewarn "to absence of any configured kernel sources or compiled"
650 ewarn "config:"
629 for config in ${CONFIG_CHECK}; do 651 for config in ${CONFIG_CHECK}; do
630 ewarn " - ${config#\~}" 652 ewarn " - ${config#\~}"
631 done 653 done
632 ewarn "You're on your own to make sure they are set if needed." 654 ewarn "You're on your own to make sure they are set if needed."
633 return 0 655 return 0
634 fi 656 fi
635 else 657 else
636 require_configured_kernel 658 [ -n "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
637 fi 659 fi
638 660
639 einfo "Checking for suitable kernel configuration options..." 661 einfo "Checking for suitable kernel configuration options..."
640 662
641 for config in ${CONFIG_CHECK} 663 for config in ${CONFIG_CHECK}
801# @FUNCTION: linux-info_pkg_setup 823# @FUNCTION: linux-info_pkg_setup
802# @DESCRIPTION: 824# @DESCRIPTION:
803# Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured 825# Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured
804# to support the options specified in CONFIG_CHECK (if not null) 826# to support the options specified in CONFIG_CHECK (if not null)
805linux-info_pkg_setup() { 827linux-info_pkg_setup() {
806 get_version 828 linux-info_get_any_version
807 if [[ $rc -ne 0 ]]; then
808 ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
809 get_running_version
810 fi
811 829
812 if kernel_is 2 4; then 830 if kernel_is 2 4; then
813 if [ "$( gcc-major-version )" -eq "4" ] ; then 831 if [ "$( gcc-major-version )" -eq "4" ] ; then
814 echo 832 echo
815 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with" 833 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with"

Legend:
Removed from v.1.63  
changed lines
  Added in v.1.74

  ViewVC Help
Powered by ViewVC 1.1.20