File: commit_new_release

package info (click to toggle)
coinutils 2.11.4%2Brepack1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,212 kB
  • sloc: cpp: 73,714; sh: 11,224; makefile: 276; ansic: 35
file content (291 lines) | stat: -rwxr-xr-x 7,658 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/bin/sh

# Copyright (C) 2010  International Business Machines and others.
# All Rights Reserved.
# This file is distributed under the Eclipse Public License.
# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
#
# $Id: commit_new_release 3599 2016-07-20 15:32:26Z stefan $
#
# Author: Andreas Waechter     IBM      2007-06-21
# Modified by: Lou Hafer       SFU	2008-04-17
#              Lou Hafer       SFU	2010-06-29	major rewrite

#set -x -v

set -e

# Know thy self. If there are no '/' chars in the command name, we're running
# in the current directory. Otherwise, strip the command name, leaving the
# prefix.  Coin-functions is expected to live in the same directory.  As of
# the original version (100602), this script doesn't need coin-functions,
# but this still has some value as a consistency check.

if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
  cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
else
  cmdDir='.'
fi
cmdDir=`cd $cmdDir ; pwd`
if test -r $cmdDir/coin-functions ; then
  . $cmdDir/coin-functions
else
  echo "Cannot find utility functions file coin-functions; exiting."
fi

# We need at least one parameter. The default is a dry run (dryRun = 1).

printHelp=0
dryRun=1
dirToCommit=

if test "$#" -eq 0; then
  printHelp=1
else

# Process the parameters. A parameter without an opening `-' is assumed to be
# the spec for the directory to be committed. (Strip any trailing '/'. Some
# people add it, but the script doesn't expect it.)

  while test $# -gt 0 && test $printHelp = 0 ; do
    case "$1" in
      -h* | --h*)
	   printHelp=1
	   ;;
      -c* | --c*)
	   dryRun=0
	   ;;
       -*) echo "$0: unrecognised command line switch '"$1"'."
	   printHelp=1
	   ;;
	*) dirToCommit=`echo $1 | sed -e 's,/$,,'`
	   ;;
    esac
    shift
  done
fi

# What are we committing?

if test -z "$dirToCommit" ; then
  printHelp=1
fi

if test $printHelp = 1 ; then
  cat <<EOF
usage: commit_new_release [-c] <directory_to_commit>

  By default, commit_new_release is a dry run, printing the commands that
  will be executed. When you're confident that everything looks right, use
  the -c (--commit) flag to commit the release.
EOF
  exit 1
fi

# Remember what was done during generation of the new release.

if test -r $dirToCommit/.new_release_data; then
  . $dirToCommit/.new_release_data
else
  echo ''
  echo "Error: the file .new_release_data is not present in $dirToCommit."
  echo 'Are you running commit_new_release in the same directory where you'
  echo 'ran prepare_new_release?'
  echo ''
  exit 1
fi

# Confirm that we're in the proper directory.

currDir=`pwd`
if test "$currDir/$dirToCommit" != "$topBuildDir" ; then
  echo "According to $dirToCommit/.new_release_data, the release candidate was assembled"
  echo "in $topBuildDir."
  echo "You have asked to commit $currDir/$dirToCommit."
  echo "There is some confusion. Repository is unchanged."
  exit 1
fi

if test $dryRun = 1 ; then
  echo "Dry run; testing commit of $dirToCommit."
else
  echo "Committing $dirToCommit."
fi

# Change to the checkout directory.

cd $coDir

# If there are externals set on this directory, confirm that
# .Externals.original is present so that we can restore them later.

releaseExternals=`svn propget svn:externals . || true`
if test -n "$releaseExternals" ; then
  if test -r .Externals.original ; then
    :
  else
    echo "This project has externals, but no .Externals.original file"
    echo "is present to restore them. Repository is unchanged."
    exit 1
  fi
fi

# Make some short-form URLs by stripping the COIN URL base.

stableURLshort=`echo $stableURL | sed -e "s,$coinURL/\(.*\),\1,"`
releaseURLshort=`echo $releaseURL | sed -e "s,$coinURL/\(.*\),\1,"`

