-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
137 lines (124 loc) · 2.85 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
#!/bin/bash
#
# Build Script for CarboniteKERNEL for the OnePlus 5!
# Based off RenderBroken's build script which is...
# ...based off AK's build script ~~ Thanks!
#
# git log --oneline --decorate
#
# Resources
THREAD="-j$(grep -c ^processor /proc/cpuinfo)"
KERNEL="Image.gz-dtb"
DEFCONFIG="flash_defconfig"
VER="Adins-Kernel-OOS-R1"
VARIANT="OP5-N"
# Paths
ANDROID_DIR="${HOME}"
KERNEL_DIR="$ANDROID_DIR/kernels/op5"
REPACK_DIR="$ANDROID_DIR/kernels/anykernel2"
MODULES_DIR="$REPACK_DIR/modules"
ZIP_MOVE="$ANDROID_DIR/kernels/out/op5"
ZIMAGE_DIR="$KERNEL_DIR/arch/arm64/boot"
# Vars
export ARCH=arm64
export SUBARCH=arm64
export LOCALVERSION=-`echo $VER`
export CROSS_COMPILE="$ANDROID_DIR/carbon/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-androidkernel-"
function clean_all {
echo
make clean O=out && make mrproper O=out
if [ -f "$ZIMAGE_DIR/$KERNEL" ]
then
rm $ZIMAGE_DIR/$KERNEL
fi
}
function make_kernel {
echo
make $DEFCONFIG O=out
make $THREADO=out
}
function make_modules {
rm `echo $MODULES_DIR"/*"`
find $KERNEL_DIR -name '*.ko' -exec cp {} $MODULES_DIR \;
${CROSS_COMPILE}strip --strip-unneeded $MODULES_DIR/*
}
function make_zip {
cd $REPACK_DIR
zip -r9 "$VER"-"$VARIANT".zip *
mv "$VER"-"$VARIANT".zip $ZIP_MOVE
cd $KERNEL_DIR
}
if [ -f "$REPACK_DIR/zImage" ]
then
rm -rf $REPACK_DIR/zImage
fi
clear
echo "CarboniteKERNEL build script for $ROM:"
echo
if [ -f "$KERNEL_DIR/.config" ]
then
while read -p "Do you want to clean stuffs (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
fi
while read -p "Do you want to build kernel (y/n)? " dchoice
do
case "$dchoice" in
y|Y)
DATE_START=$(date +"%s")
make_kernel
if [ -f "$ZIMAGE_DIR/$KERNEL" ]
then
cp $ZIMAGE_DIR/$KERNEL $REPACK_DIR/zImage
make_modules
make_zip
echo
echo "-----------------------------------------"
echo "-Kernel image build successfull for $ROM-"
echo "-----------------------------------------"
echo
else
echo "-------------------------------------------"
echo "-Kernel image build unsuccessfull for $ROM-"
echo "-------------------------------------------"
fi
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo
if [ -f "$ZIP_MOVE/$VER-$VARIANT.zip" ]
then
echo "$ZIP_MOVE/$VER-$VARIANT.zip"
else
echo "No zip was found, build incomplete."
fi
echo