-
Notifications
You must be signed in to change notification settings - Fork 0
/
glitch2.sh
117 lines (84 loc) · 2.5 KB
/
glitch2.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
# CM10 repo path :
repo=~/android/system
# Glitch kernel build-script parameters :
#
# "device" : build for a supported device (i9300).
# You can list all devices you want to build, separated by a space.
#
# clean : clean the build directory.
export CM10_REPO=$repo
# Toolchain :
export CROSS_PREFIX="$repo/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-"
setup ()
{
if [ x = "x$CM10_REPO" ] ; then
echo "Android build environment must be configured"
exit 1
fi
. "$CM10_REPO"/build/envsetup.sh
# Arch-dependent definitions
case `uname -s` in
Darwin)
KERNEL_DIR="$(dirname "$(greadlink -f "$0")")"
CROSS_PREFIX="$repo/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin/arm-eabi-"
;;
*)
KERNEL_DIR="$(dirname "$(readlink -f "$0")")"
CROSS_PREFIX="$CROSS_PREFIX"
;;
esac
BUILD_DIR="../glitch-build/kernel"
if [ x = "x$NO_CCACHE" ] && ccache -V &>/dev/null ; then
CCACHE=ccache
CCACHE_BASEDIR="$KERNEL_DIR"
CCACHE_COMPRESS=1
CCACHE_DIR="$CM10_REPO/kernel/samsung/.ccache"
export CCACHE_DIR CCACHE_COMPRESS CCACHE_BASEDIR
else
CCACHE=""
fi
}
build ()
{
local target=i9300
echo "Building for i9300"
local target_dir="$BUILD_DIR/i9300"
local module
rm -fr "$target_dir"
mkdir -p "$target_dir"
mka -C "$KERNEL_DIR" O="$target_dir" cyanogenmod_i9300_defconfig HOSTCC="$CCACHE gcc"
mka -C "$KERNEL_DIR" O="$target_dir" HOSTCC="$CCACHE gcc" CROSS_COMPILE="$CCACHE $CROSS_PREFIX" zImage modules
[[ -d release ]] || {
echo "must be in kernel root dir"
exit 1;
}
echo "copying modules and zImage"
mkdir -p $KERNEL_DIR/release/zimage/system/lib/modules/
cd $target_dir
find -name '*.ko' -exec cp -av {} $KERNEL_DIR/release/zimage/system/lib/modules/ \;
"$CROSS_PREFIX"strip --strip-unneeded $KERNEL_DIR/release/zimage/system/lib/modules/*
cd $KERNEL_DIR
mv $target_dir/arch/arm/boot/zImage $KERNEL_DIR/release/zimage/kernel/zImage
echo "packaging it up"
cd release/zimage && {
mkdir -p $KERNEL_DIR/release/Flashable-i9300-CMfriendly
REL=CM10-i9300-Glitch-$(date +%Y%m%d.%H%M).zip
zip -q -r ${REL} kernel META-INF system
sha256sum ${REL} > ${REL}.sha256sum
mv ${REL}* $KERNEL_DIR/release/Flashable-i9300-CMfriendly/
rm kernel/zImage
rm -r system
}
cd $KERNEL_DIR
echo ${REL}
}
setup
if [ "$1" = clean ] ; then
rm -fr "$BUILD_DIR"/*
echo "Old build cleaned"
else
time {
build i9300
}
fi