Changeset 28074

Show
Ignore:
Timestamp:
16.08.2013 14:45:43 (6 years ago)
Author:
ak19
Message:

Adding in the svnaddnew cmdline option to add new collections to the model-collections on svn. Untested as yet.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh

    r28073 r28074  
    100100} 
    101101 
     102function svn_add_new_collection () { 
     103 
     104    collection=$1 
     105 
     106    #escape the filename (in case of space) and get just the basename 
     107    collection=$(get_col_basename $collection) 
     108 
     109    if [ -e model-collect/$collection ];then 
     110    echo "svn_add_new_collection: $collection already exists in model-collect, can't add it to svn." 
     111    return 
     112    fi 
     113 
     114    find collect/$collection -name ".svn" -type d -exec rm -rf {} \; 
     115    cp -r collect/$collection model-collect/$collection 
     116    svn add model-collect/$collection     
     117} 
    102118 
    103119# Function that handles the --svndelete flag (mode) of this script for a single collection 
     
    346362# http://blog.onetechnical.com/2012/07/16/bash-getopt-versus-getopts/ 
    347363# Execute getopt 
    348 ARGS=$(getopt -o m:uxdh -l "message:,svnupdate,svndelete,debug,help" -n "$0" -- "$@"); 
     364ARGS=$(getopt -o m:uxadh -l "message:,svnupdate,svndelete,svnaddnew,debug,help" -n "$0" -- "$@"); 
    349365 
    350366#Bad arguments 
     
    365381      exit 0 
    366382      ;; 
     383    -a|--svnaddnew) 
     384      shift; 
     385      if [ "x$mode" == "xsvnupdate" ] || [ "x$mode" == "xsvndelete" ]; then 
     386      echo 
     387      echo "Can't use both svnaddnew and svndelete/svnupdate" 
     388      usage 
     389      exit 1 
     390      else 
     391      mode=svnaddnew 
     392#     echo "svnaddnew not yet implemented" 
     393#     exit 0 
     394      fi 
     395      ;; 
    367396    -x|--svndelete) 
    368397      shift; 
    369       if [ "x$mode" == "xsvnupdate" ]; then 
     398      if [ "x$mode" == "xsvnupdate" ] || [ "x$mode" == "xsvnaddnew" ]; then 
    370399      echo 
    371       echo "Can't use both svndelete and svnupdate" 
     400      echo "Can't use both svndelete and svnupdate/svnaddnew" 
    372401      usage 
    373402      exit 1 
     
    378407    -u|--svnupdate) 
    379408      shift; 
    380       if [ "x$mode" == "xsvndelete" ]; then 
     409      if [ "x$mode" == "xsvndelete" ] || [ "x$mode" == "xsvnaddnew" ]; then 
    381410      echo 
    382       echo "Can't use both svndelete and svnupdate" 
     411      echo "Can't use both svnupdate and svndelete/svnaddnew" 
    383412      usage 
    384413      exit 1 
     
    441470 
    442471# move the existing collect folder out of the way 
    443 if [ -e collect ] && [ ! -e collect_orig ] ; then 
     472# unless we are adding a new collection to svn, in which case, we'll grab them from whatever collect folder exists 
     473if [ "x$mode" != "xsvnaddnew" ] && [ -e collect ] && [ ! -e collect_orig ]; then 
    444474    mv collect collect_orig 
    445475fi 
     
    464494# (or if collections are specified in the cmdline arguments, copy just these over from model-collect into collect) 
    465495# Then remove the copy's .svn folders 
    466 echo "***********************************************" 
    467 echo "Creating a copy of the model-collect folder as folder collect and removing the .svn subfolders from the copy:" 
    468 echo 
    469 if [ -e collect_orig ]; then 
     496if [ "x$mode" != "xsvnaddnew" ] && [ -e collect_orig ]; then 
     497 
     498    echo "***********************************************" 
     499    echo "Creating a copy of the model-collect folder as folder collect and removing the .svn subfolders from the copy:" 
     500    echo 
     501 
    470502    if [ ! -e collect ]; then 
    471503    cp -r model-collect collect  
     
    486518    fi 
    487519    fi 
    488 fi 
    489 echo "***********************************************" 
     520    echo "***********************************************" 
     521fi 
     522 
    490523 
    491524# Set up the Greenstone environment for building 
     
    508541        if [ "x$mode" == "xsvnupdate" ]; then 
    509542        update_single_collection $collection 
     543        elif [ "x$mode" == "xsvnaddnew" ]; then 
     544        svn_add_new_collection $collection 
    510545        fi 
    511546    fi 
    512547    done 
    513548 
    514     # having rebuilt all the collections, just the processing for svndelete/update remains: 
     549    # having rebuilt all the collections, just the processing for svndelete remains: 
    515550    if [ "x$mode" == "xsvndelete" ]; then 
    516551    svn_delete 
     
    531566        if [ "x$mode" == "xsvnupdate" ]; then 
    532567            update_single_collection $collection 
     568        elif [ "x$mode" == "xsvnaddnew" ]; then 
     569            svn_add_new_collection $collection 
    533570        fi 
    534571        fi 
    535572    else 
     573        echo 
    536574        echo "Can't find collection $collection. Skipping." 
     575        echo 
    537576    fi 
    538577    done 
    539578 
    540     # having rebuilt the specified collections above, just the processing for svndelete/update remains 
     579    # having rebuilt the specified collections above, just the processing for svndelete remains 
    541580    if [ "x$mode" == "xsvndelete" ]; then 
    542581    svn_delete $@ 
    543582    fi 
    544  
    545583fi 
    546584 
     
    566604elif [ "x$mode" == "xsvndelete" ]; then 
    567605    echo "* The model-collect folder's archives and index subfolders have been updated and committed to svn." 
     606elif [ "x$mode" == "xsvnaddnew" ]; then 
     607    echo "* The new collection(s) have been built, copied to model-collect and added to svn." 
    568608fi 
    569609echo 
     
    586626fi 
    587627 
    588 echo "* The original collect directory has been left renamed as collect_orig" 
    589 echo 
     628if [ -e collect_orig ]; then 
     629    echo "* The original collect directory has been left renamed as collect_orig" 
     630    echo 
     631fi 
    590632 
    591633if [ "$debug_mode" -eq "1" ]; then