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 |
---|
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 | if test "$#" -eq 0; then |
---|
39 | printHelp=1 |
---|
40 | else |
---|
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 |
---|
58 | fi |
---|
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 | |
---|
63 | if 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 |
---|
137 | fi |
---|
138 | |
---|
139 | if test $printHelp = 1 ; then |
---|
140 | cat <<EOF |
---|
141 | Usage: set_externals <Dependency File> |
---|
142 | |
---|
143 | This script takes as input a dependency file containing a list of stable |
---|
144 | versions of COIN projects on separate lines in the form |
---|
145 | |
---|
146 | <name> <URL of stable version> |
---|
147 | |
---|
148 | Recommended practice is to keep this list in a file called "Dependencies" in |
---|
149 | the project's root directory. A temporary file called "Externals.releases" in |
---|
150 | the same form, but with the URL of each stable version replaced by the URL of |
---|
151 | the latest associated release is produced. From this file, the script will |
---|
152 | set the svn:externals variable. It does not do an update or commit the |
---|
153 | change. After the script runs, do an update and test build, then commit the |
---|
154 | change if you are happy. |
---|
155 | |
---|
156 | EOF |
---|
157 | else |
---|
158 | cat <<EOF |
---|
159 | Externals set successfully. Please verify that the change is OK and then |
---|
160 | commit to make the change permanent. |
---|
161 | EOF |
---|
162 | |
---|
163 | fi |
---|
164 | |
---|
165 | exit $exitValue |
---|