-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_sto3.sh
executable file
·105 lines (86 loc) · 2.27 KB
/
build_sto3.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
#!/bin/bash
source ./.config
if [ -f ./.userconfig ]
then
source ./.userconfig
fi
export GP=${GECKO_PATH:-./gecko}
export CUR_DIR=`pwd`
# We have to apply 3 patches. Quick and dirty...
export BUILD_PATCH='build.patch|./build'
export SYSTEM_CORE_PATCH='system_core.patch|./system/core'
export GECKO_PATCH="./recover_store_gecko.patch|$GP"
if [ $DEVICE_NAME = flame -o $DEVICE_NAME = flame-kk ]
then
# We want adb root!
PATCHES="$BUILD_PATCH $SYSTEM_CORE_PATCH $GECKO_PATCH"
else
# Only the store
PATCHES="$GECKO_PATCH"
fi
function abort() {
echo Error: $1
echo 'Aborting!'
exit 1
}
function checkIfApply() {
for i in $1
do
PATCH=$CUR_DIR/`echo $i|cut -d'|' -f1`
DIR=`echo $i|cut -d'|' -f2`
pushd $DIR || abort "Directory $DIR does not exist"
if [ -d .git ]
then
git apply --check $PATCH || abort "Patch $PATCH does not apply on $DIR"
else
echo "****.git does not exist on $DIR! ***"
echo "**** Going to assume it's Mercurial and skip it ****"
echo "Please press enter to continue or CTR+C to abort"
read
fi
popd
done
}
function revert() {
echo "Reverting changes for $PATCHES"
for i in $1
do
DIR=`echo $i|cut -d'|' -f2`
pushd $DIR || abort "Er WTH, this should not happen! $DIR does not exist!"
if [ -d .git ]
then
git reset --hard HEAD^
else
echo "***** .git does not exist on $DIR! ****"
echo "***** Skipping it happily! ****"
fi
popd
done
}
function apply() {
for i in $1
do
PATCH=$CUR_DIR/`echo $i|cut -d'|' -f1`
DIR=`echo $i|cut -d'|' -f2`
pushd $DIR || abort "Er WTH, this should not happen! $DIR does not exist!"
if [ -d .git ]
then
git apply --index $PATCH || abort "Error applying $PATCH on $DIR. This should NOT happen"
git commit -a -m "Don't push"|| abort "Error commiting on $DIR. This should NOT happen"
else
echo "***** .git does not exist on $DIR! ****"
echo "***** Skipping it happily! ****"
fi
popd
done
}
export GECKO_DIR=$GP
export PATH=$PATH:.
checkIfApply "$PATCHES"
# Ok, at this point everything should be good with life so let's apply the patches...
apply "$PATCHES"
trap "revert \"$PATCHES\"" INT QUIT
./build.sh $*
ERR_CODE=$?
revert "$PATCHES"
exit $ERR_CODE