forked from StockPlusKernel/stockplus_vibrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·119 lines (96 loc) · 2.79 KB
/
build.sh
File metadata and controls
executable file
·119 lines (96 loc) · 2.79 KB
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
#!/bin/bash
# Colors
RESET=$(tput sgr0)
BLUE=$(tput setaf 4)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
# Setup environment
export ARCH=arm
export CROSS_COMPILE=staging/toolchain/bin/arm-eabi-
# Setup source symlink
if [ ! -L source ]; then
ln -s . source
fi
function build_root_ramdisk
{
echo "${GREEN}Building root ramdisk...${RESET}"
rm -f staging/ramdisk.img
cd staging/ramdisk
find . | cpio -o -H newc | gzip > ../ramdisk.img
cd ../..
}
function build_recovery_ramdisk
{
echo "${GREEN}Building recovery ramdisk...${RESET}"
rm -f staging/ramdisk-recovery.img
cd staging/ramdisk-recovery
find . | cpio -o -H newc | gzip > ../ramdisk-recovery.img
cd ../..
}
function error
{
MSG=$1
echo "${RED}ERROR:${RESET} ${MSG}"
exit 1
}
for OPT in $(echo "$*" | tr "+" "\n"); do
if [ "$OPT" = "clean" ]; then
echo "${GREEN}Cleaning...${RESET}"
rm -rf \
staging/tmp
make clean
fi
done
for CMD in $(echo "$*" | tr "+" "\n"); do
if [ "$CMD" = "root" ]; then
build_root_ramdisk
elif [ "$CMD" = "recovery" ]; then
build_recovery_ramdisk
fi
done
VERSION=$(cat Makefile | grep '_Arbiter_' | cut -d "_" -f 3)
TARGET="CM10"
TARGET_ZIP=Arbiter_${VERSION}_${TARGET}.zip
echo "${GREEN}Building kernel...${RESET}"
make cyanogenmod_vibrantmtd_defconfig
make -j4
if [[ $? != 0 ]]; then
error "Build failed! Please see the errors above and correct them."
fi
echo "${GREEN}Build succeeded!${RESET}"
if [ ! -e staging/tmp ]; then
mkdir staging/tmp
fi
test -e staging/ramdisk.img || error "Root ramdisk not found!"
test -e staging/ramdisk-recovery.img || error "Recovery ramdisk not found!"
gzip -t staging/ramdisk.img &> /dev/null || error "Root ramdisk is not a valid gzip archive!"
gzip -t staging/ramdisk-recovery.img &> /dev/null || error "Recovery ramdisk not a valid gzip archive!"
echo "${GREEN}Packing up...${RESET}"
# Create boot.img
cp arch/arm/boot/zImage staging/tmp/boot.img
# Copy over package files
cp -R staging/package/* staging/tmp
SEDS="s/\${VERSION}/${VERSION}/"
SEDS="s/\${TARGET}/${TARGET}/;$SEDS"
sed -i ${SEDS} \
staging/tmp/META-INF/com/google/android/updater-script
# Find modules
MODULES=$(find -name *.ko)
for MODULE in $MODULES; do
MODULE_NAME=$(basename $MODULE)
TARGET_MODULE=staging/tmp/system/lib/modules/$MODULE_NAME
# Update modules (if they differ)
if [[ ! -e $TARGET_MODULE || $(md5sum $MODULE | cut -d " " -f 1) != \
$(md5sum $TARGET_MODULE | cut -d " " -f 1) ]]; then
echo "${GREEN}Target module:${RESET} ${MODULE_NAME}"
cp $MODULE staging/tmp/system/lib/modules/
fi
done
if [ ! -e out ]; then
mkdir out
fi
# Zip it up!
cd staging/tmp
zip -r ../../out/$TARGET_ZIP .
cd ../..
echo "${GREEN}Done! Package: out/${TARGET_ZIP}${RESET}"