[Lunar-commits] <lunar> Extend kernel_option_present() to allow checking if a kernel option have a certain value

Stefan Wold ratler at lunar-linux.org
Sat Mar 19 12:02:50 CET 2011


commit ee2968fb024878a8c03d415c4a81a5e43e006e72
Author: Stefan Wold <ratler at lunar-linux.org>
Date:   Sat Mar 19 12:02:50 2011 +0100

    Extend kernel_option_present() to allow checking if a kernel option have a certain value
---
 var/lib/lunar/functions/kernel.lunar |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/var/lib/lunar/functions/kernel.lunar b/var/lib/lunar/functions/kernel.lunar
index 9cc2a17..8c9251d 100644
--- a/var/lib/lunar/functions/kernel.lunar
+++ b/var/lib/lunar/functions/kernel.lunar
@@ -67,9 +67,10 @@ kernel_config_exists() {
 # 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
+    local KERNEL_CONFIG KERNEL_OPTION KERNEL_VALUE CAT
     KERNEL_CONFIG=$(kernel_config_exists) || return 255
     KERNEL_OPTION=$1
+    KERNEL_VALUE=$2
 
     case $KERNEL_CONFIG in
         *.gz)
@@ -79,9 +80,16 @@ kernel_option_present() {
             CAT=cat
             ;;
     esac
-
-    if $CAT $KERNEL_CONFIG | grep -Eq "^$KERNEL_OPTION=(y|m)$"; then
+    
+    if [ -n "$KERNEL_VALUE" ]; then
+      if $CAT $KERNEL_CONFIG | grep -Eq "^$KERNEL_OPTION=\"$KERNEL_VALUE\""; then
+        return 0
+      fi
+    else
+      if $CAT $KERNEL_CONFIG | grep -Eq "^$KERNEL_OPTION=(y|m)$"; then
         return 0
+      fi
     fi
+    
     return 1
 }


More information about the Lunar-commits mailing list