source: stable/0.5/set_externals @ 1695

Last change on this file since 1695 was 1400, checked in by tkr, 11 years ago

Merging r1368 accidentally committed to releases/0.5.29 to stable/0.5 (oops :P)

  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#!/bin/sh
2
3# Copyright (C) 2007 International Business Machines and
4# Copyright (c) 2009 Lehigh University
5# All Rights Reserved.
6# This file is distributed under the Common Public License.
7# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
8#
9## $Id: prepare_new_release 1302 2009-06-07 18:17:53Z stefan $
10#
11# This script is based on prepare_new_release, which is authored by
12# Author: Andreas Waechter     IBM      2007-06-21
13# Modified: Lou Hafer          SFU      2008-01-20
14#
15# The modifications to set_externals were made by
16# Ted Ralphs Lehigh University          2009-07-07
17#
18
19#set -x -v
20set -e
21
22determine_release ()
23{ 
24  drtmp_stableBranch=`echo $1 | sed -e 's|.*/stable/||'`
25  drtmp_baseURL=`echo $1 | sed -e 's|/stable/[0-9.]*||'`
26  drtmp_returnVal=
27
28  # List the existing releases and screen for releases matching stableBranch.
29
30  drtmp_svnlst=`svn list $drtmp_baseURL/releases/`
31
32  drtmp_release_vers=
33  for drtmp_i in $drtmp_svnlst ; do
34    case $drtmp_i in
35      $drtmp_stableBranch.*)
36        drtmp_i=`echo $drtmp_i | sed -e 's|/$||'`
37        drtmp_release_vers="$drtmp_release_vers $drtmp_i";;
38    esac;
39  done
40
41  # Are there any existing releases? If not, and the user didn't ask for the
42  # next release, we have an error.
43
44  if test -z "$drtmp_release_vers" ; then
45    if test $2 = 1 ; then
46      drtmp_returnVal="$drtmp_stableBranch.0"
47    else
48      drtmp_returnVal="Error"
49    fi
50  else
51
52  # There are releases. If we don't have one after the loop, we're confused.
53
54    drtmp_new_rel=-10000
55    for drtmp_i in $drtmp_release_vers; do
56      drtmp_rel=`echo $drtmp_i | sed -e "s|^$drtmp_stableBranch.||"`
57      if test $drtmp_rel -gt $drtmp_new_rel; then
58        drtmp_new_rel=$drtmp_rel
59      fi
60    done
61
62    if test $drtmp_new_rel = -10000; then
63      drtmp_new_rel="Error"
64    elif test $2 = 1 ; then
65      drtmp_new_rel=`expr $drtmp_new_rel + 1`
66    fi
67      drtmp_returnVal="$drtmp_stableBranch.$drtmp_new_rel"
68  fi
69
70  echo $drtmp_returnVal
71}
72
73printHelp=0
74exitValue=0
75Dependencies=
76
77if test "$#" -eq 0; then
78  printHelp=1
79else
80
81# Process the parameters. A parameter without an opening `-' is assumed to be
82# the spec for the stable branch.
83
84  while test $# -gt 0 && test $exitValue = 0 && test $printHelp = 0 ; do
85    case "$1" in
86      -h* | --h*) printHelp=1 ;;
87           
88       -*) echo "$0: unrecognised command line switch '"$1"'."
89           printHelp=1
90           exitValue=-1
91           ;;
92        *) Dependencies=$1
93           ;;
94    esac
95    shift
96  done
97fi
98
99# End of parameter parsing. We have a stable URL to work with.  Tell the
100# user what we've seen.
101
102# Find out the most recent release (if any) for the stable branch. List the
103# existing releases and screen for releases matching stableBranch. The new
104# release should be one greater than any existing release, or 0 if the stable
105# branch has no releases.
106
107if test $printHelp = 0 && test $exitValue = 0; then
108
109  rm -f Externals
110
111  if test -r $Dependencies; then
112
113    echo ''
114    echo '===> Creating new externals file with pointers to releases...'
115    echo ''
116
117    ext_name=
118    ext_url=
119    for i in `cat $Dependencies`; do
120      if test "$ext_name" = ""; then
121        ext_name="$i"
122      else
123        ext_url=$i
124        if (echo $ext_name | grep -E '^#' >/dev/null); then
125          echo "Skip $ext_name."
126          ext_name=
127          continue
128        fi                                   
129        if (echo $ext_url | grep -E 'trunk|stable/|releases/' >/dev/null); then
130          :;
131        else
132          echo ''
133          echo "The external URL $ext_url is not valid. Exiting."
134          echo ''
135          exit -2
136        fi
137
138        ext_base_front=`echo $ext_url | sed -e 's|/stable/.*||'`
139        ext_proj=`echo $ext_base_front | sed -e 's|.*/\([^/]*\)|\1|'`
140
141        if expr "$ext_url" : '.*releases/.*' 2>&1 >/dev/null ; then
142          echo "Using specified release for $ext_name."
143          ext_rel_url=$ext_url
144        elif expr "$ext_url" : '.*trunk.*' 2>&1 >/dev/null; then
145          echo "Using specified trunk for $ext_name."
146          ext_rel_url=$ext_url
147        else
148          ext_stable=`echo $ext_url | sed -e 's|\(.*/stable/[0-9\.]*\).*|\1|'`
149          ext_base_end=`echo $ext_url | sed -e 's|.*/stable/[0-9\.]*||'`
150
151          echo "Determining release for $ext_name:"
152          ext_latest=`determine_release $ext_stable 0`
153 
154          if test "$ext_base_end" = ""; then
155            ext_rel_url=$ext_base_front/releases/$ext_latest
156          else
157            ext_rel_url=$ext_base_front/releases/$ext_latest$ext_base_end
158          fi
159        fi
160
161        echo "  $ext_rel_url"
162        echo "$ext_name  $ext_rel_url" >>Externals
163        ext_name=
164      fi
165    done
166
167    echo ''
168    echo '===> Updating svn:externals property...'
169    echo ''
170
171    svn pset svn:externals -F Externals .
172 
173    #Leave the new externals file there for no
174    #rm -f Externals
175
176  else # if test -r Externals
177    echo ""
178    echo "Dependency file does not exist or is unspecified..."
179    echo ""
180    printHelp=1
181    exitvalue=-2
182  fi
183fi
184
185if test $printHelp = 1 ; then
186  cat <<EOF
187Usage: set_externals <Dependency File>
188
189This script takes as input a dependency file containing a list of stable
190versions of COIN projects on separate lines in the form
191
192 <name> <URL of stable version>
193
194Recommended practice is to keep this list in a file called "Dendencies" in the
195project's root directory. A temporary file called "Externals" in the same form,
196but with the URL of each stable version replaced by the URL of the latest
197associated release is produced. From this file, the script will set the
198svn:externals variable. It does not do an update or commit the change. After
199the script runs, do an update and test build, then commit the change if you
200are happy.
201
202EOF
203else
204cat <<EOF
205Externals set successfully. Please verify that the change is OK and then
206commit to make the change permanent.
207EOF
208
209fi
210
211exit $exitValue
Note: See TracBrowser for help on using the repository browser.