forked from sgt7/android_kernel_samsung_p1
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_zImage.sh
89 lines (78 loc) · 2.28 KB
/
build_zImage.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/bash
#
# Script to build Galaxy Tab Kernel
# 2012 Chirayu Desai
# Common defines
txtrst='\e[0m' # Color off
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
echo -e "${txtblu}##########################################"
echo -e "${txtblu}# #"
echo -e "${txtblu}# GALAXYTAB KERNEL BUILDSCRIPT #"
echo -e "${txtblu}# #"
echo -e "${txtblu}##########################################"
echo -e "\r\n ${txtrst}"
# Starting Timer
START=$(date +%s)
DEVICE="$1"
THREADS=`cat /proc/cpuinfo | grep processor | wc -l`
case "$DEVICE" in
clean)
make clean
exit
;;
p1|P1)
DEFCONFIG=p1_cm9_defconfig
;;
p1c|P1C)
DEFCONFIG=p1c_cm9_defconfig
;;
p1l|P1L)
DEFCONFIG=p1l_cm9_defconfig
;;
p1n|P1N)
DEFCONFIG=p1n_cm9_defconfig
;;
*)
echo -e "${txtred}Usage: $0 device"
echo -e "Example: ./build.sh p1"
echo -e "Supported Devices: p1|P1 p1c|P1C p1l|P1L p1n|P1N ${txtrst}"
;;
esac
# Some defines
KERNEL_DIR=`pwd`
KERNEL_INITRD_DIR="../initramfs"
KERNEL_INITRD_GIT="https://github.com/sgt7/p1000-initramfs-cm9.git"
INITSOURCE=`grep CONFIG_INITRAMFS_SOURCE arch/arm/configs/$DEFCONFIG `
# Check if initramfs is present, if not, then clone it
if [ ! -d $KERNEL_INITRD_DIR ]; then
cd ..
git clone $KERNEL_INITRD_GIT initramfs
cd $KERNEL_DIR
fi
# .git is huge!
mv $KERNEL_INITRD_DIR/.git ~/DONOTLOOKATME
echo -e "${txtblu} Checking if your initramfs path is correct....${txtrst}"
if [ ! "$INITSOURCE" = "CONFIG_INITRAMFS_SOURCE=\"../initramfs\"" ]; then
echo -e "${txtblu}The initramfs path was: ""${txtred}$INITSOURCE${txtrst}"
sed -i "s|CONFIG_INITRAMFS_SOURCE=\".*\"|CONFIG_INITRAMFS_SOURCE=\"../initramfs\"|" arch/arm/configs/$DEFCONFIG
INITSOURCE=`grep CONFIG_INITRAMFS_SOURCE arch/arm/configs/$DEFCONFIG `
echo -e "${txtblu}Now changed to: ""${txtgrn}$INITSOURCE${txtrst}"
fi
# The real build starts now
if [ ! "$1" = "" ] ; then
make -j$THREADS ARCH=arm $DEFCONFIG
make -j$THREADS
fi
# move it back just in case
mv ~/DONOTLOOKATME $KERNEL_INITRD_DIR/.git
# The end!
END=$(date +%s)
ELAPSED=$((END - START))
E_MIN=$((ELAPSED / 60))
E_SEC=$((ELAPSED - E_MIN * 60))
printf "Elapsed: "
[ $E_MIN != 0 ] && printf "%d min(s) " $E_MIN
printf "%d sec(s)\n" $E_SEC