forked from ChronoMonochrome/android_kernel_samsung_smdk4412
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_kernel.sh
90 lines (75 loc) · 2.46 KB
/
build_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
#!/bin/sh
export KERNELDIR=/media/system1/root/CM14/out/target/product/i9300/obj/KERNEL_OBJ
export INITRAMFS_SOURCE=`readlink -f $KERNELDIR/../../root`
export PARENT_DIR=`readlink -f ..`
export USE_SEC_FIPS_MODE=true
export ARCH=arm
export CROSS_COMPILE=/media/system1/root/CM14/prebuilts/gcc/linux-x86/arm/arm-eabi-4.9-linaro/bin/arm-eabi-
if [ "${1}" != "" ];then
export KERNELDIR=`readlink -f ${1}`
fi
INITRAMFS_TMP="/tmp/initramfs-source"
#if [ ! -f $KERNELDIR/.config ];
#then
make O=$KERNELDIR lineageos_i9300_defconfig
#fi
. $KERNELDIR/.config
#Remove previous zImage files
if [ -e $KERNELDIR/zImage ]; then
rm $KERNELDIR/zImage
rm $KERNELDIR/arch/arm/boot/zImage
fi
#Remove all old modules before compile.
cd $KERNELDIR
OLDMODULES=`find -name *.ko`
for i in $OLDMODULES
do
rm -f $i
done
#remove previous initramfs files
if [ -e $INITRAMFS_TMP ]; then
echo "removing old temp iniramfs"
rm -rf $INITRAMFS_TMP
fi
if [ -f /tmp/cpio* ]; then
echo "removing old temp iniramfs_tmp.cpio"
rm -rf /tmp/cpio*
fi
#Clean initramfs old compile data
rm -f usr/initramfs_data.cpio
rm -f usr/initramfs_data.o
cd $KERNELDIR/
nice -n 10 make -j8 || exit 1
#copy initramfs files to tmp directory
cp -ax $INITRAMFS_SOURCE $INITRAMFS_TMP
#clear git repositories in initramfs
if [ -e $INITRAMFS_TMP/.git ]; then
find $INITRAMFS_TMP -name .git -exec rm -rf {} \;
fi
#remove empty directory placeholders
find $INITRAMFS_TMP -name EMPTY_DIRECTORY -exec rm -rf {} \;
#remove mercurial repository
if [ -d $INITRAMFS_TMP/.hg ]; then
rm -rf $INITRAMFS_TMP/.hg
fi
#copy modules into initramfs
mkdir -p $INITRAMFS/lib/modules
find -name '*.ko' -exec cp -av {} $INITRAMFS_TMP/lib/modules/ \;
${CROSS_COMPILE}strip --strip-debug $INITRAMFS_TMP/lib/modules/*.ko
chmod 755 $INITRAMFS_TMP/lib/modules/*
nice -n 10 make -j8 zImage CONFIG_INITRAMFS_SOURCE="$INITRAMFS_TMP" || exit 1
if [ -e $KERNELDIR/arch/arm/boot/zImage ]; then
$KERNELDIR/mkshbootimg.py $KERNELDIR/zImage $KERNELDIR/arch/arm/boot/zImage $KERNELDIR/payload.tar $KERNELDIR/recovery.tar.xz
#Copy all needed to ready kernel folder.
mkdir -p $KERNELDIR/READY/boot
cp $KERNELDIR/.config $KERNELDIR/arch/arm/configs/dorimanx_defconfig
cp $KERNELDIR/.config $KERNELDIR/READY/
rm $KERNELDIR/READY/boot/zImage
rm $KERNELDIR/READY/Kernel_Dorimanx-SGII-ICS-V*
stat $KERNELDIR/zImage
cp $KERNELDIR/zImage /$KERNELDIR/READY/boot/
cd $KERNELDIR/READY/
zip -r Kernel_Dorimanx-SGII-ICS-`date +"Date-%d-%m-%y-Time-%H-%M"`.zip .
else
echo "Kernel STUCK in BUILD! no zImage exist"
fi