forked from corimf/build-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorimf-snapshot
executable file
·217 lines (192 loc) · 6.4 KB
/
corimf-snapshot
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/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 create a source snapshot of the specified $NEW_TAG.
# It will not fetch from $REMOTE_ORIGIN or $MASTER_ORIGIN, it is expected
# that the local repos are already up-to-date (via the other scripts here).
# You may need to have cordova-coho checked out at the WL6200 tag for this
# script to work.
if [ "$1" = "" ]
then
echo "Loading the settings from corimf-settings..."
source corimf-settings
else
echo "Loading the settings from $1"
source "$1"
fi
echo "NEW_TAG=$NEW_TAG"
echo "PREV_TAG=$PREV_TAG"
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 ]
then
echo "Failed."
exit $RC
elif [ "$DONE" = 1 ]
then
echo "Success."
else
echo "Incomplete."
exit 1
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=
# strip cordova-cli and cordova-plugman and cordova-blackberry-plugins from OTHER_REPOS when 2.x
OTHER_REPOS=`echo $OTHER_REPOS | sed -e 's/cordova-cli//' | sed -e 's/cordova-plugman//' | sed -e 's/cordova-blackberry-plugins//'`
fi
echo "Checking that each repo exists..."
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
test -d $DIR
done
echo "Checking that output directory $NEW_TAG does not already exist..."
test ! -d $NEW_TAG
mkdir $NEW_TAG
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
pushd $DIR
git archive --format zip --prefix $DIR/ -o ../$NEW_TAG/$DIR-$NEW_TAG.zip $NEW_TAG
popd
done
echo "Getting cordova-blackberry-plugins..."
SAVE_DIR=`pwd`
# using similar command as what is in "coho create-archive"
pushd cordova-blackberry-plugins
# The name for pimlib changed between 3.1.0 and 3.4.0.
if [ -d plugin/org.apache.cordova.blackberry10.pimlib ]
then
echo " Using old pimlib name."
PIMLIB="plugin/org.apache.cordova.blackberry10.pimlib"
elif [ -d plugin/com.blackberry.pim.lib ]
then
echo " Using new pimlib name."
PIMLIB="plugin/com.blackberry.pim.lib"
elif [ $MAJOR -eq 2 ]
then
# hmm, I don't think this is needed for 2.x
echo "Skipping BlackBerry plugin for Cordova 2.x"
else
# something is wrong
echo "Can't find BlackBerry plugin."
exit 1
fi
if [ $MAJOR -ge 3 ]
then
test -d plugin/com.blackberry.utils
test -d $PIMLIB
# we also need to get the pieces to compile from source. See the README.md
# for instructions on how to compile.
git archive --format zip --prefix cordova-blackberry-plugins/ -o $SAVE_DIR/$NEW_TAG/cordova-blackberry-plugins-$NEW_TAG.zip $NEW_TAG plugin/com.blackberry.utils $PIMLIB Jakefile LICENSE README.md package.json Makefile test scripts dependencies plugin/Makefile plugin/meta.mk
fi
popd
echo "Creating reference to build instructions..."
cat << EOM > $SAVE_DIR/$NEW_TAG/IBM-INSTRUCTIONS.html
<html>
<head>
<title>Reference to Instructions for Building Cordova Snapshot from Source</title>
</head>
<body>
<h1>Building Cordova Snapshot from Source</h1>
The instructions can be found <a href="https://w3-connections.ibm.com/wikis/home?lang=en-us#!/wiki/W9ae505f4bacb_461a_acbb_680b6ed21a7f/page/BlueWash%20Process">here</a>.
</body>
</html>
EOM
echo "Storing hashes and release notes..."
echo "corimf git hashes and release notes for $NEW_TAG (as compared to $PREV_TAG):" > $NEW_TAG/IBM-RELEASE-NOTES.txt
SAVE_DIR=`pwd`
for DIR in $PLATFORM_REPOS $PLUGINS $OTHER_REPOS
do
pushd $DIR
EXPECTED=`git rev-parse $NEW_TAG`
LOCAL=`git log -1 --pretty=oneline | cut -f1 -d' '`
if [ -z "`git tag --list $PREV_TAG`" ]
then
echo "WARNING: is $DIR a new repo? $PREV_TAG is not found."
PREV="(non-existent)"
NEW_REPO=1
DIFF=
else
PREV=`git rev-parse $PREV_TAG`
NEW_REPO=0
DIFF=`git diff --numstat $PREV_TAG $NEW_TAG`
fi
if [ -f IBM-MODIFICATIONS.txt ]
then
MODIFICATIONS=`git diff $PREV_TAG $NEW_TAG IBM-MODIFICATIONS.txt`
MODIFICATIONS_STRIP=`echo "$MODIFICATIONS" | tr -d '\n' | tr -d '\r'`
if [ -z "$MODIFICATIONS_STRIP" ]
then
MODIFICATIONS='(no modifications listed manually)'
fi
elif [ $NEW_REPO == 1 ]
then
MODIFICATIONS="(*** This appears to be a new repo. Assume all files are new. ***)"
else
MODIFICATIONS='(no manual definition file found)'
fi
LOCAL_BRANCH=`git status -b --porcelain | grep '^##' | cut -f2 -d' '`
cat << EOM >> $SAVE_DIR/$NEW_TAG/IBM-RELEASE-NOTES.txt
Repository: $DIR
Git Hashes:
expected=$EXPECTED
local=$LOCAL
local branch=$LOCAL_BRANCH
previous=$PREV
IBM Modifications:
$MODIFICATIONS
Diff Stats (lines added/deleted/filename):
$DIFF
============================================================================
EOM
unset EXPECTED
unset LOCAL
unset DIFF
unset MODIFICATIONS
unset LOCAL_BRANCH
popd
done
echo "Creating zip file..."
VERSION=`cat cordova-js/VERSION | tr -d '\n' | tr -d '\r'`
test ! -z "$VERSION"
zip -r cordova-$VERSION-$NEW_TAG.zip $NEW_TAG
DONE=1