source: trunk/set_externals @ 1561

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

Correctly handle case where directory used for external does not match the
project name, e.g., FlopC++/trunk/FlopCpp. Also add libtool library version
functions in coin-functions and correct output redirection.

  • Property svn:executable set to *
File size: 4.3 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$
10#
11
12# Adapted from prepare_new_release by Ted Ralphs, Lehigh Univ., 2009-07-07
13# Modified: Lou Hafer          SFU      2010-06-02
14
15#set -x -v
16set -e
17
18# Know thy self. If there are no '/' chars in the command name, we're running
19# in the currrent directory. Otherwise, strip the command name, leaving the
20# prefix.  Coin-functions is expected to live in the same directory.
21
22if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
23  cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
24else
25  cmdDir='.'
26fi
27if test -r $cmdDir/coin-functions ; then
28  . $cmdDir/coin-functions
29else
30  echo "Cannot find utility functions file coin-functions; exiting."
31fi
32
33
34printHelp=0
35exitValue=0
36depFile=
37
38if test "$#" -eq 0; then
39  printHelp=1
40else
41
42# Process the parameters. A parameter without an opening `-' is assumed to be
43# the dependency file.
44
45  while test $# -gt 0 && test $exitValue = 0 && test $printHelp = 0 ; do
46    case "$1" in
47      -h* | --h*) printHelp=1 ;;
48           
49       -*) echo "$0: unrecognised command line switch '"$1"'."
50           printHelp=1
51           exitValue=1
52           ;;
53        *) depFile=$1
54           ;;
55    esac
56    shift
57  done
58fi
59
60# Find the most recent release for each stable external. Allow for the
61# possibility that a stable branch has no associated release.
62
63if test $printHelp = 0 && test $exitValue = 0; then
64  if test -r $depFile; then
65
66    rm -f Externals.releases
67
68    echo ''
69    echo '===> Converting stable externals to releases ...'
70    echo ''
71
72    ext_name=
73    ext_url=
74    for i in `cat $depFile`; do
75      if test "$ext_name" = ""; then
76        ext_name="$i"
77      else
78        ext_url=$i
79        if expr "$ext_name" : '#.*' >/dev/null 2>&1 ; then
80          echo "Skipping $ext_name."
81          ext_name=
82          continue
83        fi                                   
84        extType=`extractTypeFromURL $ext_url`
85        if test "$extType" = invalid ; then
86          echo ''
87          echo "The external URL $ext_url appears to be invalid. Exiting."
88          echo ''
89          exit 3
90        fi
91
92        if test "$extType" = stable ; then
93          ext_majVer=`extractMajorFromURL $ext_url`
94          ext_minVer=`extractMinorFromURL $ext_url`
95          ext_rel_url=`bestRelease $ext_url $ext_majVer $ext_minVer`
96          if test -z "$ext_rel_url" ; then
97            echo "There is no release for $ext_url"
98            echo "Keeping $ext_url"
99          else
100            # Normal (not BuildTools/ThirdParty/Data) need a directory name,
101            # and it may differ from the project name. Carefully preserve it.
102            # ThirdParty URLs include BuildTools ; both named for emphasis
103            case $ext_rel_url in
104              */BuildTools/* | */ThirdParty/* | */Data/* ) ;;
105              *) ext_tail=`extractTailFromExt $ext_url`
106                 ext_rel_url=${ext_rel_url}${ext_tail}
107                 ;;
108            esac
109            echo "Replacing $ext_url with $ext_rel_url"
110            ext_url=$ext_rel_url
111          fi
112        else
113          echo "Keeping $ext_url"
114        fi
115
116        echo "$ext_name  $ext_url" >>Externals.releases
117        ext_name=
118      fi
119    done
120
121    echo ''
122    echo '===> Updating svn:externals property...'
123    echo ''
124
125    svn propset svn:externals -F Externals.releases .
126    svn propget svn:externals .
127   
128    rm Externals.releases
129
130  else # if test -r depFile
131    echo ""
132    echo "Dependency file does not exist or is unspecified..."
133    echo ""
134    printHelp=1
135    exitvalue=2
136  fi
137fi
138
139if test $printHelp = 1 ; then
140  cat <<EOF
141Usage: set_externals <Dependency File>
142
143This script takes as input a dependency file containing a list of stable
144versions of COIN projects on separate lines in the form
145
146 <name> <URL of stable version>
147
148Recommended practice is to keep this list in a file called "Dendencies" in the
149project's root directory. A temporary file called "Externals.releases" in the
150same form, but with the URL of each stable version replaced by the URL of the
151latest associated release is produced. From this file, the script will set the
152svn:externals variable. It does not do an update or commit the change. After
153the script runs, do an update and test build, then commit the change if you
154are happy.
155
156EOF
157else
158cat <<EOF
159Externals set successfully. Please verify that the change is OK and then
160commit to make the change permanent.
161EOF
162
163fi
164
165exit $exitValue
Note: See TracBrowser for help on using the repository browser.