This repository has been archived by the owner on Nov 18, 2019. It is now read-only.
forked from MOTO-M8916/old_kernel_motorola_msm8916
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_SmartPack.sh
117 lines (90 loc) · 3.66 KB
/
build_SmartPack.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
#!/bin/bash
#
# SmartPack-Kernel Build Script
#
# Author: sunilpaulmathew <sunil.kde@gmail.com>
#
#
# This script is licensed under the terms of the GNU General Public
# License version 2, as published by the Free Software Foundation,
# and may be copied, distributed, and modified under those terms.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# ***** ***** ***** ..How to use this script… ***** ***** ***** #
#
# For those who want to build this kernel using this script…
#
# 1. Properly locate toolchain (Line# 37)
# 2. Set the 'KERNEL_VERSION' (Line# 45)
# 3. Open Terminal, ‘cd’ to the Kernel ‘root’ folder and run ‘. build_SmartPack.sh’
# 4. The output (anykernel zip) file will be generated in the ‘release_SmartPack’ folder
# 5. Enjoy your new Kernel
#
# ***** ***** *Variables to be configured manually* ***** ***** #
TOOLCHAIN="/home/sunil/UBERTC-arm-eabi-8.2.1/bin/arm-linux-gnueabi-"
ARCHITECTURE="arm"
KERNEL_NAME="SmartPack-Kernel"
KERNEL_VARIANT="osprey" # please leave as such
KERNEL_VERSION="beta-v8" # leave as such, if no specific version tag
KERNEL_DEFCONFIG="osprey_defconfig"
KERNEL_DATE="$(date +"%Y%m%d")"
BUILD_DIR="output_$KERNEL_VARIANT"
KERNEL_IMAGE="$BUILD_DIR/arch/$ARCHITECTURE/boot/zImage"
ANYKERNEL_DIR="anykernel_SmartPack"
RELEASE_DIR="release_SmartPack"
PREPARE_RELEASE=""
NUM_CPUS="" # number of cpu cores used for build (leave empty for auto detection)
# ***** ***** ***** ***** ***THE END*** ***** ***** ***** ***** #
COLOR_RED="\033[0;31m"
COLOR_GREEN="\033[1;32m"
COLOR_NEUTRAL="\033[0m"
export ARCH=$ARCHITECTURE
export CROSS_COMPILE="${CCACHE} $TOOLCHAIN"
export KBUILD_BUILD_USER=SmartPack-Kernel-[sunilpaulmathew
export KBUILD_BUILD_HOST=xda-developers.com]
if [ -z "$NUM_CPUS" ]; then
NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
fi
# Initialize building...
if [ -e $BUILD_DIR ]; then
if [ -e $BUILD_DIR/.config ]; then
rm -f $BUILD_DIR/.config
if [ -e $KERNEL_IMAGE ]; then
rm -f $KERNEL_IMAGE
fi
fi
else
mkdir $BUILD_DIR
fi
echo -e $COLOR_NEUTRAL"\n building $KERNEL_NAME $KERNEL_VERSION for $KERNEL_VARIANT\n"$COLOR_NEUTRAL
make -C $(pwd) O=$BUILD_DIR $KERNEL_DEFCONFIG
# updating kernel version
sed -i "s;-los;-$KERNEL_VERSION;" $BUILD_DIR/.config;
make -j$NUM_CPUS -C $(pwd) O=$BUILD_DIR
if [ -e $KERNEL_IMAGE ]; then
echo -e $COLOR_GREEN"\n copying zImage to anykernel directory\n"$COLOR_NEUTRAL
cp $KERNEL_IMAGE $ANYKERNEL_DIR/zImage
# adding version tag to ramdisk in order to access from the Kernel Manager
echo $KERNEL_VERSION > $ANYKERNEL_DIR/ramdisk/version
echo -e $COLOR_GREEN"\n generating recovery flashable zip file\n"$COLOR_NEUTRAL
cd $ANYKERNEL_DIR && zip -r9 $KERNEL_NAME-$KERNEL_VARIANT-$KERNEL_VERSION-$KERNEL_DATE.zip * -x README.md $KERNEL_NAME-$KERNEL_VARIANT-$KERNEL_VERSION-$KERNEL_DATE.zip && cd ..
echo -e $COLOR_GREEN"\n cleaning...\n"$COLOR_NEUTRAL
# check and create release folder.
if [ ! -d "$RELEASE_DIR" ]; then
mkdir $RELEASE_DIR
fi
rm $ANYKERNEL_DIR/zImage && mv $ANYKERNEL_DIR/$KERNEL_NAME* $RELEASE_DIR
if [ "y" == "$PREPARE_RELEASE" ]; then
echo -e $COLOR_GREEN"\n Preparing for kernel release\n"$COLOR_NEUTRAL
cp $RELEASE_DIR/$KERNEL_NAME-$KERNEL_VARIANT-$KERNEL_VERSION-$KERNEL_DATE.zip kernel-release/$KERNEL_NAME-$KERNEL_VARIANT.zip
fi
echo -e $COLOR_GREEN"\n Building for $KERNEL_VARIANT finished... please visit '$RELEASE_DIR'...\n"$COLOR_NEUTRAL
else
echo -e $COLOR_RED"\n Building for $KERNEL_VARIANT failed. Please fix the issues and try again...\n"$COLOR_RED
fi