| 1 |
|
| 2 |
# Utility function definitions for the various COIN scripts. |
| 3 |
|
| 4 |
# Copyright (c) 2010 Lou Hafer Simon Fraser 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 |
# Functions to disassemble svn URLs and extract relevant bits, and utilities |
| 12 |
# to find the best (most recent) stable and release URLs, calculate libtool |
| 13 |
# version numbers, and compare URLs for compatibility based on major and minor |
| 14 |
# version. Complicated because we have to account for trunk/stable/release and |
| 15 |
# for the variant syntax of Data and ThirdParty URLs. For your normal project, |
| 16 |
# it's |
| 17 |
# https://projects.coin-or.org/svn/ProjName/trunk |
| 18 |
# https://projects.coin-or.org/svn/ProjName/stable/M.m |
| 19 |
# https://projects.coin-or.org/svn/ProjName/releases/M.m.r |
| 20 |
# with the proviso that sometimes it's |
| 21 |
# https://projects.coin-or.org/svn/ProjName/SubProj/trunk |
| 22 |
# etc. |
| 23 |
# For ThirdParty, it's just like a normal project, except the prefix string |
| 24 |
# is longer: |
| 25 |
# https://projects.coin-or.org/svn/BuildTools/ThirdParty/ProjName |
| 26 |
# Data is the real pain. Prior to 20101103 (1.0.x series), it had this form: |
| 27 |
# https://projects.coin-or.org/svn/Data/trunk/ProjName |
| 28 |
# https://projects.coin-or.org/svn/Data/stable/M.m/ProjName |
| 29 |
# https://projects.coin-or.org/svn/Data/releases/M.m.r/ProjName |
| 30 |
# After 20101103 (1.1 and subsequent), it uses the same layout as ThirdParty, |
| 31 |
# namely <svn prefix>/Data/Projname/<trunk, stable, releases>. Macros below |
| 32 |
# will cope, but really you should be using pre-1.1 Data anyway. |
| 33 |
|
| 34 |
# Extract the COIN base from the URL, up to svn. Just in case it ever changes. |
| 35 |
# usage: baseURL=`extractBaseURL $svnURL` |
| 36 |
|
| 37 |
extractBaseURL () |
| 38 |
{ |
| 39 |
exbu_baseURL=`echo $1 | sed -n -e 's|\(.*/svn\)/.*$|\1|p'` |
| 40 |
echo "$exbu_baseURL" |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
# Extract branch type (trunk/stable/release) from the URL. |
| 45 |
# usage: branchType=`extractTypeFromURL $svnURL` |
| 46 |
|
| 47 |
extractTypeFromURL () |
| 48 |
{ |
| 49 |
etfu_type="invalid" |
| 50 |
case "$1" in |
| 51 |
*/trunk* ) etfu_type=trunk ;; |
| 52 |
*/stable/* ) etfu_type=stable ;; |
| 53 |
*/releases/* ) etfu_type=release ;; |
| 54 |
esac |
| 55 |
echo $etfu_type |
| 56 |
} |
| 57 |
|
| 58 |
# Determine if this is a `normal' URL, defined as not Data, ThirdParty, or |
| 59 |
# BuildTools itself. ThirdParty lives in BuildTools as of 100628, so the |
| 60 |
# condition is redundant. Returns yes or no. |
| 61 |
# 101105 Exclude CoinBazaar, which follows the Data pattern. May not be the |
| 62 |
# correct choice if any CoinBazaar projects use BuildTools |
| 63 |
# usage: isNormal=`isNormalURL $svnURL` |
| 64 |
|
| 65 |
isNormalURL () |
| 66 |
{ case $1 in |
| 67 |
*/BuildTools/* | */ThirdParty/* | */Data/* | */CoinBazaar/* ) |
| 68 |
echo "no" |
| 69 |
;; |
| 70 |
*) echo "yes" |
| 71 |
;; |
| 72 |
esac |
| 73 |
} |
| 74 |
|
| 75 |
# Extract the project from a svn URL. The trick, for `normal' projects, is to |
| 76 |
# handle CHiPPS, which has CHiPPS/Alps, Bcps, Blis. We can't assume the |
| 77 |
# project name does not contain '/'. The heuristic is to look for everything |
| 78 |
# between svn and one of trunk, stable, releases, or end of line. |
| 79 |
# usage: projName=`extractProjFromURL $svnURL` |
| 80 |
|
| 81 |
extractProjFromURL () |
| 82 |
{ |
| 83 |
epfu_URL="$1" |
| 84 |
epfu_projPat='\([^/][^/]*\)' |
| 85 |
epfu_sfxPat='.*$' |
| 86 |
case "$epfu_URL" in |
| 87 |
*/Data/trunk/* ) |
| 88 |
epfu_pfxPat=svn/Data/trunk/ |
| 89 |
;; |
| 90 |
*/Data/stable/* | */Data/releases/* ) |
| 91 |
epfu_pfxPat='svn/Data/[^/][^/]*/[0-9][0-9.]*/' |
| 92 |
;; |
| 93 |
*/Data/* ) |
| 94 |
epfu_pfxPat='svn/Data/' |
| 95 |
;; |
| 96 |
*/ThirdParty/* ) |
| 97 |
epfu_pfxPat=svn/BuildTools/ThirdParty/ |
| 98 |
;; |
| 99 |
*) epfu_type=`extractTypeFromURL $epfu_URL` |
| 100 |
epfu_pfxPat='svn/' |
| 101 |
epfu_projPat='\(.*\)' |
| 102 |
case $epfu_type in |
| 103 |
trunk | stable | release ) |
| 104 |
epfu_sfxPat=$epfu_type'.*$' |
| 105 |
;; |
| 106 |
* ) |
| 107 |
epfu_sfxPat='$' |
| 108 |
;; |
| 109 |
esac |
| 110 |
;; |
| 111 |
esac |
| 112 |
epfu_projName=`echo $epfu_URL | sed -n -e 's|.*/'$epfu_pfxPat$epfu_projPat$epfu_sfxPat'|\1|p'` |
| 113 |
epfu_projName=`echo $epfu_projName | sed -e 's|/$||'` |
| 114 |
echo "$epfu_projName" |
| 115 |
} |
| 116 |
|
| 117 |
# Extract the tail (directory) from a URL that specifies an external. Relevant |
| 118 |
# only for normal projects, where the external will be a subdirectory |
| 119 |
# of the project. Returns null for Data / ThirdParty / BuildTools. |
| 120 |
# usage: projName=`extractTailFromExt $extURL` |
| 121 |
|
| 122 |
extractTailFromExt () |
| 123 |
{ |
| 124 |
etfe_tail= |
| 125 |
case "$1" in |
| 126 |
*/Data/* ) |
| 127 |
;; |
| 128 |
*/BuildTools/ThirdParty/* ) |
| 129 |
;; |
| 130 |
*/BuildTools/* ) |
| 131 |
;; |
| 132 |
*/CoinBazaar/* ) |
| 133 |
;; |
| 134 |
*) |
| 135 |
etfe_pfxPat= |
| 136 |
case "$1" in |
| 137 |
*/trunk/* ) |
| 138 |
etfe_pfxPat='.*/trunk/' |
| 139 |
;; |
| 140 |
*/stable/* ) |
| 141 |
etfe_pfxPat='.*/stable/[0-9][0-9.]*/' |
| 142 |
;; |
| 143 |
*/releases/* ) |
| 144 |
etfe_pfxPat='.*/releases/[0-9][0-9.]*/' |
| 145 |
;; |
| 146 |
esac |
| 147 |
etfe_tail=`echo $1 | sed -n -e 's|'$etfe_pfxPat'\(.*\)|\1|p'` |
| 148 |
;; |
| 149 |
esac |
| 150 |
echo "$etfe_tail" |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
# CppAD uses a version string of the form YYYMMDD.rr. What a pain in the ass. |
| 155 |
# Hence the scattered exceptions below. |
| 156 |
# Extract the entire version string from a stable or release URL. Returns a |
| 157 |
# null string if handed a trunk URL or if there's no version in the URL. The |
| 158 |
# version number must have at least major.minor to match. |
| 159 |
# usage: version=`extractVersionFromURL $svnURL` |
| 160 |
|
| 161 |
extractVersionFromURL () |
| 162 |
{ |
| 163 |
evfu_URL="$1" |
| 164 |
if expr "$evfu_URL" : '.*/stable/.*' >/dev/null 2>&1 || |
| 165 |
expr "$evfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then |
| 166 |
if expr "$evfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 167 |
evfu_verPat='\([0-9][0-9.]*\)' |
| 168 |
else |
| 169 |
evfu_verPat='\([0-9][0-9]*\.[0-9][0-9.]*\)' |
| 170 |
fi |
| 171 |
evfu_sfxPat='.*$' |
| 172 |
evfu_proj=`extractProjFromURL $evfu_URL` |
| 173 |
case "$evfu_URL" in |
| 174 |
*/Data/stable/* | */Data/releases/* ) |
| 175 |
evfu_pfxPat='svn/Data/[^/][^/]*/' |
| 176 |
;; |
| 177 |
*/ThirdParty/* ) |
| 178 |
evfu_pfxPat='svn/BuildTools/ThirdParty/[^/][^/]*/[^/][^/]*/' |
| 179 |
;; |
| 180 |
*/Data/* ) |
| 181 |
evfu_pfxPat='svn/Data/'$evfu_proj'/[^/][^/]*/' |
| 182 |
;; |
| 183 |
*) |
| 184 |
evfu_pfxPat='svn/'$evfu_proj'/[^/][^/]*/' |
| 185 |
;; |
| 186 |
esac |
| 187 |
evfu_verVer=`echo $1 | sed -n -e 's|.*/'$evfu_pfxPat$evfu_verPat$evfu_sfxPat'|\1|p'` |
| 188 |
echo "$evfu_verVer" |
| 189 |
else |
| 190 |
echo "" |
| 191 |
fi |
| 192 |
} |
| 193 |
|
| 194 |
# Replace the entire version string from a stable or release URL. A trunk |
| 195 |
# URL will be unmodified. newRev will not be accessed unless the URL is a |
| 196 |
# release. The version must have at least major.minor to match. |
| 197 |
# usage: newURL=`replaceVersionInURL $oldURL $newMajor $newMinor $newRev` |
| 198 |
# and just for CppAD, |
| 199 |
# usage: newURL=`replaceVersionInURL $oldURL $newMajor $newRev` |
| 200 |
|
| 201 |
replaceVersionInURL () |
| 202 |
{ |
| 203 |
if expr "$1" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 204 |
isCppAD=yes |
| 205 |
else |
| 206 |
isCppAD=no |
| 207 |
fi |
| 208 |
if test $isCppAD = no ; then |
| 209 |
rviu_verPat='[0-9][0-9]*\.[0-9][0-9.]*' |
| 210 |
else |
| 211 |
rviu_verPat='[0-9][0-9.]*' |
| 212 |
fi |
| 213 |
|
| 214 |
if expr "$1" : '.*/stable/.*' >/dev/null 2>&1 ; then |
| 215 |
if test $isCppAD = no ; then |
| 216 |
rviu_newVersion=$2.$3 |
| 217 |
else |
| 218 |
rviu_newVersion=$2 |
| 219 |
fi |
| 220 |
elif expr "$1" : '.*/releases/.*' >/dev/null 2>&1 ; then |
| 221 |
if test $isCppAD = no ; then |
| 222 |
rviu_newVersion=$2.$3.$4 |
| 223 |
else |
| 224 |
rviu_newVersion=$2.$3 |
| 225 |
fi |
| 226 |
else |
| 227 |
rviu_newVersion= |
| 228 |
rviu_newURL=$1 |
| 229 |
fi |
| 230 |
if test -n "$rviu_newVersion" ; then |
| 231 |
rviu_newURL=`echo $1 | sed -n -e 's|^\(.*\)/'$rviu_verPat'\(.*\)$|\1/'$rviu_newVersion'\2|p'` |
| 232 |
fi |
| 233 |
echo $rviu_newURL |
| 234 |
} |
| 235 |
|
| 236 |
# Extract the major version number from a stable or release URL. Returns -1 if |
| 237 |
# handed a trunk URL or if there's no version in the URL |
| 238 |
# usage: majVer=`extractMajorFromURL $svnURL` |
| 239 |
|
| 240 |
extractMajorFromURL () |
| 241 |
{ |
| 242 |
ejfu_URL="$1" |
| 243 |
if expr "$ejfu_URL" : '.*/stable/.*' >/dev/null 2>&1 || |
| 244 |
expr "$ejfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then |
| 245 |
ejfu_majPat='\([0-9][0-9]*\)' |
| 246 |
if expr "$ejfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 247 |
ejfu_sfxPat='.*$' |
| 248 |
else |
| 249 |
ejfu_sfxPat='\.[0-9][0-9]*.*$' |
| 250 |
fi |
| 251 |
ejfu_proj=`extractProjFromURL $ejfu_URL` |
| 252 |
case "$ejfu_URL" in |
| 253 |
*/Data/stable/* | */Data/releases/* ) |
| 254 |
ejfu_pfxPat='svn/Data/[^/][^/]*/' |
| 255 |
;; |
| 256 |
*/ThirdParty/* ) |
| 257 |
ejfu_pfxPat='svn/BuildTools/ThirdParty/[^/][^/]*/[^/][^/]*/' |
| 258 |
;; |
| 259 |
*/Data/* ) |
| 260 |
ejfu_pfxPat='svn/Data/'$ejfu_proj'/[^/][^/]*/' |
| 261 |
;; |
| 262 |
*) |
| 263 |
ejfu_pfxPat='svn/'$ejfu_proj'/[^/][^/]*/' |
| 264 |
;; |
| 265 |
esac |
| 266 |
ejfu_majVer=`echo $ejfu_URL | sed -n -e 's|.*/'$ejfu_pfxPat$ejfu_majPat$ejfu_sfxPat'|\1|p'` |
| 267 |
echo "$ejfu_majVer" |
| 268 |
else |
| 269 |
echo "-1" |
| 270 |
fi |
| 271 |
} |
| 272 |
|
| 273 |
# Extract the minor version number from a stable or release URL. Returns -1 if |
| 274 |
# handed a trunk URL or if there's no version in the URL. |
| 275 |
# The CppAD form (YYYYMMDD.rr) doesn't have a minor version number. |
| 276 |
# usage: minVer=`extractMinorFromURL $svnURL` |
| 277 |
|
| 278 |
extractMinorFromURL () |
| 279 |
{ |
| 280 |
emfu_URL="$1" |
| 281 |
if expr "$emfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 282 |
echo "-1" |
| 283 |
elif expr "$emfu_URL" : '.*/stable/.*' >/dev/null 2>&1 || |
| 284 |
expr "$emfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then |
| 285 |
emfu_minPat='[0-9][0-9]*\.\([0-9][0-9]*\)' |
| 286 |
emfu_sfxPat='.*$' |
| 287 |
emfu_proj=`extractProjFromURL $emfu_URL` |
| 288 |
case "$emfu_URL" in |
| 289 |
*/Data/stable/* | */Data/releases/* ) |
| 290 |
emfu_pfxPat='svn/Data/[^/][^/]*/' |
| 291 |
;; |
| 292 |
*/ThirdParty/* ) |
| 293 |
emfu_pfxPat='svn/BuildTools/ThirdParty/[^/][^/]*/[^/][^/]*/' |
| 294 |
;; |
| 295 |
*/Data/* ) |
| 296 |
emfu_pfxPat='svn/Data/'$emfu_proj'/[^/][^/]*/' |
| 297 |
;; |
| 298 |
*) |
| 299 |
emfu_pfxPat='svn/'$emfu_proj'/[^/][^/]*/' |
| 300 |
;; |
| 301 |
esac |
| 302 |
emfu_minVer=`echo $emfu_URL | sed -n -e 's|.*/'$emfu_pfxPat$emfu_minPat$emfu_sfxPat'|\1|p'` |
| 303 |
echo "$emfu_minVer" |
| 304 |
else |
| 305 |
echo "-1" |
| 306 |
fi |
| 307 |
} |
| 308 |
|
| 309 |
# Extract the release (revision) number from a release URL. Returns -1 if |
| 310 |
# handed a trunk or stable URL |
| 311 |
# usage: minVer=`extractReleaseFromURL $svnURL` |
| 312 |
|
| 313 |
extractReleaseFromURL () |
| 314 |
{ |
| 315 |
erfu_URL="$1" |
| 316 |
if expr "$erfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then |
| 317 |
if expr "$erfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 318 |
erfu_relPat='[0-9][0-9]*\.\([0-9][0-9]*\)' |
| 319 |
else |
| 320 |
erfu_relPat='[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)' |
| 321 |
fi |
| 322 |
erfu_sfxPat='.*$' |
| 323 |
erfu_proj=`extractProjFromURL $erfu_URL` |
| 324 |
case "$erfu_URL" in |
| 325 |
*/Data/releases/* ) |
| 326 |
erfu_pfxPat='svn/Data/[^/][^/]*/' |
| 327 |
;; |
| 328 |
*/ThirdParty/* ) |
| 329 |
erfu_pfxPat='svn/BuildTools/ThirdParty/[^/][^/]*/[^/][^/]*/' |
| 330 |
;; |
| 331 |
*/Data/*) |
| 332 |
erfu_pfxPat='svn/Data/'$erfu_proj'/[^/][^/]*/' |
| 333 |
;; |
| 334 |
*) |
| 335 |
erfu_pfxPat='svn/'$erfu_proj'/[^/][^/]*/' |
| 336 |
;; |
| 337 |
esac |
| 338 |
erfu_relVer=`echo $erfu_URL | sed -n -e 's|.*/'$erfu_pfxPat$erfu_relPat$erfu_sfxPat'|\1|p'` |
| 339 |
echo "$erfu_relVer" |
| 340 |
else |
| 341 |
echo "-1" |
| 342 |
fi |
| 343 |
} |
| 344 |
|
| 345 |
# Now some functions to locate the highest-numbered stable or release. |
| 346 |
|
| 347 |
# Return the URL of the most recent stable branch matching the parameters. |
| 348 |
# A value of -1 for major version is interpreted as `highest number' |
| 349 |
# Returns an empty string if no suitable stable branch exists. |
| 350 |
# usage: stableURL=`bestStable <URL> <major>` |
| 351 |
|
| 352 |
bestStable () |
| 353 |
{ bstb_URL=$1 |
| 354 |
bstb_majVer=$2 |
| 355 |
|
| 356 |
# Construct a URL to send to the repository to list the stable branches. |
| 357 |
|
| 358 |
bstb_baseURL=`extractBaseURL $bstb_URL` |
| 359 |
bstb_proj=`extractProjFromURL $bstb_URL` |
| 360 |
|
| 361 |
case "$bstb_URL" in |
| 362 |
*/Data/trunk/* ) |
| 363 |
bstb_listURL=$bstb_baseURL/Data/stable |
| 364 |
;; |
| 365 |
*/Data/* ) |
| 366 |
bstb_listURL=$bstb_baseURL/Data/$bstb_proj/stable |
| 367 |
;; |
| 368 |
*/ThirdParty/* ) |
| 369 |
bstb_listURL=$bstb_baseURL/BuildTools/ThirdParty/$bstb_proj/stable |
| 370 |
;; |
| 371 |
* ) |
| 372 |
bstb_listURL=$bstb_baseURL/$bstb_proj/stable |
| 373 |
;; |
| 374 |
esac |
| 375 |
|
| 376 |
bstb_rawls=`svn list $bstb_listURL | sort -nr -t. -k1,1 -k2,2` |
| 377 |
|
| 378 |
# echo "Raw ls: $bstb_rawls" |
| 379 |
|
| 380 |
# Filter the list of stable branches to remove any that do not match the |
| 381 |
# requested major version. Note that there's a / at the end of each URL. |
| 382 |
|
| 383 |
if test "$bstb_majVer" = "-1" ; then |
| 384 |
bstb_verPat='[0-9][0-9.]*/' |
| 385 |
elif expr "$bstb_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 386 |
bstb_verPat=$bstb_majVer'/' |
| 387 |
else |
| 388 |
bstb_verPat=$bstb_majVer'\.[0-9][0-9]*' |
| 389 |
fi |
| 390 |
bstb_filter= |
| 391 |
for bstb_ver in $bstb_rawls ; do |
| 392 |
if expr "$bstb_ver" : "$bstb_verPat" >/dev/null 2>&1 ; then |
| 393 |
bstb_filter="$bstb_filter $bstb_ver" |
| 394 |
fi |
| 395 |
done |
| 396 |
|
| 397 |
# echo "Filtered ls: $bstb_filter" |
| 398 |
|
| 399 |
# If there are any candidates left ... |
| 400 |
|
| 401 |
bstb_bestURL= |
| 402 |
if test -n "$bstb_filter" ; then |
| 403 |
|
| 404 |
# If we're dealing with old-style Data, we have to work a bit harder |
| 405 |
# to find our project. See if any of the filtered candidates contain |
| 406 |
# the correct project. |
| 407 |
|
| 408 |
case "$bstb_URL" in |
| 409 |
*/Data/trunk/* | */Data/stable/* | */Data/releases/* ) |
| 410 |
bstb_projPat='.*'$bstb_proj'/.*' |
| 411 |
# echo "Pattern: $bstb_projPat" |
| 412 |
for bstb_ver in $bstb_filter ; do |
| 413 |
if expr "$bstb_ver" : "$bstb_verPat" >/dev/null 2>&1 ; then |
| 414 |
# echo " url: $bstb_listURL/$bstb_ver" |
| 415 |
bstb_svnls2="`svn list $bstb_listURL/$bstb_ver`" |
| 416 |
# echo " result: $bstb_svnls2" |
| 417 |
if expr "$bstb_svnls2" : "$bstb_projPat" >/dev/null 2>&1 ; then |
| 418 |
bstb_best=$bstb_ver |
| 419 |
# echo " best: $bstb_best" |
| 420 |
break |
| 421 |
fi |
| 422 |
fi |
| 423 |
done |
| 424 |
bstb_bestURL=$bstb_listURL/$bstb_best$bstb_proj |
| 425 |
;; |
| 426 |
*) |
| 427 |
bstb_bestURL=`echo $bstb_filter | sed -n -e 's|\([^/]*/\).*$|\1|p'` |
| 428 |
bstb_bestURL=$bstb_listURL/$bstb_bestURL |
| 429 |
;; |
| 430 |
esac |
| 431 |
fi |
| 432 |
|
| 433 |
echo $bstb_bestURL |
| 434 |
} |
| 435 |
|
| 436 |
# Return the URL of the most recent release matching the parameters. Returns |
| 437 |
# null if no suitable release exists. |
| 438 |
# A value of -1 for major or minor version is interpreted as `highest number' |
| 439 |
# A value of -1 for major version means that minor version is ignored. |
| 440 |
# usage: releaseURL=`bestRelease <URL> <major> <minor>` |
| 441 |
|
| 442 |
bestRelease () |
| 443 |
{ bstb_URL=$1 |
| 444 |
bstb_majVer=$2 |
| 445 |
bstb_minVer=$3 |
| 446 |
|
| 447 |
# Construct a URL to send to the repository to list the releases. |
| 448 |
|
| 449 |
bstb_baseURL=`extractBaseURL $bstb_URL` |
| 450 |
bstb_proj=`extractProjFromURL $bstb_URL` |
| 451 |
|
| 452 |
case "$bstb_URL" in |
| 453 |
*/Data/* ) |
| 454 |
bstb_listURL=$bstb_baseURL/Data/$bstb_proj/releases |
| 455 |
;; |
| 456 |
*/ThirdParty/* ) |
| 457 |
bstb_listURL=$bstb_baseURL/BuildTools/ThirdParty/$bstb_proj/releases |
| 458 |
;; |
| 459 |
* ) |
| 460 |
bstb_listURL=$bstb_baseURL/$bstb_proj/releases |
| 461 |
;; |
| 462 |
esac |
| 463 |
|
| 464 |
bstb_rawls=`svn list $bstb_listURL | sort -nr -t. -k1,1 -k2,2 -k3,3` |
| 465 |
|
| 466 |
# echo "Raw ls: $bstb_rawls" |
| 467 |
|
| 468 |
# Filter the list of releases to remove any that do not match the |
| 469 |
# requested major and minor version. |
| 470 |
|
| 471 |
if expr "$bstb_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 472 |
isCppAD=yes |
| 473 |
else |
| 474 |
isCppAD=no |
| 475 |
fi |
| 476 |
|
| 477 |
if test "$bstb_majVer" = "-1" ; then |
| 478 |
bstb_verPat='[0-9][0-9.]*/' |
| 479 |
else |
| 480 |
bstb_verPat=$bstb_majVer |
| 481 |
if test $isCppAD = no && |
| 482 |
test "$bstb_minVer" != "-1" ; then |
| 483 |
bstb_verPat="${bstb_verPat}\.$bstb_minVer" |
| 484 |
fi |
| 485 |
bstb_verPat="${bstb_verPat}"'\.[0-9][0-9]*/' |
| 486 |
fi |
| 487 |
|
| 488 |
# echo "Version pattern: $bstb_verPat" |
| 489 |
bstb_filter= |
| 490 |
for bstb_ver in $bstb_rawls ; do |
| 491 |
if expr "$bstb_ver" : "$bstb_verPat" >/dev/null 2>&1 ; then |
| 492 |
bstb_filter="$bstb_filter $bstb_ver" |
| 493 |
fi |
| 494 |
done |
| 495 |
|
| 496 |
# echo "Filtered ls: $bstb_filter" |
| 497 |
|
| 498 |
# If there are any candidates left ... |
| 499 |
|
| 500 |
bstb_bestURL= |
| 501 |
if test -n "$bstb_filter" ; then |
| 502 |
|
| 503 |
# If we're dealing with old-style Data, we have to work a bit harder to find our |
| 504 |
# project. See if any of the filtered candidates contain the correct |
| 505 |
# project. |
| 506 |
|
| 507 |
case "$bstb_URL" in |
| 508 |
*/Data/trunk/* | */Data/stable/* | */Data/releases/* ) |
| 509 |
bstb_projPat='.*'$bstb_proj'/.*' |
| 510 |
# echo "Pattern: $bstb_projPat" |
| 511 |
for bstb_ver in $bstb_filter ; do |
| 512 |
if expr "$bstb_ver" : "$bstb_verPat" >/dev/null 2>&1 ; then |
| 513 |
# echo " url: $bstb_listURL/$bstb_ver" |
| 514 |
bstb_svnls2="`svn list $bstb_listURL/$bstb_ver`" |
| 515 |
# echo " result: $bstb_svnls2" |
| 516 |
if expr "$bstb_svnls2" : "$bstb_projPat" >/dev/null 2>&1 ; then |
| 517 |
bstb_best=$bstb_ver |
| 518 |
# echo " best: $bstb_best" |
| 519 |
break |
| 520 |
fi |
| 521 |
fi |
| 522 |
done |
| 523 |
bstb_bestURL=$bstb_listURL/$bstb_best$bstb_proj |
| 524 |
;; |
| 525 |
*) |
| 526 |
bstb_bestURL=`echo $bstb_filter | sed -n -e 's|\([^/]*/\).*$|\1|p'` |
| 527 |
bstb_bestURL=$bstb_listURL/$bstb_bestURL |
| 528 |
;; |
| 529 |
esac |
| 530 |
|
| 531 |
fi |
| 532 |
|
| 533 |
echo $bstb_bestURL |
| 534 |
} |
| 535 |
|
| 536 |
# Count the total number of stable branches for the project for the specified |
| 537 |
# major version number, up to the specified minor version number (libtool age). |
| 538 |
# Returns 0 if handed a trunk url, or if the url is BuildTools itself. |
| 539 |
# usage: calcLibtoolAge <svnURL> <major> <minor> |
| 540 |
|
| 541 |
calcLibtoolAge () |
| 542 |
{ cltc_URL=$1 |
| 543 |
cltc_majVer=$2 |
| 544 |
cltc_minVer=$3 |
| 545 |
|
| 546 |
# Construct a URL to send to the repository to list the stable branches. |
| 547 |
|
| 548 |
cltc_baseURL=`extractBaseURL $cltc_URL` |
| 549 |
cltc_proj=`extractProjFromURL $cltc_URL` |
| 550 |
|
| 551 |
case "$cltc_URL" in |
| 552 |
*/Data/* ) |
| 553 |
cltc_listURL=$cltc_baseURL/Data/$cltc_proj/stable |
| 554 |
;; |
| 555 |
*/ThirdParty/* ) |
| 556 |
cltc_listURL=$cltc_baseURL/BuildTools/ThirdParty/$cltc_proj/stable |
| 557 |
;; |
| 558 |
*/BuildTools/* ) |
| 559 |
cltc_listURL= |
| 560 |
;; |
| 561 |
* ) |
| 562 |
cltc_listURL=$cltc_baseURL/$cltc_proj/stable |
| 563 |
;; |
| 564 |
esac |
| 565 |
|
| 566 |
# Run an ls and filter for standard stable branches (M.m or YYYYMMDD) |
| 567 |
|
| 568 |
if test -n "$cltc_listURL" ; then |
| 569 |
cltc_rawls=`svn list $cltc_listURL | sed -n -e '/[0-9][0-9.]/p'` |
| 570 |
|
| 571 |
# echo "Raw ls: $cltc_rawls" |
| 572 |
|
| 573 |
# Filter the list of stable branches to remove any that do not match the |
| 574 |
# requested major version. |
| 575 |
|
| 576 |
if expr "$cltc_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then |
| 577 |
cltc_verPat=$cltc_majVer |
| 578 |
else |
| 579 |
cltc_verPat=$cltc_majVer'\.[0-9][0-9]*/' |
| 580 |
fi |
| 581 |
cltc_majfilter= |
| 582 |
for cltc_ver in $cltc_rawls ; do |
| 583 |
if expr "$cltc_ver" : "$cltc_verPat" >/dev/null 2>&1 ; then |
| 584 |
cltc_majfilter="$cltc_majfilter $cltc_ver" |
| 585 |
fi |
| 586 |
done |
| 587 |
|
| 588 |
# echo "Filtered ls (major version): $cltc_majfilter" |
| 589 |
|
| 590 |
# For the specific major version, filter the list that matched on major |
| 591 |
# version to remove any that exceed the minor version. |
| 592 |
|
| 593 |
cltc_minfilter= |
| 594 |
for cltc_ver in $cltc_majfilter ; do |
| 595 |
cltc_min=`echo $cltc_ver | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/'` |
| 596 |
if expr $cltc_min '<=' $cltc_minVer >/dev/null 2>&1 ; then |
| 597 |
cltc_minfilter="$cltc_minfilter $cltc_ver" |
| 598 |
fi |
| 599 |
done |
| 600 |
|
| 601 |
# echo "Filtered ls (minor version): $cltc_minfilter" |
| 602 |
|
| 603 |
cltc_cnt=`echo $cltc_minfilter | wc -w | sed -e 's/ //g'` |
| 604 |
else |
| 605 |
cltc_cnt=0 |
| 606 |
fi |
| 607 |
|
| 608 |
echo $cltc_cnt |
| 609 |
} |
| 610 |
|
| 611 |
# Count the total number of stable branches for the project up to the |
| 612 |
# specified major.minor version number (libtool current). Returns 0 if |
| 613 |
# handed a trunk url, or if the url is BuildTools itself. |
| 614 |
# usage: calcLibtoolCurrent <svnURL> <major> <minor> |
| 615 |
|
| 616 |
calcLibtoolCurrent () |
| 617 |
{ cltc_URL=$1 |
| 618 |
cltc_majVer=$2 |
| 619 |
cltc_minVer=$3 |
| 620 |
|
| 621 |
# Construct a URL to send to the repository to list the stable branches. |
| 622 |
|
| 623 |
cltc_baseURL=`extractBaseURL $cltc_URL` |
| 624 |
cltc_proj=`extractProjFromURL $cltc_URL` |
| 625 |
|
| 626 |
case "$cltc_URL" in |
| 627 |
*/Data/* ) |
| 628 |
cltc_listURL=$cltc_baseURL/Data/$cltc_proj/stable |
| 629 |
;; |
| 630 |
*/ThirdParty/* ) |
| 631 |
cltc_listURL=$cltc_baseURL/BuildTools/ThirdParty/$cltc_proj/stable |
| 632 |
;; |
| 633 |
*/BuildTools/* ) |
| 634 |
cltc_listURL= |
| 635 |
;; |
| 636 |
* ) |
| 637 |
cltc_listURL=$cltc_baseURL/$cltc_proj/stable |
| 638 |
;; |
| 639 |
esac |
| 640 |
|
| 641 |
# Run an ls and filter for standard stable branches (M.m or YYYYMMDD) |
| 642 |
|
| 643 |
if test -n "$cltc_listURL" ; then |
| 644 |
cltc_rawls=`svn list $cltc_listURL | sed -n -e '/[0-9][0-9.]/p'` |
| 645 |
|
| 646 |
# echo "Raw ls: $cltc_rawls" |
| 647 |
|
| 648 |
# Filter the list of stable branches to find those with standard version |
| 649 |
# numbers. |
| 650 |
|
| 651 |
cltc_verPat='[0-9][0-9.]*/' |
| 652 |
|
| 653 |
cltc_stdfilter= |
| 654 |
for cltc_ver in $cltc_rawls ; do |
| 655 |
if expr "$cltc_ver" : "$cltc_verPat" >/dev/null 2>&1 ; then |
| 656 |
cltc_stdfilter="$cltc_stdfilter $cltc_ver" |
| 657 |
fi |
| 658 |
done |
| 659 |
|
| 660 |
# echo "Filtered ls (standard): $cltc_stdfilter" |
| 661 |
|
| 662 |
# Filter to remove major versions that exceed the specified version. |
| 663 |
|
| 664 |
cltc_majfilter= |
| 665 |
for cltc_ver in $cltc_stdfilter ; do |
| 666 |
cltc_maj=`echo $cltc_ver | sed -e 's/\([0-9][0-9]*\)\.[0-9].*/\1/'` |
| 667 |
if expr $cltc_maj '<=' $cltc_majVer >/dev/null 2>&1 ; then |
| 668 |
cltc_majfilter="$cltc_majfilter $cltc_ver" |
| 669 |
fi |
| 670 |
done |
| 671 |
|
| 672 |
# echo "Filtered ls (major version): $cltc_majfilter" |
| 673 |
|
| 674 |
# For the specific major version, filter the list that matched on major |
| 675 |
# version to remove any that exceed the minor version. |
| 676 |
|
| 677 |
cltc_minfilter= |
| 678 |
cltc_verPat='s/'$cltc_majVer'\.\([0-9][0-9]*\).*/\1/' |
| 679 |
for cltc_ver in $cltc_majfilter ; do |
| 680 |
cltc_min=`echo $cltc_ver | sed -e $cltc_verPat` |
| 681 |
if test $cltc_min = $cltc_ver || \ |
| 682 |
expr $cltc_min '<=' $cltc_minVer >/dev/null 2>&1 ; then |
| 683 |
cltc_minfilter="$cltc_minfilter $cltc_ver" |
| 684 |
fi |
| 685 |
done |
| 686 |
|
| 687 |
# echo "Filtered ls (minor version): $cltc_minfilter" |
| 688 |
|
| 689 |
cltc_cnt=`echo $cltc_minfilter | wc -w | sed -e 's/ //g'` |
| 690 |
else |
| 691 |
cltc_cnt=0 |
| 692 |
fi |
| 693 |
|
| 694 |
echo $cltc_cnt |
| 695 |
} |
| 696 |
|
| 697 |
|
| 698 |
# Function to compare the versions in a pair of URLs for equality. The criteria |
| 699 |
# is that the major and minor versions match. In theory, the release should |
| 700 |
# not matter. Probably should be a parameter. |
| 701 |
# usage: compareURLVersions <url1> <url2> |
| 702 |
|
| 703 |
compareURLVersions () |
| 704 |
{ |
| 705 |
url1_major=`extractMajorFromURL $1` |
| 706 |
url1_minor=`extractMinorFromURL $1` |
| 707 |
url2_major=`extractMajorFromURL $2` |
| 708 |
url2_minor=`extractMinorFromURL $2` |
| 709 |
|
| 710 |
if test $url1_major = $url2_major && |
| 711 |
test $url1_minor = $url2_minor ; then |
| 712 |
echo "yes" |
| 713 |
else |
| 714 |
echo "no" |
| 715 |
fi |
| 716 |
} |
| 717 |
|