source: trunk/prepare_new_release @ 412

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

some changes for release files; make it work for Data projects

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