Debian Codegraph @

BuildTools/commit_new_release

raw
1 #!/bin/sh
2
3 # Copyright (C) 2010 International Business Machines and others.
4 # All Rights Reserved.
5 # This file is distributed under the Eclipse Public License.
6 # It is part of the BuildTools project in COIN-OR (www.coin-or.org)
7 #
8 # $Id: commit_new_release 3599 2016-07-20 15:32:26Z stefan $
9 #
10 # Author: Andreas Waechter IBM 2007-06-21
11 # Modified by: Lou Hafer SFU 2008-04-17
12 # Lou Hafer SFU 2010-06-29 major rewrite
13
14 #set -x -v
15
16 set -e
17
18 # Know thy self. If there are no '/' chars in the command name, we're running
19 # in the current directory. Otherwise, strip the command name, leaving the
20 # prefix. Coin-functions is expected to live in the same directory. As of
21 # the original version (100602), this script doesn't need coin-functions,
22 # but this still has some value as a consistency check.
23
24 if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
25 cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
26 else
27 cmdDir='.'
28 fi
29 cmdDir=`cd $cmdDir ; pwd`
30 if test -r $cmdDir/coin-functions ; then
31 . $cmdDir/coin-functions
32 else
33 echo "Cannot find utility functions file coin-functions; exiting."
34 fi
35
36 # We need at least one parameter. The default is a dry run (dryRun = 1).
37
38 printHelp=0
39 dryRun=1
40 dirToCommit=
41
42 if test "$#" -eq 0; then
43 printHelp=1
44 else
45
46 # Process the parameters. A parameter without an opening `-' is assumed to be
47 # the spec for the directory to be committed. (Strip any trailing '/'. Some
48 # people add it, but the script doesn't expect it.)
49
50 while test $# -gt 0 && test $printHelp = 0 ; do
51 case "$1" in
52 -h* | --h*)
53 printHelp=1
54 ;;
55 -c* | --c*)
56 dryRun=0
57 ;;
58 -*) echo "$0: unrecognised command line switch '"$1"'."
59 printHelp=1
60 ;;
61 *) dirToCommit=`echo $1 | sed -e 's,/$,,'`
62 ;;
63 esac
64 shift
65 done
66 fi
67
68 # What are we committing?
69
70 if test -z "$dirToCommit" ; then
71 printHelp=1
72 fi
73
74 if test $printHelp = 1 ; then
75 cat <<EOF
76 usage: commit_new_release [-c] <directory_to_commit>
77
78 By default, commit_new_release is a dry run, printing the commands that
79 will be executed. When you're confident that everything looks right, use
80 the -c (--commit) flag to commit the release.
81 EOF
82 exit 1
83 fi
84
85 # Remember what was done during generation of the new release.
86
87 if test -r $dirToCommit/.new_release_data; then
88 . $dirToCommit/.new_release_data
89 else
90 echo ''
91 echo "Error: the file .new_release_data is not present in $dirToCommit."
92 echo 'Are you running commit_new_release in the same directory where you'
93 echo 'ran prepare_new_release?'
94 echo ''
95 exit 1
96 fi
97
98 # Confirm that we're in the proper directory.
99
100 currDir=`pwd`
101 if test "$currDir/$dirToCommit" != "$topBuildDir" ; then
102 echo "According to $dirToCommit/.new_release_data, the release candidate was assembled"
103 echo "in $topBuildDir."
104 echo "You have asked to commit $currDir/$dirToCommit."
105 echo "There is some confusion. Repository is unchanged."
106 exit 1
107 fi
108
109 if test $dryRun = 1 ; then
110 echo "Dry run; testing commit of $dirToCommit."
111 else
112 echo "Committing $dirToCommit."
113 fi
114
115 # Change to the checkout directory.
116
117 cd $coDir
118
119 # If there are externals set on this directory, confirm that
120 # .Externals.original is present so that we can restore them later.
121
122 releaseExternals=`svn propget svn:externals . || true`
123 if test -n "$releaseExternals" ; then
124 if test -r .Externals.original ; then
125 :
126 else
127 echo "This project has externals, but no .Externals.original file"
128 echo "is present to restore them. Repository is unchanged."
129 exit 1
130 fi
131 fi
132
133 # Make some short-form URLs by stripping the COIN URL base.
134
135 stableURLshort=`echo $stableURL | sed -e "s,$coinURL/\(.*\),\1,"`
136 releaseURLshort=`echo $releaseURL | sed -e "s,$coinURL/\(.*\),\1,"`
137
138 # Do we have to svn add Dependencies? If this query comes up with a leading
139 # `?', the answer is yes. If Dependencies is entirely absent or unchanged,
140 # we'll get a null string. If it's modified, we'll have a leading `M'.
141
142 dependStatus=`svn status Dependencies`
143 if expr "$dependStatus" : '?.*Dependencies.*' >/dev/null 2>&1 ; then
144 cmd='svn add Dependencies'
145 echo $cmd
146 if test $dryRun = 0 ; then
147 eval $cmd
148 fi
149 fi
150
151 # Now, do we really need to to a temporary commit? BuildTools is the poster
152 # child, there are no changes at time of writing (100629). Do an svn status
153 # on the checkout directory and see if anything comes up as modified.
154
155 if svn status $coDir | egrep '^M' 2>&1 >/dev/null ; then
156 doCommit=yes
157 else
158 doCommit=no
159 fi
160
161 if test $doCommit = yes ; then
162
163 # Commit the release to stable so we can do a repository-side copy to create
164 # the release.
165
166 echo ''
167 echo "===> Temporarily committing release candidate to $stableURLshort ..."
168 echo ''
169
170 rev_num_before=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
171 echo "Revision number before commit: $rev_num_before"
172
173 cmd="svn ci -m \"temporarily committing release candidate\""
174 echo $cmd
175 if test $dryRun = 0 ; then
176 eval $cmd
177 fi
178
179 # Update to confirm the commit. Avoid pulling in externals --- if we're doing
180 # multiple commits of new releases, they may not exist. As it stands, the
181 # main purpose of this call is to allow us to easily obtain the current
182 # revision.
183 # It might be useful to strengthen this and check that the value
184 # is what we're expecting --- one greater than the revision before
185 # commit. `--ignore-externals' could be made provisional on the existence
186 # of all externals by passing a boolean through .new_release_data. This
187 # would strengthen the update, in that the update would confirm existence
188 # of the externals.
189
190 cmd='svn update --ignore-externals'
191 echo $cmd
192 if test $dryRun = 0 ; then
193 eval $cmd
194 fi
195
196 rev_num=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
197 echo "Current revision number is: $rev_num"
198
199 fi
200
201 # End preparatory commit.
202
203 # Create the release with a repository-side copy.
204
205 echo ''
206 echo "===> Creating new release $releaseURLshort from $stableURLshort (rev $rev_num) ..."
207 echo ''
208
209 cmd="svn copy -m \"creating $releaseURLshort from $stableURLshort (rev $rev_num)\" $stableURL $releaseURL"
210 echo $cmd
211 if test $dryRun = 0 ; then
212 eval $cmd
213 fi
214
215 # Restore the original stable branch.
216
217 if test $doCommit = yes ; then
218
219 # And restore the stable branch to its original condition. Start by reverting
220 # to the original externals.
221
222 if test -r .Externals.original ; then
223 echo ''
224 echo '===> Restoring original externals ...'
225 echo ''
226 cmd="svn propset -F .Externals.original svn:externals ."
227 echo $cmd
228 if test $dryRun = 0 ; then
229 eval $cmd
230 rm .Externals.original
231 fi
232 fi
233
234 # For every .bak file that we created, revert it.
235
236 if test -n "$bak_files" ; then
237 echo ''
238 echo '===> Restoring modified files ...'
239 echo ''
240 for i in $bak_files; do
241 cmd="cp $i.bak $i ; rm $i.bak"
242 if test $dryRun = 1 ; then
243 echo "$cmd"
244 else
245 eval $cmd
246 fi
247 done
248 fi
249
250 # Rebuild configure and Makefile.in files.
251
252 echo ''
253 echo '===> Executing run_autotools to restore configuration files ...'
254 echo ''
255 curdir=`pwd`
256 cd $topBuildDir
257 cmd="./BuildTools/run_autotools"
258 echo $cmd
259 if test $dryRun = 0 ; then
260 eval $cmd
261 fi
262 cd "$curdir"
263
264 # Commit the restored stable branch.
265
266 echo ''
267 echo "===> Committing restored $stableURLshort ..."
268 echo ''
269
270 cmd="svn ci -m \"restoring $stableURLshort\""
271 echo $cmd
272 if test $dryRun = 0 ; then
273 eval $cmd
274 fi
275
276 fi
277
278 # End restorative commit.
279
280 cd $topBuildDir
281 cmd="rm .new_release_data"
282 if test $dryRun = 0 ; then
283 eval $cmd
284 fi
285
286 cd $startDir
287 echo ''
288 echo "Done, new release $releaseURLshort created."
289 echo ''
290 echo "You can now delete the directory $topBuildDir including subdirectories"
291