-
Notifications
You must be signed in to change notification settings - Fork 0
/
romsync
executable file
·120 lines (114 loc) · 3.78 KB
/
romsync
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
120
#
# Copyright (C) 2012 Erez A. Korn
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
NOTHING_TO_MERGE="Already up-to-date"
mkdir -p $ROM_SCRIPTS_DIR/.sync
SYNC_STANDARD=yes
if [ -e $ROM_SCRIPTS_DIR/.sync/sync_stage ]; then
SYNC_LOCAL_STAGE=`cat $ROM_SCRIPTS_DIR/.sync/sync_stage`
rm $ROM_SCRIPTS_DIR/.sync/sync_stage
else
SYNC_LOCAL_STAGE=1
fi
for i in $@
do
case $i in
--local)
SYNC_STANDARD=no
;;
--restart)
SYNC_LOCAL_STAGE=1
;;
*)
echo "Unknown option: $i"
exit 1
;;
esac
done
if [ "$SYNC_STANDARD" = "yes" ]; then
SYNC_LOCAL_STAGE=1
fi
function fetch_proj {
if [ $SYNC_LOCAL_STAGE -eq $CURRENT_SYNC_STAGE ]; then
echo -n "$SYNC_LOCAL_STAGE. "
cd $ROM_TOP_DIR/$1
echo "Fetching remotes for $1"
git fetch --all
echo "Trying auto merge"
LAST_OUTPUT=`git merge --stat --log --no-commit CyanogenMod/jellybean`
LAST_ERROR=$?
echo $LAST_OUTPUT
if [ "$LAST_ERROR" -ne "0" ]; then
echo "Check results for $1"
exit 1
elif [[ "$LAST_OUTPUT" == *"$NOTHING_TO_MERGE"* ]]; then
echo "Done for $1"
echo "******************************"
echo "******************************"
SYNC_LOCAL_STAGE=`expr $SYNC_LOCAL_STAGE + 1`
echo $SYNC_LOCAL_STAGE > $ROM_SCRIPTS_DIR/.sync/sync_stage
else
echo "Merge performed for $1"
echo "Please manually commit afer reviewing"
echo "Then restart sync"
echo "******************************"
echo "******************************"
echo "******************************"
echo "******************************"
SYNC_LOCAL_STAGE=`expr $SYNC_LOCAL_STAGE + 1`
echo $SYNC_LOCAL_STAGE > $ROM_SCRIPTS_DIR/.sync/sync_stage
exit 2
fi
fi
CURRENT_SYNC_STAGE=`expr $CURRENT_SYNC_STAGE + 1`
}
if [ "$SYNC_STANDARD" = "yes" ]; then
cd $ROM_TOP_DIR
realrepo sync -j6
if [ "$?" = "0" ]; then
export my_sync_date=`date -u`
sed 's/^merges as of.*/merges as of '"$my_sync_date"'/' $ROM_TOP_DIR/vendor/erez/CHANGELOG.mkdn > $ROM_TOP_DIR/vendor/erez/CHANGELOG.mkdn.tmp
mv $ROM_TOP_DIR/vendor/erez/CHANGELOG.mkdn.tmp $ROM_TOP_DIR/vendor/erez/CHANGELOG.mkdn
else
echo "*******************************"
echo "** Repo did not succeed, **"
echo "** please try again manually **"
echo "*******************************"
exit 1
fi
fi
CURRENT_SYNC_STAGE=1
fetch_proj build
fetch_proj device/samsung/d2att
fetch_proj device/samsung/d2-common
fetch_proj device/samsung/galaxys2-common
fetch_proj device/samsung/galaxysmtd
fetch_proj device/samsung/i9100
fetch_proj device/samsung/i9300
fetch_proj device/samsung/maguro
fetch_proj device/samsung/p1
fetch_proj device/samsung/p1-common
fetch_proj device/samsung/skyrocket
fetch_proj device/samsung/tuna
fetch_proj frameworks/base
fetch_proj packages/apps/Contacts
fetch_proj packages/apps/DeskClock
fetch_proj packages/apps/Mms
fetch_proj packages/apps/Settings
fetch_proj packages/apps/Trebuchet
fetch_proj system/core
echo "******* Last one ******"
fetch_proj vendor/cm
rm $ROM_SCRIPTS_DIR/.sync/sync_stage