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