source: stable/0.5/prepare_new_release @ 833

Last change on this file since 833 was 833, checked in by andreasw, 12 years ago

synchronized BuildTools?/stable/0.5 with trunk rev 832

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 10.8 KB
Line 
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 andreasw $
9#
10# Author: Andreas Waechter     IBM      2007-06-21
11
12#set -x -v
13
14set -e
15echo ''
16
17if test "$#" -eq 0; then
18  cat <<EOF
19Usage: prepare_new_release stable_repos
20
21stable_repos is the URL for the stable branch of your project, for which
22you want to create a new release.  You can specify the entire URL, or you
23just enter what comes after "https://projects.coin-or.org/svn".  A typical
24example is
25
26  prepare_new_release Ipopt/stable/3.3
27
28You can use this script to prepare a new release based on the specified
29stable branch.
30
31This 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
45If there is any error during these tasks the script will stop and you should
46examine the output.
47
48If the script terminates successfully, you could have a look at the output,
49particularly at the output of the unit test ('make test') and the
50chosen Externals.
51
52So far, no changes will have been made to the repository.  If you want to
53commit the new release, run the "commit_new_release" script, as described
54at the end of the output.
55
56EOF
57  exit 0
58fi
59
60stable_url=$1
61if (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
66fi
67
68case $stable_url in
69  http*) ;;
70  *)
71    stable_url=https://projects.coin-or.org/svn/$stable_url
72    ;;
73esac
74
75base_url=`echo $stable_url | sed -e 's|/stable/[0-9\.]*||'`
76echo "Base URL..........: $base_url"
77echo "Stable URL........: $stable_url"
78stable_branch=`echo $stable_url | sed -e 's|.*/stable/]*||'`
79echo "Stable branch.....: $stable_branch"
80
81# finding out which releases already exist for that stable branch
82echo ''
83echo '===> Checking for current releases for this branch...'
84tmp=`svn list $base_url/releases/`
85release_vers=
86for 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;
91done
92
93# Determine latest release number
94new_rel=-10000
95for 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
101done
102
103if test $new_rel = -10000; then
104  new_rel=0
105elif test $new_rel = 0; then
106  new_rel=1
107else
108  let new_rel++
109fi
110new_ver="$stable_branch.$new_rel"
111
112echo ''
113echo "New release.......: $new_ver"
114
115echo ''
116echo "===> Checking out stable release $stable_branch without externals..."
117echo ''
118
119case $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    ;;
132esac
133
134if 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
149fi
150
151tmpbas=tmp_checkout
152if test $is_thirdparty = yes; then
153  tmpcodir=$tmpbas/a/b
154elif test $is_data = yes; then
155  tmpcodir=$tmpbas/a
156else
157  tmpcodir=$tmpbas
158fi
159
160rm -rf $tmpbas
161cmd="svn co --ignore-externals $stable_url $tmpcodir"
162echo $cmd
163eval $cmd
164
165if 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
172fi
173
174tmpcodir=`cd $tmpcodir; pwd`
175tmpbas=`cd $tmpbas; pwd`
176
177cd $tmpcodir
178
179echo ''
180conf_ac_files=`find . -name 'configure.ac' | grep -v -E 'ThirdParty/.*/.*/configure.ac'`
181echo "===> Creating backup (.bak) for configure.ac files..."
182for i in $conf_ac_files; do
183  cp $i $i.bak
184done
185
186echo ''
187echo "===> Updating version number ($new_ver) in configure.ac files"
188for 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
192done
193
194if 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
295fi # if test -r Externals
296
297if 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
305fi
306
307echo ''
308echo '===> Running the autotools...'
309echo ''
310
311if test $is_thirdparty = yes; then
312  curdir=`pwd`
313  cd ../..
314  BuildTools/run_autotools
315  cd "$curdir"
316elif test $is_data = yes; then
317  curdir=`pwd`
318  cd ..
319  BuildTools/run_autotools
320  cd "$curdir"
321else
322  BuildTools/run_autotools
323fi
324
325if 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
366fi # if test -r Externals
367
368if 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
409fi
410
411echo ''
412echo '===> ALL TESTS PASSED'
413if test $is_thirdparty != yes && test $is_data != yes; then
414  echo ''
415  echo 'Please review the output above, particularly the one of make test'
416fi
417if test -r Externals; then
418  echo ''
419  echo 'Also, please check the Externals:'
420  cat Externals
421fi
422
423echo ''
424echo 'After reviewing the output above, you can create a new release by going into'
425echo 'the directory'
426echo ''
427echo "          $tmpcodir"
428echo ''
429echo "and run the commit_new_release script"
430
431cat >.new_release_data <<EOF
432tmpcodir=$tmpcodir
433tmpbas=$tmpbas
434base_url=$base_url
435stable_url=$stable_url
436new_ver=$new_ver
437stable_branch=$stable_branch
438EOF
Note: See TracBrowser for help on using the repository browser.