/[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.22 Revision 1.23
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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.22 2005/02/01 09:13:47 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.23 2005/04/08 18:42:23 johnm Exp $
4# 4#
5# Description: This eclass is used as a central eclass for accessing kernel 5# Description: This eclass is used as a central eclass for accessing kernel
6# related information for sources already installed. 6# related information for sources already installed.
7# It is vital for linux-mod to function correctly, and is split 7# It is vital for linux-mod to function correctly, and is split
8# out so that any ebuild behaviour "templates" are abstracted out 8# out so that any ebuild behaviour "templates" are abstracted out
47# KV_OUT_DIR <string> The kernel object directory. will be KV_DIR unless 47# KV_OUT_DIR <string> The kernel object directory. will be KV_DIR unless
48# koutput is used. This should be used for referencing 48# koutput is used. This should be used for referencing
49# .config. 49# .config.
50 50
51# And to ensure all the weirdness with crosscompile 51# And to ensure all the weirdness with crosscompile
52inherit toolchain-funcs 52inherit toolchain-funcs versionator
53 53
54ECLASS=linux-info 54ECLASS=linux-info
55INHERITED="$INHERITED $ECLASS" 55INHERITED="$INHERITED $ECLASS"
56EXPORT_FUNCTIONS pkg_setup 56EXPORT_FUNCTIONS pkg_setup
57 57
105 [ -z "${1}" ] && ERROR=1 105 [ -z "${1}" ] && ERROR=1
106 [ ! -f "${2}" ] && ERROR=1 106 [ ! -f "${2}" ] && ERROR=1
107 107
108 if [ "${ERROR}" = 1 ] 108 if [ "${ERROR}" = 1 ]
109 then 109 then
110 ebeep
111 echo -e "\n" 110 echo -e "\n"
112 eerror "getfilevar requires 2 variables, with the second a valid file." 111 eerror "getfilevar requires 2 variables, with the second a valid file."
113 eerror " getfilevar <VARIABLE> <CONFIGFILE>" 112 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
114 else 113 else
115 workingdir=${PWD} 114 workingdir=${PWD}
163# got the jist yet? 162# got the jist yet?
164 163
165kernel_is() { 164kernel_is() {
166 # if we haven't determined the version yet, we need too. 165 # if we haven't determined the version yet, we need too.
167 get_version; 166 get_version;
168 167 local operator test value x=0 y=0 z=0
169 local RESULT operator test value i len
170 RESULT=0
171
172 operator="="
173 if [ "${1}" == "lt" ]
174 then
175 operator="-lt"
176 shift
177 elif [ "${1}" == "gt" ]
178 then
179 operator="-gt"
180 shift
181 elif [ "${1}" == "le" ]
182 then
183 operator="-le"
184 shift
185 elif [ "${1}" == "ge" ]
186 then
187 operator="-ge"
188 shift
189 fi
190 168
191 if [ -n "${1}" ] 169 case ${1} in
192 then 170 lt) operator="-lt"; shift;;
171 gt) operator="-gt"; shift;;
172 le) operator="-le"; shift;;
173 ge) operator="-ge"; shift;;
174 eq) operator="-eq"; shift;;
175 *) operator="-eq";;
176 esac
177
178 for x in ${@}; do
179 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
193 value="${value}${1}" 180 value="${value}${x}"
181 z=$((${z} + 1))
182
183 case ${z} in
184 1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do test="${test}0"; done;
194 test="${test}${KV_MAJOR}" 185 test="${test}${KV_MAJOR}";;
195 fi 186 2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do test="${test}0"; done;
196 if [ -n "${2}" ] 187 test="${test}${KV_MINOR}";;
197 then 188 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
198 len=$[ 3 - ${#2} ] 189 test="${test}${KV_PATCH}";;
199 for((i=0; i<$len; i++)); do 190 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
200 value="${value}0" 191 esac
201 done 192 done
202 value="${value}${2}"
203 193
204 len=$[ 3 - ${#KV_MINOR} ]
205 for((i=0; i<$len; i++)); do
206 test="${test}0"
207 done
208 test="${test}${KV_MINOR}"
209 fi
210 if [ -n "${3}" ]
211 then
212 len=$[ 3 - ${#3} ]
213 for((i=0; i<$len; i++)); do
214 value="${value}0"
215 done
216 value="${value}${3}"
217
218 len=$[ 3 - ${#KV_PATCH} ]
219 for((i=0; i<$len; i++)); do
220 test="${test}0"
221 done
222 test="${test}${KV_PATCH}"
223 fi
224
225 [ ${test} ${operator} ${value} ] && return 0 || return 1 194 [ ${test} ${operator} ${value} ] && return 0 || return 1
226} 195}
227 196
228get_version() { 197get_version() {
229 local kbuild_output 198 local kbuild_output
230 199
329 fi 298 fi
330 299
331 return 0 300 return 0
332} 301}
333 302
303get_running_version() {
304 KV_FULL=$(uname -r)
334 305
306 if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
307 KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
308 unset KV_FULL
309 get_version
310 return $?
311 elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
312 KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
313 unset KV_FULL
314 get_version
315 return $?
316 else
317 KV_MAJOR=$(get_version_component_range 1 ${KV_FULL})
318 KV_MINOR=$(get_version_component_range 2 ${KV_FULL})
319 KV_PATCH=$(get_version_component_range 3- ${KV_FULL})
320 KV_PATCH=${KV_PATCH//-*}
321 [[ -n ${KV_FULL#*-} ]] && [[ -n ${KV_FULL//${KV_FULL#*-}} ]] \
322 && KV_EXTRA="-${KV_FULL#*-}"
323 fi
324 return 0
325}
335 326
336 327
337# ebuild check functions 328# ebuild check functions
338# --------------------------------------- 329# ---------------------------------------
339 330

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.20