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
# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.88 2011/03/29 19:57:51 flameeyes Exp $
#
# Original author: John Mylchreest <johnm@gentoo.org>
# Maintainer: kernel-misc@gentoo.org
#
# Please direct your bugs to the current eclass maintainer :)
# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.91 2011/12/12 22:01:37 vapier Exp $
# @ECLASS: linux-info.eclass
# @MAINTAINER:
# kernel-misc@gentoo.org
# @AUTHOR:
# Original author: John Mylchreest <johnm@gentoo.org>
# @BLURB: eclass used for accessing kernel related information
# @DESCRIPTION:
# This eclass is used as a central eclass for accessing kernel
@ -217,7 +214,8 @@ getfilevar_noexec() {
fi
}
# @PRIVATE-VARIABLE: _LINUX_CONFIG_EXISTS_DONE
# @ECLASS-VARIABLE: _LINUX_CONFIG_EXISTS_DONE
# @INTERNAL
# @DESCRIPTION:
# 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,
@ -361,40 +359,27 @@ linux_chkconfig_string() {
# kernel_is 2 6 9 returns true
# @CODE
# got the jist yet?
# Note: duplicated in kernel-2.eclass
kernel_is() {
# if we haven't determined the version yet, we need to.
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
-lt|lt) operator="-lt"; shift;;
-gt|gt) operator="-gt"; shift;;
-le|le) operator="-le"; shift;;
-ge|ge) operator="-ge"; shift;;
-eq|eq) operator="-eq"; shift;;
*) operator="-eq";;
case ${1#-} in
lt) operator="-lt"; shift;;
gt) operator="-gt"; shift;;
le) operator="-le"; shift;;
ge) operator="-ge"; shift;;
eq) operator="-eq"; shift;;
*) operator="-eq";;
esac
[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
for x in ${@}; do
for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
value="${value}${x}"
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
: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
[ ${test} ${operator} ${value} ]
}
get_localversion() {