aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDick Streefland <dick@streefland.net>2010-10-22 18:02:44 -0400
committerMichal Marek <mmarek@suse.cz>2010-10-27 18:22:17 -0400
commit532cf2907ac3b9c2345d76251764f4f4e602c921 (patch)
tree1493be6fe2749d6c1cc785dd5655243048952c82 /scripts
parentd0f95c782686dbfbb415d533881a06c2bde17ee0 (diff)
scripts/extract-ikconfig: add support for bzip2, lzma and lzo
Add support for kernels compressed with bzip2, lzma or lzo to the extract-ikconfig script. Fixes kernel bugzilla #19852: https://bugzilla.kernel.org/show_bug.cgi?id=19852 Signed-off-by: Dick Streefland <dick@streefland.net> Tested-by: Justin <jlec@gentoo.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/extract-ikconfig41
1 files changed, 27 insertions, 14 deletions
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index 37f30d36c944..1512c0a755ac 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -7,12 +7,10 @@
7# The obscure use of the "tr" filter is to work around older versions of 7# The obscure use of the "tr" filter is to work around older versions of
8# "grep" that report the byte offset of the line instead of the pattern. 8# "grep" that report the byte offset of the line instead of the pattern.
9# 9#
10# (c) 2009, Dick Streefland <dick@streefland.net> 10# (c) 2009,2010 Dick Streefland <dick@streefland.net>
11# Licensed under the terms of the GNU General Public License. 11# Licensed under the terms of the GNU General Public License.
12# ---------------------------------------------------------------------- 12# ----------------------------------------------------------------------
13 13
14gz1='\037\213\010'
15gz2='01'
16cf1='IKCFG_ST\037\213\010' 14cf1='IKCFG_ST\037\213\010'
17cf2='0123456789' 15cf2='0123456789'
18 16
@@ -21,11 +19,25 @@ dump_config()
21 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"` 19 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
22 then 20 then
23 pos=${pos%%:*} 21 pos=${pos%%:*}
24 tail -c+$(($pos+8)) "$1" | zcat -q 22 tail -c+$(($pos+8)) "$1" | zcat > $tmp1 2> /dev/null
25 exit 0 23 if [ $? != 1 ]
24 then # exit status must be 0 or 2 (trailing garbage warning)
25 cat $tmp1
26 exit 0
27 fi
26 fi 28 fi
27} 29}
28 30
31try_decompress()
32{
33 for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
34 do
35 pos=${pos%%:*}
36 tail -c+$pos "$img" | $3 > $tmp2 2> /dev/null
37 dump_config $tmp2
38 done
39}
40
29# Check invocation: 41# Check invocation:
30me=${0##*/} 42me=${0##*/}
31img=$1 43img=$1
@@ -35,18 +47,19 @@ then
35 exit 2 47 exit 2
36fi 48fi
37 49
50# Prepare temp files:
51tmp1=/tmp/ikconfig$$.1
52tmp2=/tmp/ikconfig$$.2
53trap "rm -f $tmp1 $tmp2" 0
54
38# Initial attempt for uncompressed images or objects: 55# Initial attempt for uncompressed images or objects:
39dump_config "$img" 56dump_config "$img"
40 57
41# That didn't work, so decompress and try again: 58# That didn't work, so retry after decompression.
42tmp=/tmp/ikconfig$$ 59try_decompress '\037\213\010' xy gunzip
43trap "rm -f $tmp" 0 60try_decompress 'BZh' xy bunzip2
44for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"` 61try_decompress '\135\0\0\0' xxx unlzma
45do 62try_decompress '\211\114\132' xy 'lzop -d'
46 pos=${pos%%:*}
47 tail -c+$pos "$img" | zcat 2> /dev/null > $tmp
48 dump_config $tmp
49done
50 63
51# Bail out: 64# Bail out:
52echo "$me: Cannot find kernel config." >&2 65echo "$me: Cannot find kernel config." >&2