-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_nemesis.sh
executable file
·186 lines (160 loc) · 4.68 KB
/
build_nemesis.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
# kernel build script by Tkkg1994 v0.6 (optimized from apq8084 kernel source)
export MODEL=noblelte
export ARCH=arm64
export BUILD_CROSS_COMPILE=/home/geiti94/android/toolchain/aarch64-sabermod-7.0/bin/aarch64-
export BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
RDIR=$(pwd)
OUTDIR=$RDIR/arch/$ARCH/boot
DTSDIR=$RDIR/arch/$ARCH/boot/dts
DTBDIR=$OUTDIR/dtb
DTCTOOL=$RDIR/scripts/dtc/dtc
INCDIR=$RDIR/include
PAGE_SIZE=2048
DTB_PADDING=0
if [ $MODEL = noblelte ]
then
KERNEL_DEFCONFIG=exynos7420-noblelte_defconfig
else if [ $MODEL = zeroflte ]
then
KERNEL_DEFCONFIG=exynos7420-zeroflte_defconfig
else if [ $MODEL = zerolte ]
then
KERNEL_DEFCONFIG=exynos7420-zerolte_defconfig
else [ $MODEL = zenlte ]
KERNEL_DEFCONFIG=exynos7420-zenlte_defconfig
fi
fi
fi
FUNC_CLEAN_DTB()
{
if ! [ -d $RDIR/arch/$ARCH/boot/dts ] ; then
echo "no directory : "$RDIR/arch/$ARCH/boot/dts""
else
echo "rm files in : "$RDIR/arch/$ARCH/boot/dts/*.dtb""
rm $RDIR/arch/$ARCH/boot/dts/*.dtb
rm $RDIR/arch/$ARCH/boot/dtb/*.dtb
rm $RDIR/arch/$ARCH/boot/boot.img-dtb
rm $RDIR/arch/$ARCH/boot/boot.img-zImage
fi
}
FUNC_BUILD_DTIMAGE_TARGET()
{
[ -f "$DTCTOOL" ] || {
echo "You need to run ./build.sh first!"
exit 1
}
case $MODEL in
noblelte)
DTSFILES="exynos7420-noblelte_eur_open_09"
;;
zeroflte)
DTSFILES=""
;;
zerolte)
DTSFILES=""
;;
zenlte)
DTSFILES=""
;;
*)
echo "Unknown device: $MODEL"
exit 1
;;
esac
mkdir -p $OUTDIR $DTBDIR
cd $DTBDIR || {
echo "Unable to cd to $DTBDIR!"
exit 1
}
rm -f ./*
echo "Processing dts files..."
for dts in $DTSFILES; do
echo "=> Processing: ${dts}.dts"
${CROSS_COMPILE}cpp -nostdinc -undef -x assembler-with-cpp -I "$INCDIR" "$DTSDIR/${dts}.dts" > "${dts}.dts"
echo "=> Generating: ${dts}.dtb"
$DTCTOOL -p $DTB_PADDING -i "$DTSDIR" -O dtb -o "${dts}.dtb" "${dts}.dts"
done
echo "Generating dtb.img..."
$RDIR/scripts/dtbTool/dtbTool -o "$OUTDIR/dtb.img" -d "$DTBDIR/" -s $PAGE_SIZE
echo "Done."
}
FUNC_BUILD_KERNEL()
{
echo ""
echo "=============================================="
echo "START : FUNC_BUILD_KERNEL"
echo "=============================================="
echo ""
echo "build common config="$KERNEL_DEFCONFIG ""
echo "build variant config="$MODEL ""
FUNC_CLEAN_DTB
make -j$BUILD_JOB_NUMBER ARCH=$ARCH \
CROSS_COMPILE=$BUILD_CROSS_COMPILE \
$KERNEL_DEFCONFIG || exit -1
make -j$BUILD_JOB_NUMBER ARCH=$ARCH \
CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1
FUNC_BUILD_DTIMAGE_TARGET
echo ""
echo "================================="
echo "END : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
}
FUNC_BUILD_RAMDISK()
{
mv $RDIR/arch/$ARCH/boot/Image $RDIR/arch/$ARCH/boot/boot.img-zImage
mv $RDIR/arch/$ARCH/boot/dtb.img $RDIR/arch/$ARCH/boot/boot.img-dtb
case $MODEL in
noblelte)
rm -f $RDIR/ramdisk/SM-N920F/split_img/boot.img-zImage
rm -f $RDIR/ramdisk/SM-N920F/split_img/boot.img-dtb
mv -f $RDIR/arch/$ARCH/boot/boot.img-zImage $RDIR/ramdisk/SM-N920F/split_img/boot.img-zImage
mv -f $RDIR/arch/$ARCH/boot/boot.img-dtb $RDIR/ramdisk/SM-N920F/split_img/boot.img-dtb
cd $RDIR/ramdisk/SM-N920F
./repackimg.sh
echo SEANDROIDENFORCE >> image-new.img
;;
zeroflte)
rm -f $RDIR/ramdisk/SM-G920F/split_img/boot.img-zImage
rm -f $RDIR/ramdisk/SM-G920F/split_img/boot.img-dtb
mv -f $RDIR/arch/$ARCH/boot/boot.img-zImage $RDIR/ramdisk/SM-G920F/split_img/boot.img-zImage
mv -f $RDIR/arch/$ARCH/boot/boot.img-dtb $RDIR/ramdisk/SM-G920F/split_img/boot.img-dtb
cd $RDIR/ramdisk/SM-G920F
./repackimg.sh
echo SEANDROIDENFORCE >> image-new.img
;;
zerolte)
rm -f $RDIR/ramdisk/SM-G925F/split_img/boot.img-zImage
rm -f $RDIR/ramdisk/SM-G925F/split_img/boot.img-dtb
mv -f $RDIR/arch/$ARCH/boot/boot.img-zImage $RDIR/ramdisk/SM-G925F/split_img/boot.img-zImage
mv -f $RDIR/arch/$ARCH/boot/boot.img-dtb $RDIR/ramdisk/SM-G925F/split_img/boot.img-dtb
cd $RDIR/ramdisk/SM-G925F
./repackimg.sh
echo SEANDROIDENFORCE >> image-new.img
;;
zenlte)
rm -f $RDIR/ramdisk/SM-G928F/split_img/boot.img-zImage
rm -f $RDIR/ramdisk/SM-G928F/split_img/boot.img-dtb
mv -f $RDIR/arch/$ARCH/boot/boot.img-zImage $RDIR/ramdisk/SM-G928F/split_img/boot.img-zImage
mv -f $RDIR/arch/$ARCH/boot/boot.img-dtb $RDIR/ramdisk/SM-G928F/split_img/boot.img-dtb
cd $RDIR/ramdisk/SM-G928F
./repackimg.sh
echo SEANDROIDENFORCE >> image-new.img
;;
*)
echo "Unknown device: $MODEL"
exit 1
;;
esac
}
# MAIN FUNCTION
rm -rf ./build.log
(
START_TIME=`date +%s`
FUNC_BUILD_KERNEL
FUNC_BUILD_RAMDISK
END_TIME=`date +%s`
let "ELAPSED_TIME=$END_TIME-$START_TIME"
echo "Total compile time is $ELAPSED_TIME seconds"
) 2>&1 | tee -a ./build.log