source: trunk/prepare_new_release @ 401

Last change on this file since 401 was 401, checked in by andreasw, 13 years ago

added scripts for making new releases

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 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 401 2007-06-22 05:47:13Z 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=1
105else
106  let new_rel++
107fi
108new_ver="$stable_branch.$new_rel"
109
110echo ''
111echo "New release.......: $new_ver"
112
113echo ''
114echo "===> Checking out stable release $stable_branch without externals..."
115echo ''
116
117case $base_url in
118  *ThirdParty*)
119    is_thirdparty=yes
120    ;;
121  *)
122    is_thirdparty=no
123    ;;
124esac
125
126tmpbas=tmp_checkout
127if test $is_thirdparty = yes; then
128  tmpcodir=$tmpbas/a/b
129else
130  tmpcodir=$tmpbas
131fi
132
133rm -rf $tmpbas
134cmd="svn co --ignore-externals $stable_url $tmpcodir"
135echo $cmd
136eval $cmd
137
138if test $is_thirdparty = yes; then
139  buildtoolsurl=$2
140  if test "$buildtoolsurl" == ""; then
141    echo ''
142    echo 'For a ThirdParty project you need to provide a URL for BuildTools'
143    echo 'as second argument.  Exiting.'
144    echo ''
145    exit -3
146  fi
147  case $buildtoolsurl in
148    http*) ;;
149    *)
150      buildtoolsurl=https://projects.coin-or.org/svn/$buildtoolsurl
151      ;;
152  esac
153  echo ''
154  echo '===> Checking out BuildTools for ThirdParty project...'
155  echo ''
156  cmd="svn co $buildtoolsurl $tmpbas/BuildTools"
157  echo $cmd
158  eval $cmd
159fi
160
161tmpcodir=`cd $tmpcodir; pwd`
162tmpbas=`cd $tmpbas; pwd`
163
164cd $tmpcodir
165
166echo ''
167conf_ac_files=`find . -name 'configure.ac'`
168echo "===> Creating backup (.bak) for configure.ac files..."
169for i in $conf_ac_files; do
170  cp $i $i.bak
171done
172
173echo ''
174echo "===> Updating version number ($new_ver) in configure.ac files"
175for i in $conf_ac_files; do
176  sed -e "s|AC_INIT\(.*\)\[[0-9\.]*\]\(.*\)|AC_INIT\1[$new_ver]\2|" $i > bla
177  mv bla $i
178  svn di $i
179done
180
181if test -r Externals; then
182
183  echo ''
184  echo '===> Creating new Externals file with pointers to releases...'
185  echo ''
186
187  rm -f Externals.releases
188  ext_name=
189  ext_url=
190  for i in `cat Externals`; do
191    if test "$ext_name" = ""; then
192      ext_name="$i"
193    else
194      ext_url=$i
195      if (echo $ext_url | grep -E 'stable/' >/dev/null); then :; else
196        echo ''
197        echo "The external URL $ex_url is not for a stable release. Exiting."
198        echo ''
199        exit -2
200      fi
201   
202      ext_base_front=`echo $ext_url | sed -e 's|/stable/.*||'`
203      ext_base_end=`echo $ext_url | sed -e 's|.*/stable/[0-9\.]*||'`
204      ext_stable_branch=`echo $ext_url | sed -e 's|.*/stable/]*||' -e s"|$ext_base_end||"`
205
206      echo "Determining release replacement for $ext_name:"
207      tmp=`svn list $ext_base_front/releases/`
208      ext_release_vers=
209      for i in $tmp; do
210        i=`echo $i | sed -e 's|/||g'`
211        case $i in
212          $ext_stable_branch.*) ext_release_vers="$ext_release_vers $i";;
213        esac;
214      done
215      # Determine latest release number
216      ext_latest=-10000
217      for i in $ext_release_vers; do
218        rel=`echo $i | sed -e "s|^$ext_stable_branch.||"`
219        if test $rel -gt $ext_latest; then
220          ext_latest=$rel
221        fi
222      done
223      if test $ext_latest = -10000; then
224        echo ''
225        echo 'Error: No release for $ext_name for its stable defined in External'
226        echo ''
227        exit -5
228      fi
229
230      if test "$ext_base_end" = ""; then
231        ext_rel_url=$ext_base_front/releases/$ext_stable_branch.$ext_latest
232      else
233        ext_rel_url=$ext_base_front/releases/$ext_stable_branch.$ext_latest$ext_base_end
234      fi
235
236      echo "  $ext_rel_url"
237      echo "$ext_name  $ext_rel_url" >> Externals.releases
238      ext_name=
239    fi
240  done
241
242  echo '===> Creating backup (.bak) for Externals'
243  mv Externals Externals.bak
244  mv Externals.releases Externals
245
246  echo ''
247  echo '===> Updating svn:externals properties, and checking out externals...'
248  echo ''
249
250  svn pset svn:externals -F Externals .
251
252  svn update
253
254  echo ''
255  echo '===> If there are ThirdParty externals, run the download scripts...'
256  echo ''
257
258  ext_name=
259  ext_url=
260  for i in `cat Externals`; do
261    if test "$ext_name" = ""; then
262      ext_name="$i"
263    else
264      ext_url=$i
265
266      case $ext_name in
267        ThirdParty/*)
268          pkg=`echo $ext_name | sed -e 's|ThirdParty/||' -e 's|/||g'`
269          getfile=get.$pkg
270          if test -r $ext_name/$getfile; then
271            cd $ext_name
272            echo "Running $getfile in `pwd`"
273            eval ./$getfile
274            cd - > /dev/null
275          fi
276          ;;
277      esac
278      ext_name=
279    fi
280  done
281fi # if test -r Externals
282
283if test $is_thirdparty = yes; then
284  pkg=`echo $base_url | sed -e 's|.*/||g'`
285  if test -r get.$pkg; then
286    echo ''
287    echo '===> Download third party code...'
288    echo ''
289    ./get.$pkg
290  fi
291fi
292
293echo ''
294echo '===> Running the autotools...'
295echo ''
296
297if test $is_thirdparty = yes; then
298  cd ../..
299  BuildTools/run_autotools
300  cd - > /dev/null
301else
302  BuildTools/run_autotools
303fi
304
305if test -r Externals; then
306
307  echo '===> Verifying consistency of the BuildTools versions...'
308  echo ''
309
310  ext_name=
311  ext_url=
312  rm -f problems.ext
313  for i in `cat Externals`; do
314    if test "$ext_name" = ""; then
315      ext_name="$i"
316    else
317      ext_url=$i
318
319      echo "  checking $ext_name"
320
321      num_M=`svn status $ext_name | grep -E '^M' | wc -l`
322
323      if test $num_M -ne 0; then
324        echo $ext_name >>problems.ext
325        echo '    ... BuildTools not consistent!'
326      else
327        echo '    ... Ok'
328      fi
329      ext_name=
330    fi
331  done
332
333  if test -r problems.ext; then
334    echo ''
335    echo 'PROBLEM DURING CONSITENCY CHECK:'
336    echo ''
337    echo 'Please contact the project manager(s) for the following project(s).'
338    echo 'A new release needs to be made with your stable branch of BuildTools.'
339    echo ''
340    cat problems.ext
341    echo ''
342    rm -f problems.ext
343    exit -2
344  fi
345  rm -f problems.ext
346fi # if test -r Externals
347
348if test $is_thirdparty != yes; then
349  (set -e
350   echo ''
351   echo '===> Creating build directory and running the configuration script...'
352   echo ''
353   mkdir build
354   cd build
355   cmd="$tmpcodir/configure -C --enable-maintainer-mode"
356   echo $cmd
357   eval $cmd
358   echo ''
359   echo '===> Compiling code...'
360   echo ''
361   cmd='make install'
362   echo $cmd
363   eval $cmd
364   echo ''
365   echo '===> Running the unit test...'
366   echo ''
367   echo '*******************************************************************************'
368   echo '***                                                                         ***'
369   echo '***                       BEGIN OUTPUT OF MAKE TEST                         ***'
370   echo '***                                                                         ***'
371   echo '*******************************************************************************'
372   echo ''
373   cmd='make test'
374   echo $cmd
375   eval $cmd
376   echo ''
377   echo '*******************************************************************************'
378   echo '***                                                                         ***'
379   echo '***                        END OUTPUT OF MAKE TEST                          ***'
380   echo '***                                                                         ***'
381   echo '*******************************************************************************'
382  )
383  if test $? != 0; then
384    echo ''
385    echo 'Error during build or test'
386    echo ''
387    exit -3
388  fi
389fi
390
391echo ''
392echo '===> ALL TESTS PASSED'
393if test $is_thirdparty != yes; then
394  echo ''
395  echo 'Please review the output above, particularly the one of make test'
396fi
397if test -r Externals; then
398  echo ''
399  echo 'Also, please check the Externals:'
400  cat Externals
401fi
402
403echo ''
404echo 'After reviewing the output above, you can create a new release by going into'
405echo 'the directory'
406echo ''
407echo "          $tmpcodir"
408echo ''
409echo "and run the $tmpbas/BuildTools/commit_new_release script"
410
411cat >.new_release_data <<EOF
412tmpcodir=$tmpcodir
413tmpbas=$tmpbas
414base_url=$base_url
415stable_url=$stable_url
416new_ver=$new_ver
417stable_branch=$stable_branch
418EOF
419
Note: See TracBrowser for help on using the repository browser.