/[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.89 Revision 1.92
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2012 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.89 2011/08/18 14:58:57 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.92 2012/06/26 00:06:14 robbat2 Exp $
4#
5# Original author: John Mylchreest <johnm@gentoo.org>
6# Maintainer: kernel-misc@gentoo.org
7#
8# Please direct your bugs to the current eclass maintainer :)
9 4
10# @ECLASS: linux-info.eclass 5# @ECLASS: linux-info.eclass
11# @MAINTAINER: 6# @MAINTAINER:
12# kernel-misc@gentoo.org 7# kernel-misc@gentoo.org
8# @AUTHOR:
9# Original author: John Mylchreest <johnm@gentoo.org>
13# @BLURB: eclass used for accessing kernel related information 10# @BLURB: eclass used for accessing kernel related information
14# @DESCRIPTION: 11# @DESCRIPTION:
15# This eclass is used as a central eclass for accessing kernel 12# This eclass is used as a central eclass for accessing kernel
16# related information for source or binary already installed. 13# related information for source or binary already installed.
17# It is vital for linux-mod.eclass to function correctly, and is split 14# It is vital for linux-mod.eclass to function correctly, and is split
19# using additional eclasses. 16# using additional eclasses.
20# 17#
21# "kernel config" in this file means: 18# "kernel config" in this file means:
22# The .config of the currently installed sources is used as the first 19# The .config of the currently installed sources is used as the first
23# preference, with a fall-back to bundled config (/proc/config.gz) if available. 20# preference, with a fall-back to bundled config (/proc/config.gz) if available.
21#
22# Before using any of the config-handling functions in this eclass, you must
23# ensure that one of the following functions has been called (in order of
24# preference), otherwise you will get bugs like #364041):
25# linux-info_pkg_setup
26# linux-info_get_any_version
27# get_version
28# get_running_version
24 29
25# A Couple of env vars are available to effect usage of this eclass 30# A Couple of env vars are available to effect usage of this eclass
26# These are as follows: 31# These are as follows:
27 32
28# @ECLASS-VARIABLE: KERNEL_DIR 33# @ECLASS-VARIABLE: KERNEL_DIR
215 p 220 p
216 }" 221 }"
217 fi 222 fi
218} 223}
219 224
220# @PRIVATE-VARIABLE: _LINUX_CONFIG_EXISTS_DONE 225# @ECLASS-VARIABLE: _LINUX_CONFIG_EXISTS_DONE
226# @INTERNAL
221# @DESCRIPTION: 227# @DESCRIPTION:
222# This is only set if one of the linux_config_*exists functions has been called. 228# This is only set if one of the linux_config_*exists functions has been called.
223# We use it for a QA warning that the check for a config has not been performed, 229# We use it for a QA warning that the check for a config has not been performed,
224# as linux_chkconfig* in non-legacy mode WILL return an undefined value if no 230# as linux_chkconfig* in non-legacy mode WILL return an undefined value if no
225# config is available at all. 231# config is available at all.
359# kernel_is 2 6 returns true 365# kernel_is 2 6 returns true
360# kernel_is 2 6 8 returns false 366# kernel_is 2 6 8 returns false
361# kernel_is 2 6 9 returns true 367# kernel_is 2 6 9 returns true
362# @CODE 368# @CODE
363 369
364# got the jist yet? 370# Note: duplicated in kernel-2.eclass
365
366kernel_is() { 371kernel_is() {
367 # if we haven't determined the version yet, we need to. 372 # if we haven't determined the version yet, we need to.
368 linux-info_get_any_version 373 linux-info_get_any_version
369 374
370 local operator testagainst value x=0 y=0 z=0 375 # Now we can continue
376 local operator test value
371 377
372 case ${1} in 378 case ${1#-} in
373 -lt|lt) operator="-lt"; shift;; 379 lt) operator="-lt"; shift;;
374 -gt|gt) operator="-gt"; shift;; 380 gt) operator="-gt"; shift;;
375 -le|le) operator="-le"; shift;; 381 le) operator="-le"; shift;;
376 -ge|ge) operator="-ge"; shift;; 382 ge) operator="-ge"; shift;;
377 -eq|eq) operator="-eq"; shift;; 383 eq) operator="-eq"; shift;;
378 *) operator="-eq";; 384 *) operator="-eq";;
379 esac 385 esac
380
381 for x in ${@}; do
382 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
383 value="${value}${x}"
384 z=$((${z} + 1))
385
386 case ${z} in
387 1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do testagainst="${testagainst}0"; done;
388 testagainst="${testagainst}${KV_MAJOR}";;
389 2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do testagainst="${testagainst}0"; done;
390 testagainst="${testagainst}${KV_MINOR}";;
391 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do testagainst="${testagainst}0"; done;
392 testagainst="${testagainst}${KV_PATCH}";;
393 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 386 [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
394 esac
395 done
396 387
397 [ "${testagainst}" ${operator} "${value}" ] && return 0 || return 1 388 : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
389 : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
390 [ ${test} ${operator} ${value} ]
398} 391}
399 392
400get_localversion() { 393get_localversion() {
401 local lv_list i x 394 local lv_list i x
402 395

Legend:
Removed from v.1.89  
changed lines
  Added in v.1.92

  ViewVC Help
Powered by ViewVC 1.1.20