forked from jcadduono/idleKernel-note3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·166 lines (140 loc) · 4.29 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
# idleKernel for Samsung Galaxy Note 3 build script by jcadduono
# This build script is for Touchwiz Lollipop only
################### 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.sh
# while inside the /idleKernel-note3/ directory.
#
###################### CONFIG ######################
# root directory of idleKernel git repo (default is this script's location)
RDIR=$(pwd)
[ -z $VARIANT ] && \
# device variant/carrier, possible options:
# att = N900A (AT&T)
# can = N900W8 (Canadian, same as T-Mobile)
# eur = N9005 (Snapdragon International / hltexx / Europe)
# spr = N900P (Sprint)
# tmo = N900T (T-Mobile, same as Canadian)
# usc = N900R4 (US Cellular)
# vzw = N900V (Verizon)
# korean variants:
# ktt = N900K (KT Corporation)
# lgt = N900L (LG Telecom)
# skt = N900S (South Korea Telecom)
# japanese variants:
# dcm = N900D / SC-01F (NTT Docomo)
# kdi = N900J / SCL22 (au by KDDI)
VARIANT=can
[ -z $VER ] && \
# version number
VER=$(cat $RDIR/VERSION)
# kernel version string appended to 3.4.x-idleKernel-hlte-
# (shown in Settings -> About device)
KERNEL_VERSION=$VARIANT-$VER
[ -z $PERMISSIVE ] && \
# should we boot with SELinux mode set to permissive? (1 = permissive, 0 = enforcing)
PERMISSIVE=1
# output directory of flashable kernel
OUT_DIR=$RDIR
# output filename of flashable kernel
OUT_NAME=idleKernel-hlte-$KERNEL_VERSION
# 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
############## SCARY NO-TOUCHY STUFF ###############
export ARCH=arm
export CROSS_COMPILE=$TOOLCHAIN/bin/arm-eabi-
export LOCALVERSION=$KERNEL_VERSION
if ! [ -f $RDIR"/arch/arm/configs/variant_hlte_"$VARIANT ] ; then
echo "Device variant/carrier $VARIANT not found in arm configs!"
exit -1
fi
if ! [ -d $RDIR"/ik.ramdisk/variant/$VARIANT/" ] ; then
echo "Device variant/carrier $VARIANT not found in ik.ramdisk/variant!"
exit -1
fi
[ $PERMISSIVE -eq 1 ] && SELINUX="never_enforce" || SELINUX="always_enforce"
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
}
DO_BUILD