Debian Codegraph @

BuildTools/set_externals

raw
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 Eclipse 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
16 set -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
22 if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
23 cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
24 else
25 cmdDir='.'
26 fi
27 if test -r $cmdDir/coin-functions ; then
28 . $cmdDir/coin-functions
29 else
30 echo "Cannot find utility functions file coin-functions; exiting."
31 fi
32
33
34 printHelp=0
35 exitValue=0
36 depFile=
37
38 # stableExternals specifies externals which we do not want to convert to
39 # releases, for whatever reason.
40
41 stableExternals=
42
43 if test "$#" -eq 0; then
44 printHelp=1
45 else
46
47 # Process the parameters. A parameter without an opening `-' is assumed to be
48 # the dependency file.
49
50 while test $# -gt 0 && test $exitValue = 0 && test $printHelp = 0 ; do
51 case "$1" in
52 -h* | --h*) printHelp=1 ;;
53 -s* | --s*)
54 if expr "$1" : '.*-s.*=.*' 2>&1 >/dev/null ; then
55 stableExternals=`echo $1 | sed -n -e 's/[^=]*=\(.*\)/\1/p'`
56 else
57 shift
58 stableExternals=$1
59 fi
60 ;;
61 -*) echo "$0: unrecognised command line switch '"$1"'."
62 printHelp=1
63 exitValue=1
64 ;;
65 *) depFile=$1
66 ;;
67 esac
68 shift
69 done
70 fi
71
72 # Find the most recent release for each stable external. Allow for the
73 # possibility that a stable branch has no associated release, or that the
74 # user has asked to keep the stable external.
75
76 if test $printHelp = 0 && test $exitValue = 0; then
77 if test -r $depFile; then
78
79 rm -f Externals.releases
80
81 echo ''
82 echo '===> Converting stable externals to releases ...'
83 echo ''
84
85 ext_name=
86 ext_url=
87 for i in `cat $depFile`; do
88 if test "$ext_name" = ""; then
89 ext_name="$i"
90 else
91 ext_url=$i
92 if expr "$ext_name" : '#.*' >/dev/null 2>&1 ; then
93 echo "Skipping $ext_name."
94 ext_name=
95 continue
96 fi
97 if expr "$stableExternals" : '.*'"$ext_name"'.*' 2>&1 >/dev/null ; then
98 echo " $ext_name $ext_url unchanged"
99 else
100 extType=`extractTypeFromURL $ext_url`
101 if test "$extType" = invalid ; then
102 echo ''
103 echo "The external URL $ext_url appears to be invalid. Exiting."
104 echo ''
105 exit 3
106 fi
107
108 if test "$extType" = stable ; then
109 ext_majVer=`extractMajorFromURL $ext_url`
110 ext_minVer=`extractMinorFromURL $ext_url`
111 ext_rel_url=`bestRelease $ext_url $ext_majVer $ext_minVer`
112 if test -z "$ext_rel_url" ; then
113 echo "There is no release for $ext_url"
114 echo "Keeping $ext_url"
115 else
116 # Normal (not BuildTools/ThirdParty/Data) need a directory name,
117 # and it may differ from the project name. Carefully preserve it.
118 # ThirdParty URLs include BuildTools ; both named for emphasis
119 case $ext_rel_url in
120 */BuildTools/* | */ThirdParty/* | */Data/* ) ;;
121 *) ext_tail=`extractTailFromExt $ext_url`
122 ext_rel_url=${ext_rel_url}${ext_tail}
123 ;;
124 esac
125 echo "Replacing $ext_url with $ext_rel_url"
126 ext_url=$ext_rel_url
127 fi
128 else
129 echo "Keeping $ext_url"
130 fi
131 fi
132
133 echo "$ext_name $ext_url" >>Externals.releases
134 ext_name=
135 fi
136 done
137
138 echo ''
139 echo '===> Updating svn:externals property...'
140 echo ''
141
142 svn propset svn:externals -F Externals.releases .
143 svn propget svn:externals .
144
145 rm Externals.releases
146
147 else # if test -r depFile
148 echo ""
149 echo "Dependency file does not exist or is unspecified..."
150 echo ""
151 printHelp=1
152 exitvalue=2
153 fi
154 fi
155
156 if test $printHelp = 1 ; then
157 cat <<EOF
158 Usage: set_externals <Dependency File>
159
160 Options:
161 -s <projectlist> Suppress conversion from stable to release for the
162 listed externals (comma-separated list of project
163 names, e.g., -s Osi,Cbc).
164
165 This script takes as input a dependency file containing a list of stable
166 versions of COIN projects on separate lines in the form
167
168 <name> <URL of stable version>
169
170 Recommended practice is to keep the set of stable externals in a file
171 called "Dependencies" in the project's root directory. A temporary file
172 called "Externals.releases" in the same form, but with the URL of each
173 stable version replaced by the URL of the latest associated release is
174 produced. From this file, the script will set the svn:externals variable. It
175 does not do an update or commit the change. After the script runs, do an
176 update and test build, then commit the change if you are happy.
177
178 EOF
179 else
180 cat <<EOF
181 Externals set successfully. Please verify that the change is OK and then
182 commit to make the change permanent.
183 EOF
184
185 fi
186
187 exit $exitValue