/[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.90 Revision 1.91
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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.90 2011/08/22 04:46:32 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.91 2011/12/12 22:01:37 vapier Exp $
4 4
5# @ECLASS: linux-info.eclass 5# @ECLASS: linux-info.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kernel-misc@gentoo.org 7# kernel-misc@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
357# kernel_is 2 6 returns true 357# kernel_is 2 6 returns true
358# kernel_is 2 6 8 returns false 358# kernel_is 2 6 8 returns false
359# kernel_is 2 6 9 returns true 359# kernel_is 2 6 9 returns true
360# @CODE 360# @CODE
361 361
362# got the jist yet? 362# Note: duplicated in kernel-2.eclass
363
364kernel_is() { 363kernel_is() {
365 # if we haven't determined the version yet, we need to. 364 # if we haven't determined the version yet, we need to.
366 linux-info_get_any_version 365 linux-info_get_any_version
367 366
368 local operator testagainst value x=0 y=0 z=0 367 # Now we can continue
368 local operator test value
369 369
370 case ${1} in 370 case ${1#-} in
371 -lt|lt) operator="-lt"; shift;; 371 lt) operator="-lt"; shift;;
372 -gt|gt) operator="-gt"; shift;; 372 gt) operator="-gt"; shift;;
373 -le|le) operator="-le"; shift;; 373 le) operator="-le"; shift;;
374 -ge|ge) operator="-ge"; shift;; 374 ge) operator="-ge"; shift;;
375 -eq|eq) operator="-eq"; shift;; 375 eq) operator="-eq"; shift;;
376 *) operator="-eq";; 376 *) operator="-eq";;
377 esac 377 esac
378
379 for x in ${@}; do
380 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
381 value="${value}${x}"
382 z=$((${z} + 1))
383
384 case ${z} in
385 1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do testagainst="${testagainst}0"; done;
386 testagainst="${testagainst}${KV_MAJOR}";;
387 2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do testagainst="${testagainst}0"; done;
388 testagainst="${testagainst}${KV_MINOR}";;
389 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do testagainst="${testagainst}0"; done;
390 testagainst="${testagainst}${KV_PATCH}";;
391 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 378 [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
392 esac
393 done
394 379
395 [ "${testagainst}" ${operator} "${value}" ] && return 0 || return 1 380 : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
381 : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
382 [ ${test} ${operator} ${value} ]
396} 383}
397 384
398get_localversion() { 385get_localversion() {
399 local lv_list i x 386 local lv_list i x
400 387

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91

  ViewVC Help
Powered by ViewVC 1.1.20