blob: e8feba82c4368f5c7a8ee2d0a7ec320b2298d5e9 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/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
12BLOCK_SIZE=2621440
13DICT_SIZE=2097152
14PRESET=6
15
16BCJ=
17LZMA2OPTS=
18
19case $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 ;;
25esac
26
27if [ "$BCJ" = "--arm" ] && grep -Fq CONFIG_ARM_THUMB=y "$srctree/$KCONFIG_CONFIG"; then
28 BCJ=--armthumb
29fi
30
31:<<EOF
32exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB
33EOF
34
35set -e
36LZMA2OPTS=$LZMA2OPTS,preset=$PRESET,dict=$DICT_SIZE
37
38if [ -n "$TMP_DIR" ]; then
39 export TMPDIR=$TMP_DIR
40fi
41
42TMPF=`mktemp`
43split -b $BLOCK_SIZE - $TMPF.part
44$XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS $TMPF.part??
45cat $TMPF.part??.xz
46rm -f $TMPF $TMPF.part?? $TMPF.part??.xz