-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·177 lines (158 loc) · 3.47 KB
/
build.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
#!/bin/bash
nitrogen_dir=nitrogenEx
nitrogen_build_dir=nitrogenEx-build
compiler_dir=../linaro-5.2
compiler_prefix=bin/arm-cortex-linux-gnueabi-
cross_compiler=$compiler_dir/$compiler_prefix
if ! [ -d ~/.ccache/$nitrogen_dir ]; then
echo -e "${bldred}No ccache directory, creating...${txtrst}"
mkdir ~/.ccache
mkdir ~/.ccache/$nitrogen_dir
fi
if ! [ -d ../$nitrogen_build_dir ]; then
echo -e "${bldred}No $nitrogen_build_dir directory, creating...${txtrst}"
mkdir ~/$nitrogen_build_dir
mkdir ~/$nitrogen_build_dir/build_files
fi
if ! [ -d ../$compiler_dir ]; then
echo -e "${bldred}No $compiler_dir directory, creating...${txtrst}"
git clone https://github.com/nitrogen-devs/linaro5.2.git $compiler_dir
fi
# Bash Color
green='\033[01;32m'
red='\033[01;31m'
blink_red='\033[05;31m'
restore='\033[0m'
clear
# Resources
THREAD=$(cat /proc/cpuinfo | grep 'model name' | sed -e 's/.*: //' | wc -l)
KERNEL="zImage"
DEFCONFIG="geehrc_defconfig"
# Kernel Details
BASE_NEX_VER="NitrogenEX.geehrc"
VER=".3.0"
NEX_VER="$BASE_NEX_VER$VER"
# Vars
export KBUILD_BUILD_USER="Mr.MEX"
export KBUILD_BUILD_HOST="nitrogen-pc"
export CCACHE_DIR=~/.ccache/nitrogenex
export LOCALVERSION=.`echo $NEX_VER`
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=$cross_compiler
# Paths
KERNEL_DIR=`pwd`
REPACK_DIR="anykernel"
ZIP_MOVE=~/$nitrogen_build_dir/3.4.0.`echo $NEX_VER`.zip
ZIMAGE_DIR="arch/arm/boot"
# Functions
function clean_all {
rm -rf $REPACK_DIR/tmp/anykernel/zImage
make clean && make mrproper
}
function make_kernel {
make $DEFCONFIG
make -j$THREAD
if [ -f $ZIMAGE_DIR/$KERNEL ]; then
cp -vr $ZIMAGE_DIR/$KERNEL $REPACK_DIR/tmp/anykernel
else
echo -e "No zImage!"
fi
}
function make_zip {
cd $REPACK_DIR
zip -9 -r `echo $NEX_VER`.zip .
if [ -f `echo $NEX_VER`.zip ]; then
mv `echo $NEX_VER`.zip $ZIP_MOVE
else
echo -e "No zip!"
fi
cd $KERNEL_DIR
}
DATE_START=$(date +"%s")
echo -e "${green}"
echo "Kernel Creation Script:"
echo
echo "---------------"
echo "Kernel Version:"
echo "---------------"
echo -e "${red}"; echo -e "${blink_red}"; echo "$NEX_VER"; echo -e "${restore}";
echo -e "${green}"
echo "-----------------"
echo "Making Kernel:"
echo "-----------------"
echo -e "${restore}"
while read -p "Please choose your option:
1. Clean build
2. Dirty build
3. Abort
:> " cchoice
do
case "$cchoice" in
1 )
echo -e "${green}"
echo
echo "[..........Cleaning up..........]"
echo
echo -e "${restore}"
clean_all
echo -e "${green}"
echo
echo "[....Building `echo $NEX_VER`....]"
echo
echo -e "${restore}"
make_kernel
echo -e "${green}"
echo
echo "[....Make `echo $NEX_VER`.zip....]"
echo
echo -e "${restore}"
make_zip
echo -e "${green}"
echo
echo "[.....Moving `echo $NEX_VER`.....]"
echo
echo -e "${restore}"
break
;;
2 )
echo -e "${green}"
echo
echo "[....Building `echo $NEX_VER`....]"
echo
echo -e "${restore}"
make_kernel
echo -e "${green}"
echo
echo "[....Make `echo $NEX_VER`.zip....]"
echo
echo -e "${restore}"
make_zip
echo -e "${green}"
echo
echo "[.....Moving `echo $NEX_VER`.....]"
echo
echo -e "${restore}"
break
;;
3 )
break
;;
* )
echo -e "${red}"
echo
echo "Invalid try again!"
echo
echo -e "${restore}"
;;
esac
done
echo -e "${green}"
echo "-------------------"
echo "Build Completed in:"
echo "-------------------"
echo -e "${restore}"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
echo