sm-discuss AT lists.ibiblio.org
Subject: Public SourceMage Discussion List
List archive
[SM-Discuss] [PATCH 04/16] FUNCTIONS: Improve code reuse for get_*_kernel_config()
- From: Ismael Luceno <ismael.luceno AT gmail.com>
- To: sm-discuss AT lists.ibiblio.org
- Subject: [SM-Discuss] [PATCH 04/16] FUNCTIONS: Improve code reuse for get_*_kernel_config()
- Date: Sun, 11 Apr 2010 20:50:16 -0300
---
ChangeLog | 1 +
FUNCTIONS | 56 +++++++++++++++++++++-----------------------------------
2 files changed, 22 insertions(+), 35 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bd62f01..87ed048 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* FUNCTIONS: Improved get_running_kernel_config() and make it use the
more standard /lib/modules path to get the kernel config.
* FUNCTIONS: Remove duplicated code
+ * FUNCTIONS: Improve code reuse for get_*_kernel_config()
2010-04-10 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libs/libmpc: arithmetic of complex numbers; needed for gcc 4.5
diff --git a/FUNCTIONS b/FUNCTIONS
index e4cb040..9a68945 100755
--- a/FUNCTIONS
+++ b/FUNCTIONS
@@ -367,17 +367,15 @@ function devoke_uname_change()
}
#-----------------------------------------------------------------------
-## Get the running kernel config status of the running kernel option
-## given by $1.
-##
+## Get the kernel config status of the kernel option specified by $2.
+## Kernel version is given by $1.
+##
## If a configure file is found print the requested config status (if
## any) and return 0, otherwise return 1.
-#-----------------------------------------------------------------------
-function get_running_kernel_config()
+##-----------------------------------------------------------------------
+function get_kernel_config_ver()
{
- local KVER=$(get_running_kernel_version)
-
- for i in /proc/config /boot/config-$KVER
/lib/modules/$KVER/build/.config
+ for i in /proc/config /boot/config-"$1"
/lib/modules/"$1"/build/.config
do
if [ -f "$i" ]; then
cat "$i" && break
@@ -390,7 +388,18 @@ function get_running_kernel_config()
elif [ -f "$i.lzma" ]; then
xzcat "$i.lzma" && break
fi
- done | grep "^$1=" | awk -F= '{ if ($2) { print $2 }; exit (!$2) }'
+ done | grep "^$2=" | awk -F= '{ if ($2) { print $2 }; exit (!$2) }'
+}
+
+#-----------------------------------------------------------------------
+## Get the running kernel config status of the running kernel option
+## given by $1.
+##
+## See also: get_specified_kernel_config
+#-----------------------------------------------------------------------
+function get_running_kernel_config()
+{
+ get_kernel_config_ver $(get_running_kernel_version) "$1"
}
#-------------------------------------------------------------------------
@@ -401,14 +410,7 @@ function get_running_kernel_config()
#-------------------------------------------------------------------------
function get_sorcery_kernel_config()
{
- local KVER=$(get_kernel_version)
- if [ -f /boot/config-$KVER ] ; then
- echo $(grep "^$1=" /boot/config-$KVER | awk -F= '{ print $2
}')
- elif [ -f /usr/src/linux-$KVER/.config ] ; then
- echo $(grep "^$1=" /usr/src/linux-$KVER/.config | awk -F= '{
print $2 }')
- else
- echo "-1"
- fi
+ get_kernel_config_ver $(get_kernel_version) || echo "-1"
}
@@ -600,15 +602,7 @@ function get_sorcery_kernel_config()
local KVER="$(installed_version linux)"
if [[ $KVER ]]
then
- if [[ -f "/boot/config-$KVER" ]]
- then
- grep "^$1=" "/boot/config-$KVER" | cut -d= -f2
- elif [[ -f "/usr/src/linux-$KVER/.config" ]]
- then
- grep "^$1=" "/usr/src/linux-$KVER/.config" | cut -d= -f2
- else
- return 1
- fi
+ get_kernel_config_ver "$KVER" "$1"
else
return 1
fi
@@ -625,15 +619,7 @@ function get_kernel_config()
{
if [[ $USE_KERNEL_VERSION ]]
then
- if [[ -f "/boot/config-$USE_KERNEL_VERSION" ]]
- then
- grep "^$1=" "/boot/config-$USE_KERNEL_VERSION" | cut -d= -f2
- elif [[ -f "/usr/src/linux-$USE_KERNEL_VERSION/.config" ]]
- then
- grep "^$1=" "/usr/src/linux-$USE_KERNEL_VERSION/.config" | cut -d= -f2
- else
- return 1
- fi
+ get_kernel_config_ver "$USE_KERNEL_VERSION" "$1"
else
get_sorcery_kernel_config "$1" || get_running_kernel_config "$1"
fi
--
1.7.0.4
-
[SM-Discuss] Kernel build path,
Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 01/16] FUNCTIONS: Improved get_running_kernel_config(), Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 02/16] FUNCTIONS: Remove duplicated code, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 03/16] FUNCTIONS: make get_running_kernel_config() get kernel version from get_running_kernel_version(), Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 04/16] FUNCTIONS: Improve code reuse for get_*_kernel_config(), Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 05/16] bridge-utils: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 06/16] klibc: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 07/16] virtualbox-module: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 08/16] splashutils: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 09/16] ndiswrapper: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 10/16] madwifi: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 11/16] cloop: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 12/16] dazuko: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 13/16] bluez-kernel: Fix kernel headers path, Ismael Luceno, 04/11/2010
- [SM-Discuss] [PATCH 14/16] ath5k: Fix kernel headers path, Ismael Luceno, 04/11/2010
Archive powered by MHonArc 2.6.24.