1  # Copyright 19992011 Gentoo Foundation 
1  # Copyright 19992011 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/gentoox86/eclass/linuxinfo.eclass,v 1.90 2011/08/22 04:46:32 vapier Exp $ 
3  # $Header: /var/cvsroot/gentoox86/eclass/linuxinfo.eclass,v 1.91 2011/12/12 22:01:37 vapier Exp $ 
4  
4  
5  # @ECLASS: linuxinfo.eclass 
5  # @ECLASS: linuxinfo.eclass 
6  # @MAINTAINER: 
6  # @MAINTAINER: 
7  # kernelmisc@gentoo.org 
7  # kernelmisc@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 kernel2.eclass 
363  


364  kernel_is() { 
363  kernel_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  linuxinfo_get_any_version 
365  linuxinfo_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  ltlt) operator="lt"; shift;; 
371  lt) operator="lt"; shift;; 
372  gtgt) operator="gt"; shift;; 
372  gt) operator="gt"; shift;; 
373  lele) operator="le"; shift;; 
373  le) operator="le"; shift;; 
374  gege) operator="ge"; shift;; 
374  ge) operator="ge"; shift;; 
375  eqeq) 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 kernel2_kernel_is(): Too many parameters.";; 
378  [[ $# gt 3 ]] && die "Error in kernel2_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  
398  get_localversion() { 
385  get_localversion() { 
399  local lv_list i x 
386  local lv_list i x 
400  
387  