SVN: geninitrd/trunk/geninitrd

glen glen at pld-linux.org
Sun Jan 23 20:47:17 CET 2011


Author: glen
Date: Sun Jan 23 20:47:17 2011
New Revision: 12078

Modified:
   geninitrd/trunk/geninitrd
Log:
use copy of extract-ikconfig from kernel sources what can process any file
containing it (vmlinux or kernel mod with or without compressions)



Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd	(original)
+++ geninitrd/trunk/geninitrd	Sun Jan 23 20:47:17 2011
@@ -275,39 +275,16 @@
 	fi
 }
 
-# extract-ikconfig - Extract the .config file from a kernel image
-#
-# The obscure use of the "tr" filter is to work around older versions of
-# "grep" that report the byte offset of the line instead of the pattern.
-#
-# (c) 2009, Dick Streefland <dick at streefland.net>
-# Licensed under the terms of the GNU General Public License.
-#
-# Ripped and adjusted for geninitrd from linux-2.6.34/scripts/extract-ikconfig
-extract-ikconfig() {
+# Extract the .config file from a kernel image
+# uses extract-ikconfig from kernel sources (scripts/extract-ikconfig)
+ikconfig() {
 	local kofile=$(modinfo -k $kernel -n configs 2> /dev/null)
-	if [ -z "$kofile" ]; then
-		return
-	fi
-	local img=$(mktemp)
-	case "$kofile" in
-	*.gz)
-		gzip -dc "$kofile" > $img
-		;;
-	*)
-		cat "$kofile" > $img
-		;;
-	esac
-
-	local cf1='IKCFG_ST\037\213\010'
-	local cf2='0123456789'
-	local pos
-
-	if pos=$(tr "$cf1\n$cf2" "\n$cf2=" < "$img" | grep -abo "^$cf2"); then
-		pos=${pos%%:*}
-		tail -c+$(($pos+8)) "$img" | gzip -dcq
+	if [ -n "$kofile" ]; then
+		/lib/geninitrd/extract-ikconfig $kofile
+	else
+		# try vmlinuz itself
+		/lib/geninitrd/extract-ikconfig /boot/vmlinuz-$kernel
 	fi
-	rm -f $img
 }
 
 # Finds module dependencies
@@ -1395,7 +1372,7 @@
 	die "Filesystem $INITRDFS not supported by $PROGRAM"
 esac
 
-CONFIG_BLK_DEV_RAM_SIZE=$(extract-ikconfig | awk -F= '/^CONFIG_BLK_DEV_RAM_SIZE/{print $2}')
+CONFIG_BLK_DEV_RAM_SIZE=$(ikconfig | awk -F= '/^CONFIG_BLK_DEV_RAM_SIZE/{print $2}')
 if [ -z "$CONFIG_BLK_DEV_RAM_SIZE" ]; then
 	CONFIG_BLK_DEV_RAM_SIZE=4096
 fi


More information about the pld-cvs-commit mailing list