b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # This is a wrapper for xz to compress the kernel image using appropriate |
| 4 | # compression options depending on the architecture. |
| 5 | # |
| 6 | # Author: Lasse Collin <lasse.collin@tukaani.org> |
| 7 | # |
| 8 | # This file has been put into the public domain. |
| 9 | # You can do whatever you want with this file. |
| 10 | # |
| 11 | |
| 12 | BLOCK_SIZE=2621440 |
| 13 | DICT_SIZE=2097152 |
| 14 | PRESET=6 |
| 15 | |
| 16 | BCJ= |
| 17 | LZMA2OPTS= |
| 18 | |
| 19 | case $SRCARCH in |
| 20 | x86) BCJ=--x86 ;; |
| 21 | powerpc) BCJ=--powerpc ;; |
| 22 | ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;; |
| 23 | arm) BCJ=--arm ;; |
| 24 | sparc) BCJ=--sparc ;; |
| 25 | esac |
| 26 | |
| 27 | if [ "$BCJ" = "--arm" ] && grep -Fq CONFIG_ARM_THUMB=y "$srctree/$KCONFIG_CONFIG"; then |
| 28 | BCJ=--armthumb |
| 29 | fi |
| 30 | |
| 31 | :<<EOF |
| 32 | exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB |
| 33 | EOF |
| 34 | |
| 35 | set -e |
| 36 | LZMA2OPTS=$LZMA2OPTS,preset=$PRESET,dict=$DICT_SIZE |
| 37 | |
| 38 | if [ -n "$TMP_DIR" ]; then |
| 39 | export TMPDIR=$TMP_DIR |
| 40 | fi |
| 41 | |
| 42 | TMPF=`mktemp` |
| 43 | split -b $BLOCK_SIZE - $TMPF.part |
| 44 | $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS $TMPF.part?? |
| 45 | cat $TMPF.part??.xz |
| 46 | rm -f $TMPF $TMPF.part?? $TMPF.part??.xz |