Changeset 28046

Show
Ignore:
Timestamp:
14.08.2013 21:30:02 (6 years ago)
Author:
ak19
Message:

Committing an intermediate version of the gen-model-colls script, which has some useful sections of code for future use, before committing the completely overhauled version of the same script file (currently being tested)

Files:
1 modified

Legend:

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

    r28037 r28046  
    7777    return; 
    7878    fi 
     79 
     80# return here if just deleting empty dirs 
     81#return 
    7982 
    8083    # diff the svn model and rebuilt model collections 
     
    117120 
    118121    # Now svn remove what's unique to model-collect and svn add what's been rebuilt in index and archives 
    119     # see # http://stackoverflow.com/questions/7502261/delete-folder-content-and-remove-from-version-control 
    120   
     122    # see http://stackoverflow.com/questions/7502261/delete-folder-content-and-remove-from-version-control 
     123    # And doing: rm -rfv mydir/* should leave .hidden folders in mydir, see 
     124    # http://askubuntu.com/questions/72446/how-to-remove-all-files-and-subdirectories-in-a-directory-without-deleting-the-d 
    121125    if [ "$mode" == "svndelete" ]; then 
    122126    svn rm model-collect/$collection/archives/* 
    123127    svn rm model-collect/$collection/index/* 
    124     fi 
     128#   rm -rfv model-collect/$collection/archives/* 
     129#   rm -rfv model-collect/$collection/index/*    
     130    # from testing, the above will remove all the contents of archives and index  
     131    # except the .svn folder of toplevel archives/index 
     132    fi 
     133 
     134    # http://stackoverflow.com/questions/5044214/how-do-i-detect-and-or-delete-empty-subversion-directories 
     135    # http://stackoverflow.com/questions/1301203/removing-svn-files-from-all-directories 
    125136 
    126137    # copy across the contents of the rebuilt model-collection's index and archives to the svn model-collect 
     
    139150 
    140151    # if etc/collect.cfg is different, copy it across too? 
    141  
    142  
    143152} 
     153 
    144154 
    145155# re-build a single collection in "collect" which is a copy of model-collect 
     
    152162    #get just the basename 
    153163    collection=`basename $collection` 
     164 
     165    # clean up empty directories: 
     166    # HASH dirs that are empty in local (non-svn) collect's archives and index/assoc,  
     167    # need to be removed from the svn in model-collect.  
     168    # They're almost empty in the mode-collect, except for the .svn folder they contain 
     169 
     170    for coldir in `find collect/$collection/archives/HASH* -type d -empty`; do 
     171    modeldir="model-$coldir" 
     172    echo "Removing empty dir from svn: $modeldir" 
     173     
     174    # remove from svn of model collect 
     175    svn rm $modeldir 
     176    rm -rf $modeldir 
     177    # remove physically from local collect (not necessary, as a rebuild will sort this out too) 
     178    rm -rf $coldir 
     179    done 
     180 
     181    for coldir in `find collect/$collection/index/assoc/HASH* -type d -empty`; do 
     182    modeldir="model-$coldir" 
     183    echo "Removing empty dir from svn: $modeldir" 
     184     
     185    # remove from svn of model collect 
     186    svn rm $modeldir 
     187    rm -rf $modeldir 
     188    # remove physically from local collect (not necessary, as a rebuild will sort this out too) 
     189    rm -rf $coldir 
     190    done 
    154191     
    155192    import.pl -removeold $collection 
     
    304341 
    305342 
     343# Now delete all empty dirs in the copy of model-collect (since the dirs will not have .svn folders in them anymore) 
     344# http://www.commandlinefu.com/commands/view/5131/recursively-remove-all-empty-directories 
     345#find collect -type d -empty -delete 
     346 
    306347# Set up the Greenstone environment for building 
    307348source setup.bash 
     
    317358    single_collection $collection; 
    318359    if [ "x$mode" != "x" ]; then 
     360        # Now delete all empty dirs in the copy of model-collect (since the dirs will not have .svn folders in them anymore) 
     361            # http://www.commandlinefu.com/commands/view/5131/recursively-remove-all-empty-directories 
     362#       find collect/$collection/archives/HASH* -type d -empty -delete 
     363#       find collect/$collection/index/assoc/HASH* -type d -empty -delete 
    319364        update_single_collection $collection $mode; 
    320365    fi 
     
    329374        single_collection $collection; 
    330375        if [ "x$mode" != "x" ]; then 
     376#       find collect/$collection/archives/HASH* -type d -empty -delete 
     377#       find collect/$collection/index/assoc/HASH* -type d -empty -delete 
    331378        update_single_collection $collection $mode; 
    332379        fi 
     
    358405 
    359406 
     407# The following in a separate script file will delete all folders from model-collect that are 
     408# empty in the copied collection (all folders which contain only a .svn subfolder in model-collect) 
     409 
     410#for collection in collect/*; do 
     411    #escape the filename (in case of space) 
     412#    collection=`echo $collection | sed 's@ @\\\ @g'` 
     413     
     414    #get just the basename 
     415#    collection=`basename $collection` 
     416 
     417    # HASH dirs that are empty in local collect's archives and index/assoc,  
     418    # need to be removed from the svn in model-collect 
     419 
     420#    for line in `find collect/$collection/archives/HASH* -type d -empty`; do 
     421#   modelline="model-$line" 
     422#   echo "LINE: $modelline" 
     423     
     424    # remove from svn of model collect 
     425#   svn rm $modelline 
     426##  rm -rf $modelline 
     427    # remove physically from local collect 
     428#   rm -rf $line 
     429#    done 
     430 
     431#    for line in `find collect/$collection/index/assoc/HASH* -type d -empty`; do 
     432#   modelline="model-$line" 
     433#   echo "LINE: $modelline" 
     434     
     435    # remove from svn of model collect 
     436#   svn rm $modelline 
     437##  rm -rf $modelline 
     438    # remove physically from local collect 
     439#   rm -rf $line 
     440#    done 
     441 
     442#done