forked from jcadduono/idleKernel-note3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_all.sh
executable file
·157 lines (134 loc) · 4.02 KB
/
build_all.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
#!/bin/bash
# idleKernel for Samsung Galaxy Note 3 build script by jcadduono
# This build script is for Note 5 Touchwiz ports only
# This build script builds all variants in /ik.ramdisk/variant/
################### BEFORE STARTING ################
#
# download a working toolchain and extract it somewhere and configure this file
# to point to the toolchain's root directory.
# I highly recommend Christopher83's Linaro GCC 4.9.x Cortex-A15 toolchain.
# Download it here: http://forum.xda-developers.com/showthread.php?t=2098133
#
# once you've set up the config section how you like it, you can simply run
# ./build_all.sh
# while inside the /idleKernel-note3/ directory.
#
###################### CONFIG ######################
# root directory of idleKernel git repo (default is this script's location)
RDIR=$(pwd)
[ -z $VER ] && \
# version number
VER=$(cat $RDIR/VERSION)
# output directory of flashable kernel
OUT_DIR_ENFORCING="/home/jc/idlekernel.com/note5port/selinux_enforcing/v"$VER"_"$(date +'%Y_%m_%d')
OUT_DIR_PERMISSIVE="/home/jc/idlekernel.com/note5port/v"$VER"_"$(date +'%Y_%m_%d')
# should we make a TWRP flashable zip? (1 = yes, 0 = no)
MAKE_ZIP=1
# should we make an Odin flashable tar.md5? (1 = yes, 0 = no)
MAKE_TAR=1
# directory containing cross-compile arm-cortex_a15 toolchain
TOOLCHAIN=/home/jc/build/toolchain/arm-cortex_a15-linux-gnueabihf-linaro_4.9.4-2015.06
# amount of cpu threads to use in kernel make process
THREADS=5
SET_KERNEL_VERSION()
{
# kernel version string appended to 3.4.x-idleKernel-hlte-
# (shown in Settings -> About device)
KERNEL_VERSION=$VARIANT-$VER-note5port
# output filename of flashable kernel
OUT_NAME=idleKernel-hlte-$KERNEL_VERSION
}
############## SCARY NO-TOUCHY STUFF ###############
export ARCH=arm
export CROSS_COMPILE=$TOOLCHAIN/bin/arm-eabi-
KDIR=$RDIR/build/arch/arm/boot
CLEAN_BUILD()
{
echo "Cleaning build..."
cd $RDIR
rm -rf build
echo "Removing old boot.img..."
rm -f ik.zip/boot.img
echo "Removing old zip/tar.md5 files..."
rm -f $OUT_DIR/$OUT_NAME.zip
rm -f $OUT_DIR/$OUT_NAME.tar.md5
}
BUILD_KERNEL()
{
echo "Creating kernel config..."
cd $RDIR
mkdir -p build
make -C $RDIR O=build ik_defconfig \
VARIANT_DEFCONFIG=variant_hlte_$VARIANT \
SELINUX_DEFCONFIG=selinux_$SELINUX
echo "Starting build..."
make -C $RDIR O=build -j"$THREADS"
}
BUILD_RAMDISK()
{
VARIANT=$VARIANT $RDIR/setup_ramdisk.sh
cd $RDIR/build/ramdisk
echo "Building ramdisk.img..."
find | fakeroot cpio -o -H newc | gzip -9 > $KDIR/ramdisk.cpio.gz
cd $RDIR
}
BUILD_BOOT_IMG()
{
echo "Generating boot.img..."
$RDIR/scripts/mkqcdtbootimg/mkqcdtbootimg --kernel $KDIR/zImage \
--ramdisk $KDIR/ramdisk.cpio.gz \
--dt_dir $KDIR \
--cmdline "quiet console=null androidboot.hardware=qcom user_debug=23 msm_rtb.filter=0x37 ehci-hcd.park=3" \
--base 0x00000000 \
--pagesize 2048 \
--ramdisk_offset 0x02000000 \
--tags_offset 0x01E00000 \
--output $RDIR/ik.zip/boot.img
}
CREATE_ZIP()
{
echo "Compressing to TWRP flashable zip file..."
cd $RDIR/ik.zip
zip -r -9 - * > $OUT_DIR/$OUT_NAME.zip
cd $RDIR
}
CREATE_TAR()
{
echo "Compressing to Odin flashable tar.md5 file..."
cd $RDIR/ik.zip
tar -H ustar -c boot.img > $OUT_DIR/$OUT_NAME.tar
cd $OUT_DIR
md5sum -t $OUT_NAME.tar >> $OUT_NAME.tar
mv $OUT_NAME.tar $OUT_NAME.tar.md5
cd $RDIR
}
DO_BUILD()
{
echo "Starting build for $OUT_NAME, SELINUX = $SELINUX..."
CLEAN_BUILD && BUILD_KERNEL && BUILD_RAMDISK && BUILD_BOOT_IMG || {
echo "Error!"
exit -1
}
if [ $MAKE_ZIP -eq 1 ]; then CREATE_ZIP; fi
if [ $MAKE_TAR -eq 1 ]; then CREATE_TAR; fi
}
#mkdir -p $OUT_DIR_ENFORCING
mkdir -p $OUT_DIR_PERMISSIVE
for V in $RDIR/ik.ramdisk/variant/*
do
VARIANT=${V#$RDIR/ik.ramdisk/variant/}
if ! [ -f $RDIR"/arch/arm/configs/variant_hlte_"$VARIANT ] ; then
echo "Device variant/carrier $VARIANT not found in arm configs!"
continue
else
SET_KERNEL_VERSION
export LOCALVERSION=$KERNEL_VERSION
#OUT_DIR=$OUT_DIR_ENFORCING
#SELINUX="always_enforce"
#DO_BUILD
OUT_DIR=$OUT_DIR_PERMISSIVE
SELINUX="never_enforce"
DO_BUILD
fi
done;
echo "Finished!"