linux-info.eclass: sync with upstream Gentoo

Mostly cosmetic changes here, but kernel_is gets optimized a bit.
Very few packages actually use this eclass.  Mostly updating this
so we can pull in a newer kernel-2.eclass.

BUG=chromium-os:14334
TEST=`emerge fuse udev qemu-kvm` still works
TEST=`cbuildbot chromiumos-sdk` worked
TEST=`cbuildbot amd64-generic-full` passes
TEST=`cbuildbot arm-generic-full` passes
TEST=`cbuildbot x86-generic-full` passes
TEST=build_packages+build_image for x86-alex boots

Change-Id: I9e3a1c901f2efaf32caadfd7ed909a339bb8342d
Reviewed-on: https://gerrit.chromium.org/gerrit/13080
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2011-12-15 16:41:58 -05:00 committed by Gerrit
parent 5db6f272fd
commit 6a26cd8c0a

View File

@ -1,15 +1,12 @@
# Copyright 1999-2006 Gentoo Foundation # Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.88 2011/03/29 19:57:51 flameeyes Exp $ # $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.91 2011/12/12 22:01:37 vapier Exp $
#
# Original author: John Mylchreest <johnm@gentoo.org>
# Maintainer: kernel-misc@gentoo.org
#
# Please direct your bugs to the current eclass maintainer :)
# @ECLASS: linux-info.eclass # @ECLASS: linux-info.eclass
# @MAINTAINER: # @MAINTAINER:
# kernel-misc@gentoo.org # kernel-misc@gentoo.org
# @AUTHOR:
# Original author: John Mylchreest <johnm@gentoo.org>
# @BLURB: eclass used for accessing kernel related information # @BLURB: eclass used for accessing kernel related information
# @DESCRIPTION: # @DESCRIPTION:
# This eclass is used as a central eclass for accessing kernel # This eclass is used as a central eclass for accessing kernel
@ -217,7 +214,8 @@ getfilevar_noexec() {
fi fi
} }
# @PRIVATE-VARIABLE: _LINUX_CONFIG_EXISTS_DONE # @ECLASS-VARIABLE: _LINUX_CONFIG_EXISTS_DONE
# @INTERNAL
# @DESCRIPTION: # @DESCRIPTION:
# This is only set if one of the linux_config_*exists functions has been called. # This is only set if one of the linux_config_*exists functions has been called.
# We use it for a QA warning that the check for a config has not been performed, # We use it for a QA warning that the check for a config has not been performed,
@ -361,40 +359,27 @@ linux_chkconfig_string() {
# kernel_is 2 6 9 returns true # kernel_is 2 6 9 returns true
# @CODE # @CODE
# got the jist yet? # Note: duplicated in kernel-2.eclass
kernel_is() { kernel_is() {
# if we haven't determined the version yet, we need to. # if we haven't determined the version yet, we need to.
linux-info_get_any_version linux-info_get_any_version
local operator testagainst value x=0 y=0 z=0 # Now we can continue
local operator test value
case ${1} in case ${1#-} in
-lt|lt) operator="-lt"; shift;; lt) operator="-lt"; shift;;
-gt|gt) operator="-gt"; shift;; gt) operator="-gt"; shift;;
-le|le) operator="-le"; shift;; le) operator="-le"; shift;;
-ge|ge) operator="-ge"; shift;; ge) operator="-ge"; shift;;
-eq|eq) operator="-eq"; shift;; eq) operator="-eq"; shift;;
*) operator="-eq";; *) operator="-eq";;
esac esac
[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
for x in ${@}; do : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
value="${value}${x}" [ ${test} ${operator} ${value} ]
z=$((${z} + 1))
case ${z} in
1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do testagainst="${testagainst}0"; done;
testagainst="${testagainst}${KV_MAJOR}";;
2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do testagainst="${testagainst}0"; done;
testagainst="${testagainst}${KV_MINOR}";;
3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do testagainst="${testagainst}0"; done;
testagainst="${testagainst}${KV_PATCH}";;
*) die "Error in kernel-2_kernel_is(): Too many parameters.";;
esac
done
[ "${testagainst}" ${operator} "${value}" ] && return 0 || return 1
} }
get_localversion() { get_localversion() {