Changeset 1593 for trunk/coin-functions


Ignore:
Timestamp:
Jul 4, 2010 11:22:15 PM (11 years ago)
Author:
lou
Message:

Release scripts *_new_release rewritten for new script architecture. Upgrades
and bug fixes for coin-functions, *_new_stable, set_externals. Correctly handle
multilevel project names (e.g., CHiPPS/Alps), CppAD version numbering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin-functions

    r1563 r1593  
    99# $Id$
    1010
    11 # Functions to disassemble svn URLs and extract relevant bits. Complicated
    12 # because we have to account for trunk/stable/release and for the variant
    13 # syntax of Data and ThirdParty URLs. For your normal project, it's
     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
    1417#   https://projects.coin-or.org/svn/ProjName/trunk
    1518#   https://projects.coin-or.org/svn/ProjName/stable/M.m
    1619#   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.
    1723# For ThirdParty, it's just like a normal project, except the prefix string
    1824# is longer:
     
    4753}
    4854
    49 
    50 # Extract the project from a svn URL
     55# Determine if this is a `normal' URL, defined as not Data, ThirdParty, or
     56# BuildTools itself. ThirdParty lives in BuildTools as of 100628, so the
     57# condition is redundant. Returns yes or no.
     58# usage: isNormal=`isNormalURL $svnURL`
     59
     60isNormalURL ()
     61{ case $1 in
     62    */BuildTools/* | */ThirdParty/* | */Data/* )
     63       echo "no"
     64       ;;
     65    *) echo "yes"
     66       ;;
     67  esac
     68}
     69
     70# Extract the project from a svn URL. The trick, for `normal' projects, is to
     71# handle CHiPPS, which has CHiPPS/Alps, Bcps, Blis. We can't assume the
     72# project name does not contain '/'. The heuristic is to look for everything
     73# between svn and one of trunk, stable, releases, or end of line.
    5174# usage: projName=`extractProjFromURL $svnURL`
    5275
    5376extractProjFromURL ()
    5477{
     78  epfu_URL="$1"
    5579  epfu_projPat='\([^/][^/]*\)'
    5680  epfu_sfxPat='.*$'
    57   case "$1" in
     81  case "$epfu_URL" in
    5882    */Data/trunk/* )
    5983        epfu_pfxPat=svn/Data/trunk/
     
    6589        epfu_pfxPat=svn/BuildTools/ThirdParty/
    6690        ;;
    67     *)
    68         epfu_pfxPat=svn/
    69         ;;
    70   esac
    71   epfu_projName=`echo $1 | sed -n -e 's|.*/'$epfu_pfxPat$epfu_projPat$epfu_sfxPat'|\1|p'`
     91    *)  epfu_type=`extractTypeFromURL $epfu_URL`
     92        epfu_pfxPat='svn/'
     93        epfu_projPat='\(.*\)'
     94        case $epfu_type in
     95          trunk | stable | releases )
     96              epfu_sfxPat=$epfu_type'.*$'
     97              ;;
     98          * )
     99              epfu_sfxPat='$'
     100              ;;
     101        esac
     102        ;;
     103  esac
     104  epfu_projName=`echo $epfu_URL | sed -n -e 's|.*/'$epfu_pfxPat$epfu_projPat$epfu_sfxPat'|\1|p'`
     105  epfu_projName=`echo $epfu_projName | sed -e 's|/$||'`
    72106  echo "$epfu_projName"
    73107}
    74108
    75 # Extract the tail (directory) from an external URL. Relevant only for normal
    76 # projects, where the external will be a subdirectory of the project. Returns
    77 # null for Data/ThirdParty/BuildTools.
     109# Extract the tail (directory) from a URL that specifies an external. Relevant
     110# only for normal projects, where the external will be a subdirectory
     111# of the project. Returns null for Data / ThirdParty / BuildTools.
    78112# usage: projName=`extractTailFromExt $extURL`
    79113
     
    108142
    109143
     144# CppAD uses a version string of the form YYYMMDD.rr. What a pain in the ass.
     145# Hence the scattered exceptions below.
    110146# Extract the entire version string from a stable or release URL. Returns a
    111 # null string if handed a trunk URL or if there's no version in the URL.
     147# null string if handed a trunk URL or if there's no version in the URL. The
     148# version number must have at least major.minor to match.
    112149# usage: version=`extractVersionFromURL $svnURL`
    113150
    114151extractVersionFromURL ()
    115152{
    116   if expr "$1" : '.*/stable/.*' >/dev/null 2>&1 ||
    117      expr "$1" : '.*/releases/.*' >/dev/null 2>&1 ; then
    118     evfu_verPat='\([0-9.][0-9.]*\)'
     153  evfu_URL="$1"
     154  if expr "$evfu_URL" : '.*/stable/.*' >/dev/null 2>&1 ||
     155     expr "$evfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then
     156    if expr "$evfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     157      evfu_verPat='\([0-9][0-9.]*\)'
     158    else
     159      evfu_verPat='\([0-9][0-9]*\.[0-9][0-9.]*\)'
     160    fi
    119161    evfu_sfxPat='.*$'
    120     case "$1" in
     162    evfu_proj=`extractProjFromURL $evfu_URL`
     163    case "$evfu_URL" in
    121164      */Data/stable/* | */Data/releases/* )
    122165          evfu_pfxPat='svn/Data/[^/][^/]*/'
     
    126169          ;;
    127170      *)
    128           evfu_pfxPat='svn/[^/][^/]*/[^/][^/]*/'
     171          evfu_pfxPat='svn/'$evfu_proj'/[^/][^/]*/'
    129172          ;;
    130173    esac
     
    138181# Replace the entire version string from a stable or release URL. A trunk
    139182# URL will be unmodified. newRev will not be accessed unless the URL is a
    140 # release.
     183# release. The version must have at least major.minor to match.
    141184# usage: newURL=`replaceVersionInURL $oldURL $newMajor $newMinor $newRev`
     185# and just for CppAD,
     186# usage: newURL=`replaceVersionInURL $oldURL $newMajor $newRev`
    142187
    143188replaceVersionInURL ()
    144189{
     190  if expr "$1" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     191    isCppAD=yes
     192  else
     193    isCppAD=no
     194  fi
     195  if test $isCppAD = no ; then
     196    rviu_verPat='[0-9][0-9]*\.[0-9][0-9.]*'
     197  else
     198    rviu_verPat='[0-9][0-9.]*'
     199  fi
     200
    145201  if expr "$1" : '.*/stable/.*' >/dev/null 2>&1 ; then
    146     rviu_newVersion=$2.$3
     202    if test $isCppAD = no ; then
     203      rviu_newVersion=$2.$3
     204    else
     205      rviu_newVersion=$2
     206    fi
    147207  elif expr "$1" : '.*/releases/.*' >/dev/null 2>&1 ; then
    148     rviu_newVersion=$2.$3.$4
     208    if test $isCppAD = no ; then
     209      rviu_newVersion=$2.$3.$4
     210    else
     211      rviu_newVersion=$2.$3
     212    fi
    149213  else
    150214    rviu_newVersion=
     
    152216  fi
    153217  if test -n "$rviu_newVersion" ; then
    154     rviu_newURL=`echo $1 | sed -n -e 's|^\(.*\)/[0-9][0-9.]*\(.*\)$|\1/'$rviu_newVersion'\2|p'`
     218    rviu_newURL=`echo $1 | sed -n -e 's|^\(.*\)/'$rviu_verPat'\(.*\)$|\1/'$rviu_newVersion'\2|p'`
    155219  fi
    156220  echo $rviu_newURL
     
    163227extractMajorFromURL ()
    164228{
    165   if expr "$1" : '.*/stable/.*' >/dev/null 2>&1 ||
    166      expr "$1" : '.*/releases/.*' >/dev/null 2>&1 ; then
     229  ejfu_URL="$1"
     230  if expr "$ejfu_URL" : '.*/stable/.*' >/dev/null 2>&1 ||
     231     expr "$ejfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then
    167232    ejfu_majPat='\([0-9][0-9]*\)'
    168     ejfu_sfxPat='\.[0-9][0-9]*.*$'
    169     case "$1" in
     233    if expr "$ejfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     234      ejfu_sfxPat='.*$'
     235    else
     236      ejfu_sfxPat='\.[0-9][0-9]*.*$'
     237    fi
     238    ejfu_proj=`extractProjFromURL $ejfu_URL`
     239    case "$ejfu_URL" in
    170240      */Data/stable/* | */Data/releases/* )
    171241          ejfu_pfxPat='svn/Data/[^/][^/]*/'
     
    175245          ;;
    176246      *)
    177           ejfu_pfxPat='svn/[^/][^/]*/[^/][^/]*/'
     247          ejfu_pfxPat='svn/'$ejfu_proj'/[^/][^/]*/'
    178248          ;;
    179249    esac
    180     ejfu_majVer=`echo $1 | sed -n -e 's|.*/'$ejfu_pfxPat$ejfu_majPat$ejfu_sfxPat'|\1|p'`
     250    ejfu_majVer=`echo $ejfu_URL | sed -n -e 's|.*/'$ejfu_pfxPat$ejfu_majPat$ejfu_sfxPat'|\1|p'`
    181251    echo "$ejfu_majVer"
    182252  else
     
    187257# Extract the minor version number from a stable or release URL. Returns -1 if
    188258# handed a trunk URL or if there's no version in the URL.
     259# The CppAD form (YYYYMMDD.rr) doesn't have a minor version number.
    189260# usage: minVer=`extractMinorFromURL $svnURL`
    190261
    191262extractMinorFromURL ()
    192263{
    193   if expr "$1" : '.*/stable/.*' >/dev/null 2>&1 ||
    194      expr "$1" : '.*/releases/.*' >/dev/null 2>&1 ; then
     264  emfu_URL="$1"
     265  if expr "$emfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     266    echo "-1"
     267  elif expr "$emfu_URL" : '.*/stable/.*' >/dev/null 2>&1 ||
     268       expr "$emfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then
    195269    emfu_minPat='[0-9][0-9]*\.\([0-9][0-9]*\)'
    196270    emfu_sfxPat='.*$'
    197     case "$1" in
     271    emfu_proj=`extractProjFromURL $emfu_URL`
     272    case "$emfu_URL" in
    198273      */Data/stable/* | */Data/releases/* )
    199274          emfu_pfxPat='svn/Data/[^/][^/]*/'
     
    203278          ;;
    204279      *)
    205           emfu_pfxPat='svn/[^/][^/]*/[^/][^/]*/'
     280          emfu_pfxPat='svn/'$emfu_proj'/[^/][^/]*/'
    206281          ;;
    207282    esac
    208     emfu_minVer=`echo $1 | sed -n -e 's|.*/'$emfu_pfxPat$emfu_minPat$emfu_sfxPat'|\1|p'`
     283    emfu_minVer=`echo $emfu_URL | sed -n -e 's|.*/'$emfu_pfxPat$emfu_minPat$emfu_sfxPat'|\1|p'`
    209284    echo "$emfu_minVer"
    210285  else
     
    219294extractReleaseFromURL ()
    220295{
    221   if expr "$1" : '.*/releases/.*' >/dev/null 2>&1 ; then
    222     erfu_relPat='[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)'
     296  erfu_URL="$1"
     297  if expr "$erfu_URL" : '.*/releases/.*' >/dev/null 2>&1 ; then
     298    if expr "$erfu_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     299      erfu_relPat='[0-9][0-9]*\.\([0-9][0-9]*\)'
     300    else
     301      erfu_relPat='[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)'
     302    fi
    223303    erfu_sfxPat='.*$'
    224     case "$1" in
     304    erfu_proj=`extractProjFromURL $erfu_URL`
     305    case "$erfu_URL" in
    225306      */Data/releases/* )
    226307          erfu_pfxPat='svn/Data/[^/][^/]*/'
     
    230311          ;;
    231312      *)
    232           erfu_pfxPat='svn/[^/][^/]*/[^/][^/]*/'
     313          erfu_pfxPat='svn/'$erfu_proj'/[^/][^/]*/'
    233314          ;;
    234315    esac
    235     erfu_relVer=`echo $1 | sed -n -e 's|.*/'$erfu_pfxPat$erfu_relPat$erfu_sfxPat'|\1|p'`
     316    erfu_relVer=`echo $erfu_URL | sed -n -e 's|.*/'$erfu_pfxPat$erfu_relPat$erfu_sfxPat'|\1|p'`
    236317    echo "$erfu_relVer"
    237318  else
     
    244325# Return the URL of the most recent stable branch matching the parameters.
    245326# A value of -1 for major or minor version is interpreted as `highest number'
     327# Returns an empty string if no suitable stable branch exists.
    246328# usage: stableURL=`bestStable <URL> <major>`
    247329
     
    272354
    273355  # Filter the list of stable branches to remove any that do not match the
    274   # requested major version.
    275 
    276   bstb_verPat='[0-9][0-9]*/'
    277   if test "$bstb_majVer" != "-1" ; then
     356  # requested major version. Note that there's a / at the end of each URL.
     357
     358  if test "$bstb_majVer" = "-1" ; then
     359    bstb_verPat='[0-9][0-9.]*/'
     360  elif expr "$bstb_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     361    bstb_verPat=$bstb_majVer'/'
     362  else
    278363    bstb_verPat=$bstb_majVer'\.[0-9][0-9]*'
    279   else
    280     bstb_verPat='[0-9][0-9.]*'
    281364  fi
    282365  bstb_filter=
     
    324407}
    325408
    326 # Return the URL of the most recent release matching the parameters.
     409# Return the URL of the most recent release matching the parameters. Returns
     410# null if no suitable release exists.
    327411# A value of -1 for major or minor version is interpreted as `highest number'
     412# A value of -1 for major version means that minor version is ignored.
    328413# usage: releaseURL=`bestRelease <URL> <major> <minor>`
    329414
     
    357442  # requested major and minor version.
    358443
    359   if test "$bstb_majVer" != "-1" ; then
    360     bstb_verPat=$bstb_majVer'\.'
    361   else
    362     bstb_verPat='[0-9][0-9]*\.'
    363   fi
    364   if test "$bstb_minVer" != "-1" ; then
    365     bstb_verPat="${bstb_verPat}$bstb_minVer"
    366   else
    367     bstb_verPat="${bstb_verPat}"'[0-9][0-9]*'
    368   fi
    369   bstb_verPat="${bstb_verPat}"'\.[0-9][0-9]*'
     444  if expr "$bstb_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     445    isCppAD=yes
     446  else
     447    isCppAD=no
     448  fi
     449
     450  if test "$bstb_majVer" = "-1" ; then
     451    bstb_verPat='[0-9][0-9.]*/'
     452  else
     453    bstb_verPat=$bstb_majVer
     454    if test $isCppAD = no &&
     455       test "$bstb_minVer" != "-1" ; then
     456      bstb_verPat="${bstb_verPat}\.$bstb_minVer"
     457    fi
     458    bstb_verPat="${bstb_verPat}"'\.[0-9][0-9]*/'
     459  fi
     460
    370461  # echo "Version pattern: $bstb_verPat"
    371462  bstb_filter=
     
    443534  esac
    444535
    445   # Run an ls and filter for standard stable branches (M.m)
     536  # Run an ls and filter for standard stable branches (M.m or YYYYMMDD)
     537
    446538  if test -n "$cltc_listURL" ; then
    447     cltc_rawls=`svn list $cltc_listURL | sed -n -e '/[0-9]\.[0-9]/p'`
     539    cltc_rawls=`svn list $cltc_listURL | sed -n -e '/[0-9][0-9.]/p'`
    448540
    449541    # echo "Raw ls: $cltc_rawls"
     
    452544    # requested major version. -1 means `any major version', hence no filter.
    453545
    454     cltc_verPat='[0-9][0-9]*/'
    455546    if test "$cltc_majVer" != "-1" ; then
    456       cltc_verPat=$cltc_majVer'\.[0-9][0-9]*'
     547      if expr "$cltc_URL" : '.*/CppAD/.*' >/dev/null 2>&1 ; then
     548        cltc_verPat=$cltc_majVer
     549      else
     550        cltc_verPat=$cltc_majVer'\.[0-9][0-9]*'
     551      fi
    457552    else
    458553      cltc_verPat='[0-9][0-9.]*'
     
    475570}
    476571
    477 # Count the total number of stable branches (libtool current). See comments
    478 # above for calcLibtoolAge.
    479 # usage: calcLibtoolCurrent <url>
    480 calcLibtoolCurrent ()
    481 { calcLibtoolAge $1 -1
    482 }
    483 
     572# Function to compare the versions in a pair of URLs for equality. The criteria
     573# is that the major and minor versions match. In theory, the release should
     574# not matter. Probably should be a parameter.
     575# usage: compareURLVersions <url1> <url2>
     576
     577compareURLVersions ()
     578{
     579  url1_major=`extractMajorFromURL $1`
     580  url1_minor=`extractMinorFromURL $1`
     581  url2_major=`extractMajorFromURL $2`
     582  url2_minor=`extractMinorFromURL $2`
     583
     584  if test $url1_major = $url2_major &&
     585     test $url1_minor = $url2_minor ; then
     586    echo "yes"
     587  else
     588    echo "no"
     589  fi
     590}
     591
Note: See TracChangeset for help on using the changeset viewer.