forked from corimf/build-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorimf-cron
executable file
·155 lines (138 loc) · 4.29 KB
/
corimf-cron
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/sh -e
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
###############################################################################
# Use the -e option so the script will fail on the first non-zero return code.
# This is a script to check the hash of local $BASE_BRANCH against the hash
# of $RW_ORIGIN $BASE_BRANCH (not $REMOTE_ORIGIN). The purpose of this
# is to make sure that the cron job that pulls from $RW_ORIGIN to
# $REMOTE_ORIGIN is running, so when we pull from $REMOTE_ORIGIN it is
# current. Because we need need a remote to $RW_ORIGIN to do that check
# and we shouldn't be doing that when corimf is present, the $RW_ORIGIN
# remote will be defined only for the duration of this script.
if [ "$1" = "" ]
then
echo "Loading the settings from corimf-settings..."
source corimf-settings
else
echo "Loading the settings from $1"
source "$1"
fi
echo "RW_ORIGIN=$RW_ORIGIN"
echo "BASE_BRANCH=$BASE_BRANCH"
echo "BRANCH=$BRANCH"
/bin/echo -n "Hit ENTER to continue: "
read ANSWER
# Shouldn't need to change anything below here.
check_rc() {
SAVE_RC=$?
if [ $SAVE_RC != 0 -o "$DONE" != 1 ]
then
echo "Failed."
echo "Cleaning up..."
popd || true
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
pushd $DIR > /dev/null 2>&1
git remote | grep $RW_ORIGIN && git remote remove $RW_ORIGIN
popd > /dev/null 2>&1
done
exit $RC
else
echo "Success."
fi
}
trap check_rc EXIT
echo "Checking that we are one dir above the git repo..."
test -d $PLATFORM_REPO
echo "Checking major version number..."
MAJOR=`echo $BRANCH | cut -f1 -d.`
test "$MAJOR" -ge 2 -a "$MAJOR" -le 3
if [ "$MAJOR" -ge 3 ]
then
echo "Checking that the plugin count is $PLUGIN_COUNT..."
COUNT=0
for PLUGIN in $PLUGINS
do
COUNT=`expr $COUNT + 1`
done
test "$COUNT" == "$PLUGIN_COUNT"
else
echo "Skipping all plugins since version is $MAJOR"
PLUGINS=
PLUGMAN_REPO=
fi
echo "Checking that each repo exists..."
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
test -d $DIR
done
echo "Checking that $REMOTE_ORIGIN is a defined remote..."
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
pushd $DIR
git remote | grep $REMOTE_ORIGIN
popd
done
echo "Checking that $RW_ORIGIN is NOT a defined remote..."
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
pushd $DIR
test -z "`git remote | grep $RW_ORIGIN`"
popd
done
REPORT=
echo "Doing the check for platforms..."
for DIR in $PLATFORM_REPOS
do
pushd $DIR
git remote add $RW_ORIGIN https://git-wip-us.apache.org/repos/asf/$DIR.git
EXPECTED=`git ls-remote --heads $RW_ORIGIN $BASE_BRANCH | cut -f1`
ACTUAL=`git rev-parse $BASE_BRANCH`
if [ "$ACTUAL" != "$EXPECTED" ]
then
REPORT="$REPORT\n$DIR: EXPECTED $EXPECTED ACTUAL $ACTUAL"
fi
git remote remove $RW_ORIGIN
popd
done
echo "Doing the check for plugins and other..."
for DIR in $PLUGINS $OTHER_REPOS
do
pushd $DIR
if [ "$DIR" == "cordova-blackberry-plugins" ]
then
URL=https://github.com/blackberry/$DIR.git
else
URL=https://git-wip-us.apache.org/repos/asf/$DIR.git
fi
git remote add $RW_ORIGIN $URL
EXPECTED=`git ls-remote --heads $RW_ORIGIN master | cut -f1`
ACTUAL=`git rev-parse master`
if [ "$ACTUAL" != "$EXPECTED" ]
then
REPORT="$REPORT\n$DIR: EXPECTED $EXPECTED ACTUAL $ACTUAL"
fi
git remote remove $RW_ORIGIN
popd
done
echo "REPORT: ==================================================="
echo "$REPORT"
test -z "$REPORT"
DONE=1