[Lunar-commits] <lunar> Functions to detect kernel config and if kernel options
Stefan Wold
ratler at lunar-linux.org
Sun Mar 21 15:36:37 CET 2010
commit 9c52576de90d2b05db4b6575a3cf875b332e3c56
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Sun Mar 21 15:36:37 2010 +0100
Functions to detect kernel config and if kernel options
kernel_config_exists(): Return path to kernel config and status 0 or 1
kernel_option_present(): Return 0 if kernel option is enabled, 1 if kernel option is disabled
---
var/lib/lunar/functions/kernel.lunar | 41 ++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/var/lib/lunar/functions/kernel.lunar b/var/lib/lunar/functions/kernel.lunar
index f91acee..9cc2a17 100644
--- a/var/lib/lunar/functions/kernel.lunar
+++ b/var/lib/lunar/functions/kernel.lunar
@@ -10,6 +10,7 @@
# Parts Copyright Niki Guldbrand 2003 GPLv2 #
# Parts Copyright FW Systems llc 2003 GPLv2 #
# Parts Copyright Auke Kok 2005 GPLv2 #
+# Parts Copyright Stefan Wold 2010 GPLv2 #
# #
############################################################
@@ -44,3 +45,43 @@ update_bootloader() {
}
+# function: kernel_config_exists
+# usage: kernel_config_exists
+# purpose: Verify that a readable kernel config is available
+# returns: Config file path, (0) if successful, (1) if config not found
+kernel_config_exists() {
+ if [ -e /proc/config.gz ]; then
+ echo "/proc/config.gz"
+ elif [ -e /usr/src/linux/.config ]; then
+ echo "/usr/src/linux/.config"
+ elif [ -e $CONFIG_CACHE/.config.2.6.stable ]; then
+ echo "$CONFIG_CACHE/.config.2.6.stable"
+ else
+ return 1
+ fi
+ return 0
+}
+
+# function: kernel_option_present
+# usage: kernel_option_present config_option
+# purpose: Check if a kernel option is configured
+# returns: (0) if option is found and enabled, (1) if option is not found or disabled, (255) if kernel config not found
+kernel_option_present() {
+ local KERNEL_CONFIG KERNEL_OPTION CAT
+ KERNEL_CONFIG=$(kernel_config_exists) || return 255
+ KERNEL_OPTION=$1
+
+ case $KERNEL_CONFIG in
+ *.gz)
+ CAT=zcat
+ ;;
+ *)
+ CAT=cat
+ ;;
+ esac
+
+ if $CAT $KERNEL_CONFIG | grep -Eq "^$KERNEL_OPTION=(y|m)$"; then
+ return 0
+ fi
+ return 1
+}
More information about the Lunar-commits
mailing list