source: trunk/commit_new_release @ 2002

Last change on this file since 2002 was 1950, checked in by andreasw, 10 years ago

changed license from CPL to EPL (see also http://www.ibm.com/developerworks/library/os-cplfaq.html)

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