| # ---------------------------------------------------------------------- |
| # extract-ikconfig - Extract the .config file from a kernel image |
| # This will only work when the kernel was compiled with CONFIG_IKCONFIG. |
| # 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@streefland.net> |
| # Licensed under the terms of the GNU General Public License. |
| # ---------------------------------------------------------------------- |
| cf1='IKCFG_ST\037\213\010' |
| if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"` |
| tail -c+$(($pos+8)) "$1" | zcat -q |
| if [ $# -ne 1 -o ! -s "$img" ] |
| echo "Usage: $me <kernel-image>" >&2 |
| # Initial attempt for uncompressed images or objects: |
| # That didn't work, so decompress and try again: |
| for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"` |
| tail -c+$pos "$img" | zcat 2> /dev/null > $tmp |
| echo "$me: Cannot find kernel config." >&2 |