forked from linux-rockchip/linux-rockchip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack-kernel.sh
executable file
·150 lines (120 loc) · 3.44 KB
/
pack-kernel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
set -e
FILES=(
# arch
arch/arm/mach-rk29/clock.c
arch/arm/mach-rk29/ddr.c
arch/arm/mach-rk29/vpu.c
arch/arm/mach-rk29/vpu_mem.c
drivers/staging/rk29/ipp/rk29-ipp.c
sound/soc/codecs/rt5625.c
)
DIRS=(
drivers/staging/rk29/vivante/
)
EXCLUDES=(
arch/arm/mach-rk2818/*.c
arch/arm/mach-rk2818/*.h
arch/arm/mach-rk2818/include/mach
arch/arm/configs/rk28*
drivers/*rk28*.c
sound/*rk28*.c
sound/*rk28*.h
include/*rk28*
drivers/staging/rk29/vivante/*.c
drivers/staging/rk29/vivante/*.h
arch/arm/configs/rk29_sdk_yaffs2_defconfig
arch/arm/mach-rk29/board-malata.c
arch/arm/mach-rk29/board-rk29malata-key.c
arch/arm/configs/rk29_malata_defconfig
arch/arm/mach-rk29/board-rk29-winaccord.c
arch/arm/configs/rk29_Winaccord_defconfig
arch/arm/mach-rk29/board-rk29-a22*
arch/arm/configs/rk29_a22_defconfig
arch/arm/mach-rk29/board-rk29-fih*
arch/arm/configs/rk29_FIH_defconfig
arch/arm/mach-rk29/board-rk29-newton*
arch/arm/configs/rk29_newton_defconfig
)
# ---------------------------------------------------------------------------
usage() {
echo usage: $0 kerneldir defconfig
echo example: $0 . rk29_sdk_defconfig
exit
}
while getopts "h" options; do
case $options in
h ) usage;;
esac
done
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
kerndir=${1-.}
kerndir=$(cd $kerndir; pwd) # get absolute path
[ -d $kerndir ] || usage
defconfig=${2-rk29_sdk_defconfig}
if [ "$defconfig" = ".config" ]; then
[ -f $kerndir/.config ] || usage
else
[ -f $kerndir/arch/arm/configs/$defconfig ] || usage
fi
# ---------------------------------------------------------------------------
# make .uu
pushd $kerndir >/dev/null
declare -a files
for file in ${FILES[@]}; do
[ -e ${file} ] && files=( ${files[@]} ${file} ) || echo No such file: ${file}
[ -f ${file/.[cS]/.uu} ] && rm -f ${file/.[cS]/.uu}
done
for d in ${DIRS[@]}; do
[ -d $d ] && find $d -type f -name '*.uu' -print0 | xargs -0 rm -f
done
#zwp
mv sound/soc/codecs/rt5625.c sound/soc/codecs/rt5625.c.bak
mv sound/soc/codecs/rt5625.c.enc sound/soc/codecs/rt5625.c
####
echo build kernel on $kerndir with $defconfig
make clean >/dev/null 2>&1
make $defconfig >/dev/null 2>&1
make -j`grep 'processor' /proc/cpuinfo | wc -l` ${files[@]/.[cS]/.o} ${DIRS[@]}
for file in ${FILES[@]}; do
filename=${file##*/}
base=${filename%%.*}
dir=${file%/*}
[ -f $dir/$base.o ] && echo UU $dir/$base.uu && uuencode $dir/$base.o $base.o > $dir/$base.uu
done
for d in ${DIRS[@]}; do
for file in `find $d -type f -name '*.o'`; do
filename=${file##*/}
base=${filename%%.*}
dir=${file%/*}
echo UU $dir/$base.uu && uuencode $dir/$base.o $base.o > $dir/$base.uu
done
done
#zwp
mv sound/soc/codecs/rt5625.c sound/soc/codecs/rt5625.c.enc
mv sound/soc/codecs/rt5625.c.bak sound/soc/codecs/rt5625.c
####
make distclean >/dev/null 2>&1
popd >/dev/null
# tar kernel
pushd $kerndir/../ >/dev/null
package=$(basename $kerndir).tar
ex=$package.ex
> $ex
for file in ${FILES[@]}; do
echo "$file" >> $ex
done
for file in ${EXCLUDES[@]}; do
echo "$file" >> $ex
done
echo sound/soc/codecs/rt5625.c >>$ex
echo sound/soc/codecs/rt5625.c.enc >>$ex
echo TAR $(pwd)/$package
tar cf $package --numeric-owner --exclude-from $ex --exclude=.git --exclude=`basename $0` $(basename $kerndir)
tar rf $package --numeric-owner --exclude=.git toolchain/arm-eabi-4.4.0
echo GZIP $(pwd)/$package.gz
gzip -9 -c $package > $package.gz
rm $ex
popd >/dev/null
echo done