Commit 532cf2907ac3b9c2345d76251764f4f4e602c921

Authored by Dick Streefland
Committed by Michal Marek
1 parent d0f95c7826

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>

Showing 1 changed file with 27 additions and 14 deletions Side-by-side Diff

scripts/extract-ikconfig
... ... @@ -7,12 +7,10 @@
7 7 # The obscure use of the "tr" filter is to work around older versions of
8 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 11 # Licensed under the terms of the GNU General Public License.
12 12 # ----------------------------------------------------------------------
13 13  
14   -gz1='\037\213\010'
15   -gz2='01'
16 14 cf1='IKCFG_ST\037\213\010'
17 15 cf2='0123456789'
18 16  
19 17  
... ... @@ -21,11 +19,25 @@
21 19 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
22 20 then
23 21 pos=${pos%%:*}
24   - tail -c+$(($pos+8)) "$1" | zcat -q
25   - exit 0
  22 + tail -c+$(($pos+8)) "$1" | zcat > $tmp1 2> /dev/null
  23 + if [ $? != 1 ]
  24 + then # exit status must be 0 or 2 (trailing garbage warning)
  25 + cat $tmp1
  26 + exit 0
  27 + fi
26 28 fi
27 29 }
28 30  
  31 +try_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 41 # Check invocation:
30 42 me=${0##*/}
31 43 img=$1
32 44  
... ... @@ -35,18 +47,19 @@
35 47 exit 2
36 48 fi
37 49  
  50 +# Prepare temp files:
  51 +tmp1=/tmp/ikconfig$$.1
  52 +tmp2=/tmp/ikconfig$$.2
  53 +trap "rm -f $tmp1 $tmp2" 0
  54 +
38 55 # Initial attempt for uncompressed images or objects:
39 56 dump_config "$img"
40 57  
41   -# That didn't work, so decompress and try again:
42   -tmp=/tmp/ikconfig$$
43   -trap "rm -f $tmp" 0
44   -for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"`
45   -do
46   - pos=${pos%%:*}
47   - tail -c+$pos "$img" | zcat 2> /dev/null > $tmp
48   - dump_config $tmp
49   -done
  58 +# That didn't work, so retry after decompression.
  59 +try_decompress '\037\213\010' xy gunzip
  60 +try_decompress 'BZh' xy bunzip2
  61 +try_decompress '\135\0\0\0' xxx unlzma
  62 +try_decompress '\211\114\132' xy 'lzop -d'
50 63  
51 64 # Bail out:
52 65 echo "$me: Cannot find kernel config." >&2