source: trunk/commit_new_release @ 1593

Last change on this file since 1593 was 1593, checked in by lou, 11 years ago

Release scripts *_new_release rewritten for new script architecture. Upgrades
and bug fixes for coin-functions, *_new_stable, set_externals. Correctly handle
multilevel project names (e.g., CHiPPS/Alps), CppAD version numbering.

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