1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright (C) 2007 International Business Machines. |
---|
4 | # All Rights Reserved. |
---|
5 | # This file is distributed under the Common Public License. |
---|
6 | # It is part of the BuildTools project in COIN-OR (www.coin-or.org) |
---|
7 | # |
---|
8 | ## $Id: prepare_new_release 833 2007-12-27 18:05:15Z ladanyi $ |
---|
9 | # |
---|
10 | # Author: Andreas Waechter IBM 2007-06-21 |
---|
11 | |
---|
12 | #set -x -v |
---|
13 | |
---|
14 | set -e |
---|
15 | echo '' |
---|
16 | |
---|
17 | if test "$#" -eq 0; then |
---|
18 | cat <<EOF |
---|
19 | Usage: prepare_new_release stable_repos |
---|
20 | |
---|
21 | stable_repos is the URL for the stable branch of your project, for which |
---|
22 | you want to create a new release. You can specify the entire URL, or you |
---|
23 | just enter what comes after "https://projects.coin-or.org/svn". A typical |
---|
24 | example is |
---|
25 | |
---|
26 | prepare_new_release Ipopt/stable/3.3 |
---|
27 | |
---|
28 | You can use this script to prepare a new release based on the specified |
---|
29 | stable branch. |
---|
30 | |
---|
31 | This script will do the following: |
---|
32 | |
---|
33 | - automatically determine the next release number |
---|
34 | - check out a clean copy of the stable version specified |
---|
35 | - update the externals to point to the latest releases in the dependencies |
---|
36 | (for the same stable branch as specified in the Externals script) |
---|
37 | - update the version number in your configure.ac files |
---|
38 | - receive the code for the externals |
---|
39 | - use the "get.*" scripts to download ThirdParty code (if there are any) |
---|
40 | - rerun the autotools |
---|
41 | - check if all dependencies are using the same version of the BuildTools |
---|
42 | - run the configure script and compile the code |
---|
43 | - run the unit test |
---|
44 | |
---|
45 | If there is any error during these tasks the script will stop and you should |
---|
46 | examine the output. |
---|
47 | |
---|
48 | If the script terminates successfully, you could have a look at the output, |
---|
49 | particularly at the output of the unit test ('make test') and the |
---|
50 | chosen Externals. |
---|
51 | |
---|
52 | So far, no changes will have been made to the repository. If you want to |
---|
53 | commit the new release, run the "commit_new_release" script, as described |
---|
54 | at the end of the output. |
---|
55 | |
---|
56 | EOF |
---|
57 | exit 0 |
---|
58 | fi |
---|
59 | |
---|
60 | stable_url=$1 |
---|
61 | if (echo $stable_url | grep -E 'stable/' >/dev/null); then :; else |
---|
62 | echo '' |
---|
63 | echo 'This URL is not for a stable release. Exiting.' |
---|
64 | echo '' |
---|
65 | exit -2 |
---|
66 | fi |
---|
67 | |
---|
68 | case $stable_url in |
---|
69 | http*) ;; |
---|
70 | *) |
---|
71 | stable_url=https://projects.coin-or.org/svn/$stable_url |
---|
72 | ;; |
---|
73 | esac |
---|
74 | |
---|
75 | base_url=`echo $stable_url | sed -e 's|/stable/[0-9\.]*||'` |
---|
76 | echo "Base URL..........: $base_url" |
---|
77 | echo "Stable URL........: $stable_url" |
---|
78 | stable_branch=`echo $stable_url | sed -e 's|.*/stable/]*||'` |
---|
79 | echo "Stable branch.....: $stable_branch" |
---|
80 | |
---|
81 | # finding out which releases already exist for that stable branch |
---|
82 | echo '' |
---|
83 | echo '===> Checking for current releases for this branch...' |
---|
84 | tmp=`svn list $base_url/releases/` |
---|
85 | release_vers= |
---|
86 | for i in $tmp; do |
---|
87 | i=`echo $i | sed -e 's|/||g'` |
---|
88 | case $i in |
---|
89 | $stable_branch.*) release_vers="$release_vers $i";; |
---|
90 | esac; |
---|
91 | done |
---|
92 | |
---|
93 | # Determine latest release number |
---|
94 | new_rel=-10000 |
---|
95 | for i in $release_vers; do |
---|
96 | echo " $i" |
---|
97 | rel=`echo $i | sed -e "s|^$stable_branch.||"` |
---|
98 | if test $rel -gt $new_rel; then |
---|
99 | new_rel=$rel |
---|
100 | fi |
---|
101 | done |
---|
102 | |
---|
103 | if test $new_rel = -10000; then |
---|
104 | new_rel=0 |
---|
105 | elif test $new_rel = 0; then |
---|
106 | new_rel=1 |
---|
107 | else |
---|
108 | let new_rel++ |
---|
109 | fi |
---|
110 | new_ver="$stable_branch.$new_rel" |
---|
111 | |
---|
112 | echo '' |
---|
113 | echo "New release.......: $new_ver" |
---|
114 | |
---|
115 | echo '' |
---|
116 | echo "===> Checking out stable release $stable_branch without externals..." |
---|
117 | echo '' |
---|
118 | |
---|
119 | case $base_url in |
---|
120 | *ThirdParty/* ) |
---|
121 | is_thirdparty=yes |
---|
122 | is_data=no |
---|
123 | ;; |
---|
124 | *Data ) |
---|
125 | is_thirdparty=no |
---|
126 | is_data=yes |
---|
127 | ;; |
---|
128 | *) |
---|
129 | is_thirdparty=no |
---|
130 | is_data=no |
---|
131 | ;; |
---|
132 | esac |
---|
133 | |
---|
134 | if test $is_thirdparty = yes || test $is_data = yes; then |
---|
135 | buildtoolsurl=$2 |
---|
136 | if test "$buildtoolsurl" == ""; then |
---|
137 | echo '' |
---|
138 | echo 'For a ThirdParty project you need to provide a URL for BuildTools' |
---|
139 | echo 'as second argument. Exiting.' |
---|
140 | echo '' |
---|
141 | exit -3 |
---|
142 | fi |
---|
143 | case $buildtoolsurl in |
---|
144 | http*) ;; |
---|
145 | *) |
---|
146 | buildtoolsurl=https://projects.coin-or.org/svn/$buildtoolsurl |
---|
147 | ;; |
---|
148 | esac |
---|
149 | fi |
---|
150 | |
---|
151 | tmpbas=tmp_checkout |
---|
152 | if test $is_thirdparty = yes; then |
---|
153 | tmpcodir=$tmpbas/a/b |
---|
154 | elif test $is_data = yes; then |
---|
155 | tmpcodir=$tmpbas/a |
---|
156 | else |
---|
157 | tmpcodir=$tmpbas |
---|
158 | fi |
---|
159 | |
---|
160 | rm -rf $tmpbas |
---|
161 | cmd="svn co --ignore-externals $stable_url $tmpcodir" |
---|
162 | echo $cmd |
---|
163 | eval $cmd |
---|
164 | |
---|
165 | if test $is_thirdparty = yes || test $is_data = yes; then |
---|
166 | echo '' |
---|
167 | echo '===> Checking out BuildTools for ThirdParty project...' |
---|
168 | echo '' |
---|
169 | cmd="svn co $buildtoolsurl $tmpbas/BuildTools" |
---|
170 | echo $cmd |
---|
171 | eval $cmd |
---|
172 | fi |
---|
173 | |
---|
174 | tmpcodir=`cd $tmpcodir; pwd` |
---|
175 | tmpbas=`cd $tmpbas; pwd` |
---|
176 | |
---|
177 | cd $tmpcodir |
---|
178 | |
---|
179 | echo '' |
---|
180 | conf_ac_files=`find . -name 'configure.ac' | grep -v -E 'ThirdParty/.*/.*/configure.ac'` |
---|
181 | echo "===> Creating backup (.bak) for configure.ac files..." |
---|
182 | for i in $conf_ac_files; do |
---|
183 | cp $i $i.bak |
---|
184 | done |
---|
185 | |
---|
186 | echo '' |
---|
187 | echo "===> Updating version number ($new_ver) in configure.ac files" |
---|
188 | for i in $conf_ac_files; do |
---|
189 | sed -e "s|AC_INIT\(.*\)\[[0-9A-Za-z\.]*\],\(.*\)|AC_INIT\1[$new_ver],\2|" $i > bla |
---|
190 | mv bla $i |
---|
191 | svn di $i |
---|
192 | done |
---|
193 | |
---|
194 | if test -r Externals; then |
---|
195 | |
---|
196 | echo '' |
---|
197 | echo '===> Creating new Externals file with pointers to releases...' |
---|
198 | echo '' |
---|
199 | |
---|
200 | rm -f Externals.releases |
---|
201 | ext_name= |
---|
202 | ext_url= |
---|
203 | for i in `cat Externals`; do |
---|
204 | if test "$ext_name" = ""; then |
---|
205 | ext_name="$i" |
---|
206 | else |
---|
207 | ext_url=$i |
---|
208 | if (echo $ext_url | grep -E 'stable/' >/dev/null); then :; else |
---|
209 | echo '' |
---|
210 | echo "The external URL $ext_url is not for a stable branch. Exiting." |
---|
211 | echo '' |
---|
212 | exit -2 |
---|
213 | fi |
---|
214 | |
---|
215 | ext_base_front=`echo $ext_url | sed -e 's|/stable/.*||'` |
---|
216 | ext_base_end=`echo $ext_url | sed -e 's|.*/stable/[0-9\.]*||'` |
---|
217 | ext_stable_branch=`echo $ext_url | sed -e 's|.*/stable/]*||' -e s"|$ext_base_end||"` |
---|
218 | |
---|
219 | echo "Determining release replacement for $ext_name:" |
---|
220 | tmp=`svn list $ext_base_front/releases/` |
---|
221 | ext_release_vers= |
---|
222 | for i in $tmp; do |
---|
223 | i=`echo $i | sed -e 's|/||g'` |
---|
224 | case $i in |
---|
225 | $ext_stable_branch.*) ext_release_vers="$ext_release_vers $i";; |
---|
226 | esac; |
---|
227 | done |
---|
228 | # Determine latest release number |
---|
229 | ext_latest=-10000 |
---|
230 | for i in $ext_release_vers; do |
---|
231 | rel=`echo $i | sed -e "s|^$ext_stable_branch.||"` |
---|
232 | if test $rel -gt $ext_latest; then |
---|
233 | ext_latest=$rel |
---|
234 | fi |
---|
235 | done |
---|
236 | if test $ext_latest = -10000; then |
---|
237 | echo '' |
---|
238 | echo "Error: No release for $ext_name for its stable defined in External" |
---|
239 | echo '' |
---|
240 | exit -5 |
---|
241 | fi |
---|
242 | |
---|
243 | if test "$ext_base_end" = ""; then |
---|
244 | ext_rel_url=$ext_base_front/releases/$ext_stable_branch.$ext_latest |
---|
245 | else |
---|
246 | ext_rel_url=$ext_base_front/releases/$ext_stable_branch.$ext_latest$ext_base_end |
---|
247 | fi |
---|
248 | |
---|
249 | echo " $ext_rel_url" |
---|
250 | echo "$ext_name $ext_rel_url" >> Externals.releases |
---|
251 | ext_name= |
---|
252 | fi |
---|
253 | done |
---|
254 | |
---|
255 | echo '===> Creating backup (.bak) for Externals' |
---|
256 | mv Externals Externals.bak |
---|
257 | mv Externals.releases Externals |
---|
258 | |
---|
259 | echo '' |
---|
260 | echo '===> Updating svn:externals properties, and checking out externals...' |
---|
261 | echo '' |
---|
262 | |
---|
263 | svn pset svn:externals -F Externals . |
---|
264 | |
---|
265 | svn update |
---|
266 | |
---|
267 | echo '' |
---|
268 | echo '===> If there are ThirdParty externals, run the download scripts...' |
---|
269 | echo '' |
---|
270 | |
---|
271 | ext_name= |
---|
272 | ext_url= |
---|
273 | for i in `cat Externals`; do |
---|
274 | if test "$ext_name" = ""; then |
---|
275 | ext_name="$i" |
---|
276 | else |
---|
277 | ext_url=$i |
---|
278 | |
---|
279 | case $ext_name in |
---|
280 | ThirdParty/*) |
---|
281 | pkg=`echo $ext_name | sed -e 's|ThirdParty/||' -e 's|/||g'` |
---|
282 | getfile=get.$pkg |
---|
283 | if test -r $ext_name/$getfile; then |
---|
284 | curdir=`pwd` |
---|
285 | cd $ext_name |
---|
286 | echo "Running $getfile -patch in `pwd`" |
---|
287 | eval ./$getfile -patch |
---|
288 | cd "$curdir" |
---|
289 | fi |
---|
290 | ;; |
---|
291 | esac |
---|
292 | ext_name= |
---|
293 | fi |
---|
294 | done |
---|
295 | fi # if test -r Externals |
---|
296 | |
---|
297 | if test $is_thirdparty = yes; then |
---|
298 | pkg=`echo $base_url | sed -e 's|.*/||g'` |
---|
299 | if test -r get.$pkg; then |
---|
300 | echo '' |
---|
301 | echo '===> Download third party code...' |
---|
302 | echo '' |
---|
303 | ./get.$pkg |
---|
304 | fi |
---|
305 | fi |
---|
306 | |
---|
307 | echo '' |
---|
308 | echo '===> Running the autotools...' |
---|
309 | echo '' |
---|
310 | |
---|
311 | if test $is_thirdparty = yes; then |
---|
312 | curdir=`pwd` |
---|
313 | cd ../.. |
---|
314 | BuildTools/run_autotools |
---|
315 | cd "$curdir" |
---|
316 | elif test $is_data = yes; then |
---|
317 | curdir=`pwd` |
---|
318 | cd .. |
---|
319 | BuildTools/run_autotools |
---|
320 | cd "$curdir" |
---|
321 | else |
---|
322 | BuildTools/run_autotools |
---|
323 | fi |
---|
324 | |
---|
325 | if test -r Externals; then |
---|
326 | |
---|
327 | echo '===> Verifying consistency of the BuildTools versions...' |
---|
328 | echo '' |
---|
329 | |
---|
330 | ext_name= |
---|
331 | ext_url= |
---|
332 | rm -f problems.ext |
---|
333 | for i in `cat Externals`; do |
---|
334 | if test "$ext_name" = ""; then |
---|
335 | ext_name="$i" |
---|
336 | else |
---|
337 | ext_url=$i |
---|
338 | |
---|
339 | echo " checking $ext_name" |
---|
340 | |
---|
341 | num_M=`svn status $ext_name | grep -E '^M' | wc -l` |
---|
342 | |
---|
343 | if test $num_M -ne 0; then |
---|
344 | echo $ext_name >>problems.ext |
---|
345 | echo ' ... BuildTools not consistent!' |
---|
346 | else |
---|
347 | echo ' ... Ok' |
---|
348 | fi |
---|
349 | ext_name= |
---|
350 | fi |
---|
351 | done |
---|
352 | |
---|
353 | if test -r problems.ext; then |
---|
354 | echo '' |
---|
355 | echo 'PROBLEM DURING CONSITENCY CHECK:' |
---|
356 | echo '' |
---|
357 | echo 'Please contact the project manager(s) for the following project(s).' |
---|
358 | echo 'A new release needs to be made with your stable branch of BuildTools.' |
---|
359 | echo '' |
---|
360 | cat problems.ext |
---|
361 | echo '' |
---|
362 | rm -f problems.ext |
---|
363 | exit -2 |
---|
364 | fi |
---|
365 | rm -f problems.ext |
---|
366 | fi # if test -r Externals |
---|
367 | |
---|
368 | if test $is_thirdparty != yes && test $is_data != yes; then |
---|
369 | (set -e |
---|
370 | echo '' |
---|
371 | echo '===> Creating build directory and running the configuration script...' |
---|
372 | echo '' |
---|
373 | mkdir build |
---|
374 | cd build |
---|
375 | cmd="$tmpcodir/configure -C --enable-maintainer-mode" |
---|
376 | echo $cmd |
---|
377 | eval $cmd |
---|
378 | echo '' |
---|
379 | echo '===> Compiling code...' |
---|
380 | echo '' |
---|
381 | cmd='make install' |
---|
382 | echo $cmd |
---|
383 | eval $cmd |
---|
384 | echo '' |
---|
385 | echo '===> Running the unit test...' |
---|
386 | echo '' |
---|
387 | echo '*******************************************************************************' |
---|
388 | echo '*** ***' |
---|
389 | echo '*** BEGIN OUTPUT OF MAKE TEST ***' |
---|
390 | echo '*** ***' |
---|
391 | echo '*******************************************************************************' |
---|
392 | echo '' |
---|
393 | cmd='make test' |
---|
394 | echo $cmd |
---|
395 | eval $cmd |
---|
396 | echo '' |
---|
397 | echo '*******************************************************************************' |
---|
398 | echo '*** ***' |
---|
399 | echo '*** END OUTPUT OF MAKE TEST ***' |
---|
400 | echo '*** ***' |
---|
401 | echo '*******************************************************************************' |
---|
402 | ) |
---|
403 | if test $? != 0; then |
---|
404 | echo '' |
---|
405 | echo 'Error during build or test' |
---|
406 | echo '' |
---|
407 | exit -3 |
---|
408 | fi |
---|
409 | fi |
---|
410 | |
---|
411 | echo '' |
---|
412 | echo '===> ALL TESTS PASSED' |
---|
413 | if test $is_thirdparty != yes && test $is_data != yes; then |
---|
414 | echo '' |
---|
415 | echo 'Please review the output above, particularly the one of make test' |
---|
416 | fi |
---|
417 | if test -r Externals; then |
---|
418 | echo '' |
---|
419 | echo 'Also, please check the Externals:' |
---|
420 | cat Externals |
---|
421 | fi |
---|
422 | |
---|
423 | echo '' |
---|
424 | echo 'After reviewing the output above, you can create a new release by going into' |
---|
425 | echo 'the directory' |
---|
426 | echo '' |
---|
427 | echo " $tmpcodir" |
---|
428 | echo '' |
---|
429 | echo "and run the commit_new_release script" |
---|
430 | |
---|
431 | cat >.new_release_data <<EOF |
---|
432 | tmpcodir=$tmpcodir |
---|
433 | tmpbas=$tmpbas |
---|
434 | base_url=$base_url |
---|
435 | stable_url=$stable_url |
---|
436 | new_ver=$new_ver |
---|
437 | stable_branch=$stable_branch |
---|
438 | EOF |
---|