# Do we have to svn add Dependencies? If this query comes up with a leading
# `?', the answer is yes. If Dependencies is entirely absent or unchanged,
# we'll get a null string. If it's modified, we'll have a leading `M'.

dependStatus=`svn status Dependencies`
if expr "$dependStatus" : '?.*Dependencies.*' >/dev/null 2>&1 ; then
  cmd='svn add Dependencies'
  echo $cmd
  if test $dryRun = 0 ; then
    eval $cmd
  fi
fi

# Now, do we really need to to a temporary commit? BuildTools is the poster
# child, there are no changes at time of writing (100629). Do an svn status
# on the checkout directory and see if anything comes up as modified.

if svn status $coDir | egrep '^M' 2>&1 >/dev/null ; then
  doCommit=yes
else
  doCommit=no
fi

if test $doCommit = yes ; then

# Commit the release to stable so we can do a repository-side copy to create
# the release.

  echo ''
  echo "===> Temporarily committing release candidate to $stableURLshort ..."
  echo ''

  rev_num_before=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
  echo "Revision number before commit: $rev_num_before"

  cmd="svn ci -m \"temporarily committing release candidate\""
  echo $cmd
  if test $dryRun = 0 ; then
    eval $cmd
  fi

# Update to confirm the commit. Avoid pulling in externals --- if we're doing
# multiple commits of new releases, they may not exist. As it stands, the
# main purpose of this call is to allow us to easily obtain the current
# revision.
# It might be useful to strengthen this and check that the value
# is what we're expecting --- one greater than the revision before
# commit. `--ignore-externals' could be made provisional on the existence
# of all externals by passing a boolean through .new_release_data. This
# would strengthen the update, in that the update would confirm existence
# of the externals.

  cmd='svn update --ignore-externals'
  echo $cmd
  if test $dryRun = 0 ; then
    eval $cmd
  fi

  rev_num=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
  echo "Current revision number is: $rev_num"

fi

# End preparatory commit.

# Create the release with a repository-side copy.

echo ''
echo "===> Creating new release $releaseURLshort from $stableURLshort (rev $rev_num) ..."
echo ''

cmd="svn copy -m \"creating $releaseURLshort from $stableURLshort (rev $rev_num)\" $stableURL $releaseURL"
echo $cmd
if test $dryRun = 0 ; then
  eval $cmd
fi

# Restore the original stable branch.

if test $doCommit = yes ; then

# And restore the stable branch to its original condition. Start by reverting
# to the original externals.

  if test -r .Externals.original ; then
    echo ''
    echo '===> Restoring original externals ...'
    echo ''
    cmd="svn propset -F .Externals.original svn:externals ."
    echo $cmd
    if test $dryRun = 0 ; then
      eval $cmd
      rm .Externals.original
    fi
  fi

# For every .bak file that we created, revert it. 

  if test -n "$bak_files" ; then
    echo ''
    echo '===> Restoring modified files ...'
    echo ''
    for i in $bak_files; do
      cmd="cp $i.bak $i ; rm $i.bak"
      if test $dryRun = 1 ; then
	echo "$cmd"
      else
	eval $cmd
      fi
    done
  fi

# Rebuild configure and Makefile.in files.

  echo ''
  echo '===> Executing run_autotools to restore configuration files ...'
  echo ''
  curdir=`pwd`
  cd $topBuildDir
  cmd="./BuildTools/run_autotools"
  echo $cmd
  if test $dryRun = 0 ; then
    eval $cmd
  fi
  cd "$curdir"

# Commit the restored stable branch.

  echo ''
  echo "===> Committing restored $stableURLshort ..."
  echo ''

  cmd="svn ci -m \"restoring $stableURLshort\""
  echo $cmd
  if test $dryRun = 0 ; then
    eval $cmd
  fi

fi

# End restorative commit.

cd $topBuildDir
cmd="rm .new_release_data"
if test $dryRun = 0 ; then
  eval $cmd
fi

cd $startDir
echo ''
echo "Done, new release $releaseURLshort created."
echo ''
echo "You can now delete the directory $topBuildDir including subdirectories"