/[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.96 Revision 1.97
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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.96 2013/01/24 20:47:23 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.97 2013/02/10 02:21:55 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:
243# @RETURN: true or false 243# @RETURN: true or false
244# @DESCRIPTION: 244# @DESCRIPTION:
245# It returns true if .config exists in a build directory otherwise false 245# It returns true if .config exists in a build directory otherwise false
246linux_config_src_exists() { 246linux_config_src_exists() {
247 export _LINUX_CONFIG_EXISTS_DONE=1 247 export _LINUX_CONFIG_EXISTS_DONE=1
248 [ -s "${KV_OUT_DIR}/.config" ] 248 [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
249} 249}
250 250
251# @FUNCTION: linux_config_bin_exists 251# @FUNCTION: linux_config_bin_exists
252# @RETURN: true or false 252# @RETURN: true or false
253# @DESCRIPTION: 253# @DESCRIPTION:
254# It returns true if .config exists in /proc, otherwise false 254# It returns true if .config exists in /proc, otherwise false
255linux_config_bin_exists() { 255linux_config_bin_exists() {
256 export _LINUX_CONFIG_EXISTS_DONE=1 256 export _LINUX_CONFIG_EXISTS_DONE=1
257 [ -s "/proc/config.gz" ] 257 [[ -s /proc/config.gz ]]
258} 258}
259 259
260# @FUNCTION: linux_config_exists 260# @FUNCTION: linux_config_exists
261# @RETURN: true or false 261# @RETURN: true or false
262# @DESCRIPTION: 262# @DESCRIPTION:
264# 264#
265# This function MUST be checked before using any of the linux_chkconfig_* 265# This function MUST be checked before using any of the linux_chkconfig_*
266# functions. 266# functions.
267linux_config_exists() { 267linux_config_exists() {
268 linux_config_src_exists || linux_config_bin_exists 268 linux_config_src_exists || linux_config_bin_exists
269}
270
271# @FUNCTION: linux_config_path
272# @DESCRIPTION:
273# Echo the name of the config file to use. If none are found,
274# then return false.
275linux_config_path() {
276 if linux_config_src_exists; then
277 echo "${KV_OUT_DIR}/.config"
278 elif linux_config_bin_exists; then
279 echo "/proc/config.gz"
280 else
281 return 1
282 fi
269} 283}
270 284
271# @FUNCTION: require_configured_kernel 285# @FUNCTION: require_configured_kernel
272# @DESCRIPTION: 286# @DESCRIPTION:
273# This function verifies that the current kernel is configured (it checks against the existence of .config) 287# This function verifies that the current kernel is configured (it checks against the existence of .config)
289# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config 303# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
290# If linux_config_exists returns false, the results of this are UNDEFINED. You 304# If linux_config_exists returns false, the results of this are UNDEFINED. You
291# MUST call linux_config_exists first. 305# MUST call linux_config_exists first.
292linux_chkconfig_present() { 306linux_chkconfig_present() {
293 linux_config_qa_check linux_chkconfig_present 307 linux_config_qa_check linux_chkconfig_present
294 local RESULT config 308 [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == [my] ]]
295 config="${KV_OUT_DIR}/.config"
296 [ ! -f "${config}" ] && config="/proc/config.gz"
297 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
298 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
299} 309}
300 310
301# @FUNCTION: linux_chkconfig_module 311# @FUNCTION: linux_chkconfig_module
302# @USAGE: option 312# @USAGE: option
303# @RETURN: true or false 313# @RETURN: true or false
305# It checks that CONFIG_<option>=m is present in the current kernel .config 315# It checks that CONFIG_<option>=m is present in the current kernel .config
306# If linux_config_exists returns false, the results of this are UNDEFINED. You 316# If linux_config_exists returns false, the results of this are UNDEFINED. You
307# MUST call linux_config_exists first. 317# MUST call linux_config_exists first.
308linux_chkconfig_module() { 318linux_chkconfig_module() {
309 linux_config_qa_check linux_chkconfig_module 319 linux_config_qa_check linux_chkconfig_module
310 local RESULT config 320 [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == m ]]
311 config="${KV_OUT_DIR}/.config"
312 [ ! -f "${config}" ] && config="/proc/config.gz"
313 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
314 [ "${RESULT}" = "m" ] && return 0 || return 1
315} 321}
316 322
317# @FUNCTION: linux_chkconfig_builtin 323# @FUNCTION: linux_chkconfig_builtin
318# @USAGE: option 324# @USAGE: option
319# @RETURN: true or false 325# @RETURN: true or false
321# It checks that CONFIG_<option>=y is present in the current kernel .config 327# It checks that CONFIG_<option>=y is present in the current kernel .config
322# If linux_config_exists returns false, the results of this are UNDEFINED. You 328# If linux_config_exists returns false, the results of this are UNDEFINED. You
323# MUST call linux_config_exists first. 329# MUST call linux_config_exists first.
324linux_chkconfig_builtin() { 330linux_chkconfig_builtin() {
325 linux_config_qa_check linux_chkconfig_builtin 331 linux_config_qa_check linux_chkconfig_builtin
326 local RESULT config 332 [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == y ]]
327 config="${KV_OUT_DIR}/.config"
328 [ ! -f "${config}" ] && config="/proc/config.gz"
329 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
330 [ "${RESULT}" = "y" ] && return 0 || return 1
331} 333}
332 334
333# @FUNCTION: linux_chkconfig_string 335# @FUNCTION: linux_chkconfig_string
334# @USAGE: option 336# @USAGE: option
335# @RETURN: CONFIG_<option> 337# @RETURN: CONFIG_<option>
337# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel). 339# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
338# If linux_config_exists returns false, the results of this are UNDEFINED. You 340# If linux_config_exists returns false, the results of this are UNDEFINED. You
339# MUST call linux_config_exists first. 341# MUST call linux_config_exists first.
340linux_chkconfig_string() { 342linux_chkconfig_string() {
341 linux_config_qa_check linux_chkconfig_string 343 linux_config_qa_check linux_chkconfig_string
342 local config
343 config="${KV_OUT_DIR}/.config"
344 [ ! -f "${config}" ] && config="/proc/config.gz"
345 getfilevar_noexec "CONFIG_${1}" "${config}" 344 getfilevar_noexec "CONFIG_$1" "$(linux_config_path)"
346} 345}
347 346
348# Versioning Functions 347# Versioning Functions
349# --------------------------------------- 348# ---------------------------------------
350 349

Legend:
Removed from v.1.96  
changed lines
  Added in v.1.97

  ViewVC Help
Powered by ViewVC 1.1.20