-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·166 lines (142 loc) · 3.69 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
#!/bin/bash
#
# Build Script for Render Kernel for OPO!
# Based off AK'sbuild script - Thanks!
#
# Bash Color
green='\033[01;32m'
red='\033[01;31m'
blink_red='\033[05;31m'
restore='\033[0m'
clear
# Resources
THREAD="-j$(grep -c ^processor /proc/cpuinfo)"
KERNEL="zImage"
DT_IMG="dt.img"
DEFCONFIG="render_defconfig"
CMDLINE="console=ttyHSL0,115200,n8 androidboot.hardware=bacon user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1"
BASE="0x00000000"
PAGESIZE="2048"
RAMDISK_OFFSET="0x02000000"
TAGS_OFFSET="0x01e00000"
# Kernel Details
VER=Render-Kernel
# Vars
export LOCALVERSION=~`echo $VER`
export ARCH=arm
export SUBARCH=arm
export KBUILD_BUILD_USER=RenderBroken
export KBUILD_BUILD_HOST=RenderServer.net
export CCACHE=ccache
# Paths
KERNEL_DIR="${HOME}/android/source/kernel/msm8974_OPO-CAF_render_kernel"
OZIP_DIR="${HOME}/android/source/kernel/msm8974_OPO-CAF_render_kernel/ozip"
MODULES_DIR="${HOME}/android/source/kernel/msm8974_OPO-CAF_render_kernel/ozip/system/lib/modules"
RAMDISK_DIR="${HOME}/android/source/kernel/msm8974_OPO_render_kernel_ramdisk"
ZIP_MOVE="${HOME}/android/source/zips/opo-caf-zips"
ZIMAGE_DIR="${HOME}/android/source/kernel/msm8974_OPO-CAF_render_kernel/arch/arm/boot"
TOOLS_DIR="${HOME}/android/source/render-tools"
OUT_DIR="${HOME}/android/source/out/opo-caf"
RAMDISK="$OUT_DIR/ramdisk.gz"
VARIANT="OPO-CAF"
# Functions
function clean_all {
rm -rf /home/renderbroken/android/source/kernel/msm8974_OPO-CAF_render_kernel/ozip/system/lib/modules/*
rm -rf $OZIP_DIR/boot.img
rm -rf arch/arm/boot/"$KERNEL"
echo
make clean && make mrproper
}
function make_kernel {
echo
make $DEFCONFIG
make $THREAD
cp -vr $ZIMAGE_DIR/$KERNEL $OUT_DIR
}
function make_modules {
rm -rf /home/renderbroken/android/source/kernel/msm8974_OPO-CAF_render_kernel/ozip/system/lib/modules/*
find $KERNEL_DIR -name "*.ko" -exec cp -v {} $MODULES_DIR \;
}
function make_ramdisk {
cd $RAMDISK_DIR
git checkout caf-lp-ramdisk
$KERNEL_DIR/mkbootfs $RAMDISK_DIR | gzip > $OUT_DIR/ramdisk.gz
}
function make_dt_img {
cd $KERNEL_DIR
$KERNEL_DIR/dtbToolCM -2 -o $OUT_DIR/$DT_IMG -s 2048 -p scripts/dtc/ arch/arm/boot/
}
function make_bootimg {
$KERNEL_DIR/mkbootimg --kernel $OUT_DIR/zImage --ramdisk $OUT_DIR/ramdisk.gz --cmdline "$CMDLINE" --base $BASE --pagesize $PAGESIZE --offset $RAMDISK_OFFSET --tags-addr $TAGS_OFFSET --dt $OUT_DIR/dt.img -o $OZIP_DIR/boot.img
}
function make_zip {
cd $OZIP_DIR
zip -r9 RenderKernel-"$VARIANT"-R.zip *
mv RenderKernel-"$VARIANT"-R.zip $ZIP_MOVE
cd $KERNEL_DIR
rm -rf $OUT_DIR/*
}
DATE_START=$(date +"%s")
echo -e "${green}"
echo "Render Kernel Creation Script:"
echo -e "${restore}"
echo "Pick Toolchain..."
select choice in UBER-4.9-Cortex-a15 UBER-5.1
do
case "$choice" in
"UBER-4.9-Cortex-a15")
export CROSS_COMPILE=${HOME}/android/source/toolchains/UBER-arm-eabi-4.9-cortex-a15-062715/bin/arm-eabi-
break;;
"UBER-5.1")
export CROSS_COMPILE=${HOME}/android/source/toolchains/UBER-arm-eabi-5.1-062715/bin/arm-eabi-
break;;
esac
done
while read -p "Do you want a clean build (y/n)? " cchoice
do
case "$cchoice" in
y|Y )
clean_all
echo
echo "All Cleaned now."
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo
while read -p "Do you want to build kernel (y/n)? " dchoice
do
case "$dchoice" in
y|Y)
make_kernel
make_modules
make_ramdisk
make_dt_img
make_bootimg
make_zip
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${green}"
echo "Build Completed in:"
echo -e "${restore}"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."