Ignore:
Timestamp:
Jul 4, 2010 11:22:15 PM (11 years ago)
Author:
lou
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/commit_new_release

    r1590 r1593  
    11#!/bin/sh
    22
    3 # Copyright (C) 2007  International Business Machines.
     3# Copyright (C) 2010  International Business Machines and others.
    44# All Rights Reserved.
    55# This file is distributed under the Common Public License.
    66# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
    77#
    8 ## $Id$
     8# $Id$
    99#
    1010# Author: Andreas Waechter     IBM      2007-06-21
    1111# Modified by: Lou Hafer       SFU      2008-04-17
     12#              Lou Hafer       SFU      2010-06-29      major rewrite
    1213
    1314#set -x -v
     
    1516set -e
    1617
    17 # Remember what was done during release generation.
    18 
    19 if test -r .new_release_data; then
    20   . ./.new_release_data
    21 else
    22   echo ''
    23   echo 'Error: You need to run prepare_new_release first.'
    24   echo ''
    25   exit -1;
    26 fi
     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
    27160
    28161# Commit the release to stable so we can do a repository-side copy to create
    29162# the release.
    30163
    31 echo ''
    32 echo '===> Temporarily committing changed version of stable...'
    33 echo ''
    34 
    35 rev_num_before=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
    36 echo "Revision number before commit: $rev_num_before"
    37 
    38 cmd="svn ci -m \"temporarily committing release candidate to stable\""
     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"
    39208echo $cmd
    40 eval $cmd
    41 
    42 # Update to confirm the commit. Avoid pulling in externals --- if we're doing
    43 # circular dependencies, they may not exist. As it stands, the main purpose of
    44 # this call is to allow us to easily obtain the current revision. It might be
    45 # useful to strengthen this and check that the value is what we're expecting
    46 # --- one greater than the revision before commit. `--ignore-externals' could
    47 # be made provisional on the existence of circular dependency by passing a
    48 # boolean through .new_release_data. This would strengthen the update, in that
    49 # the update would confirm existence of the externals.
    50 
    51 cmd='svn update --ignore-externals'
    52 echo $cmd
    53 eval $cmd
    54 
    55 rev_num=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
    56 echo "Current revision number is: $rev_num"
    57 
    58 # Create the release with a repository-side copy.
    59 
    60 echo ''
    61 echo "===> Creating new release $new_ver from stable $stableBranch (rev $rev_num)..."
    62 echo ''
    63 
    64 cmd="svn copy -m \"creating releases/$new_ver from stable/$stableBranch (rev $rev_num)\" $stableURL $releaseURL"
    65 echo $cmd
    66 eval $cmd
    67 
    68 # And restore the stable branch to it's original condition. Start by reverting
     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
    69218# to the original externals.
    70219
    71 if test -r Externals; then
    72   echo ''
    73   echo '===> Restoring original externals...'
    74   echo ''
    75 
    76   mv Externals.bak Externals
    77   svn pset svn:externals -F Externals .
    78 fi
    79 
    80 # Revert the package id in configure.ac and propagate with run_autotools.  Note
    81 # that this does not exclude configure.ac for externals in the normal place.
    82 # But since changes to externals are not swept up by the commit, it doesn't
    83 # matter. On the other hand, if this whole checkout is a temporary for the
    84 # purpose of release generation, I'm not entirely convinced we need to bother
    85 # to exclude configure.ac in the actual ThirdParty code base. Comments from
    86 # ThirdParty maintainers welcome.
    87 
    88 conf_ac_files=`find . -name 'configure.ac' | grep -v -E 'ThirdParty/.*/.*/configure.ac'`
    89 
    90 echo ''
    91 echo "===> Restoring version number (${stableBranch}stable) in configure.ac files"
    92 for i in $conf_ac_files; do
    93   sed -e "s|AC_INIT\(.*\)\[[0-9\.]*\],\(.*\)|AC_INIT\1[${stableBranch}],\2|" $i > bla
    94   mv bla $i
    95   svn di $i
    96 done
    97 
    98 echo ''
    99 echo '===> Running the autotools'
    100 echo ''
    101 curdir=`pwd`
    102 cd $buildBase
    103 BuildTools/run_autotools
    104 cd "$curdir"
     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"
    105261
    106262# Commit the restored stable branch.
    107263
    108 echo ''
    109 echo '===> Committing restored stable...'
    110 echo ''
    111 
    112 cmd="svn ci -m \"restoring stable/$stableBranch\""
    113 echo $cmd
    114 eval $cmd
    115 
    116 echo ''
    117 echo "Done, new release $releaseURL created"
    118 echo ''
    119 echo "You can now delete the directory $buildBase including subdirectories"
    120 
    121 rm .new_release_data
     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 TracChangeset for help on using the changeset viewer.