-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·86 lines (69 loc) · 2.43 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
#!/bin/bash
#
#
# Quanta build script
#
# How to use:
# Compiling wihtout any arguments will compile the AOSP version
# Compiling with cm or CM for an argument will compile the CM version
#
#
export CROSS_COMPILE="$HOME/uber-arm-eabi-5.x/bin/arm-eabi-"
KERNEL_DIRECTORY="$HOME/Quanta-Mako"
ANYKERNEL_DIRECTORY="$HOME/anykernel2_msm"
ANYKERNEL_BRANCH="mako-7.x"
JOBS=$(grep -c "processor" /proc/cpuinfo)
# Verify if the CM patches has already been applied. We don't want to apply them again if the compiling is stopped
CM_CHECK=$(grep -c "case MDP_YCBYCR_H2V1:" drivers/video/msm/mdp4_overlay.c)
DEVICE="Mako"
VERSION=21
# Function responsible for download Anykernel if it's not found by the ANYKERNEL_DIRECTORY variable.
function download_anykernel2() {
echo "Anykernel hasn't been found in $ANYKERNEL_DIRECTORY."
echo "Downloading it..."
git clone https://github.com/zaclimon/anykernel2_msm -b $ANYKERNEL_BRANCH $ANYKERNEL_DIRECTORY
}
# Download Anykernel if not found.
if [ ! -d $ANYKERNEL_DIRECTORY ] ; then
download_anykernel2
fi
# Set the packaging information here. Specify if CM or AOSP.
if [[ "$1" =~ "cm" || "$1" =~ "CM" ]] ; then
kernelzip="Quanta-V$VERSION-CM-$DEVICE-AnyKernel2.zip"
# Apply the CM patches if the variant specified is CM.
if [ $CM_CHECK -eq 0 ] ; then
git am CM/*
fi
else
kernelzip="Quanta-V$VERSION-$DEVICE-AnyKernel2.zip"
fi
# Ensure that we're on the correct Anykernel branch
cd $ANYKERNEL_DIRECTORY
git checkout $ANYKERNEL_BRANCH
cd $KERNEL_DIRECTORY
# Create a /zip directory if not present
mkdir -p ./zip
# Clean the /zip directory if there have been a zip file before (Mostly a version of Quanta compiled.)
if [ -e zip/*.zip ] ; then
rm -rf zip/*
fi
# Strangely, the kernel after compiling, auto-increments the version by 1. Let's revert that by decreasing the version value also by 1.
let "VERSION -= 1"
echo $VERSION > .version
make quanta_defconfig
make -j$JOBS
# Copy the contents of the Anykernel folder if we confirm that a zImage is present.
if [ -f arch/arm/boot/zImage ] ; then
cd $ANYKERNEL_DIRECTORY
cp -r * $KERNEL_DIRECTORY/zip/
cd $KERNEL_DIRECTORY
cp arch/arm/boot/zImage zip/
# Remove the previously applied CM patches if we compiled with them before.
if [[ "$1" =~ "cm" || "$1" =~ "CM" ]] ; then
git reset --hard HEAD~2
fi
cd zip/
rm -f README.md
zip -r $kernelzip *
echo "The kernel is situated at zip/$kernelzip"
fi