[PATCH] Fix bug in saa7146 analog tv i2c-handling
[linux-2.6/history.git] / scripts / extract-ikconfig
blob8e526d3709660c3db53e30dbae881321374872d4
1 #! /bin/bash
2 # extracts .config info from a [b]zImage file
3 # uses: binoffset (new), dd, zcat, strings, grep
4 # $arg1 is [b]zImage filename
6 TMPFILE=""
8 usage()
10 echo " usage: extract-ikconfig [b]zImage_filename"
13 clean_up()
15 if [ -z $ISCOMP ]
16 then
17 rm -f $TMPFILE
21 if [ $# -lt 1 ]
22 then
23 usage
24 exit
27 image=$1
29 # There are two gzip headers, as well as arches which don't compress their
30 # kernel.
31 GZHDR="0x1f 0x8b 0x08 0x00"
32 if [ `binoffset $image $GZHDR >/dev/null 2>&1 ; echo $?` -ne 0 ]
33 then
34 GZHDR="0x1f 0x8b 0x08 0x08"
35 if [ `binoffset $image $GZHDR >/dev/null 2>&1 ; echo $?` -ne 0 ]
36 then
37 ISCOMP=0
41 PID=$$
43 # Extract and uncompress the kernel image if necessary
44 if [ -z $ISCOMP ]
45 then
46 TMPFILE="/tmp/`basename $image`.vmlin.$PID"
47 dd if=$image bs=1 skip=`binoffset $image $GZHDR` 2> /dev/null | zcat > $TMPFILE
48 else
49 TMPFILE=$image
52 # Look for strings.
53 strings $TMPFILE | grep "CONFIG_BEGIN=n" > /dev/null
54 if [ $? -eq 0 ]
55 then
56 strings $TMPFILE | awk "/CONFIG_BEGIN=n/,/CONFIG_END=n/" > $image.oldconfig.$PID
57 else
58 echo "ERROR: Unable to extract kernel configuration information."
59 echo " This kernel image may not have the config info."
60 clean_up
61 exit 1
64 echo "Kernel configuration written to $image.oldconfig.$PID"
65 clean_up
66 exit 0