Changeset 484 for branches


Ignore:
Timestamp:
11/11/2009 14:21:33 (3 years ago)
Author:
ccowart
Message:

Merging fix for regression on installing directories from trunk.

Resolves #86

Location:
branches/confman-1.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/confman-1.9

    • Property svn:mergeinfo changed
      /trunkmerged: 466
  • branches/confman-1.9/confman.in

    r483 r484  
    189189 
    190190function commit { 
    191     local msg status modules module modpath 
     191    local msg status modules module symlink symlinks 
    192192    local nocommit=true 
    193193    local opt OPTIND OPTARG 
     
    211211    wcopy_lock=$(conf_lock_wcopy) 
    212212     
    213     for module in $(conf_get_recipe) ; do 
    214         modpath=$(${readlink_cmd} -m ${WORK_PATH}/${module}) 
    215         modules=${modules:+${modules} }${modpath} 
     213    for module in $(conf_get_recipe); do 
     214        modules=${modules:+${modules} }${module} 
     215        for symlink in $(find ${WORK_PATH}/${module} \ 
     216            -type l -exec ${readlink_cmd} -m {} \; -print) 
     217        do 
     218            symlink=$(conf_rel_path "${symlink}") 
     219            symlinks="${symlinks:+${symlinks} }${symlink}" 
     220        done 
    216221    done 
    217222     
     
    219224    conf_update_tree || conf_cleanExit 
    220225     
    221     if status=$(get_status $modules) ; then 
     226    if status=$(get_status $modules $symlinks); then 
    222227        nocommit=false 
    223228        msg=$(get_log "$status") || conf_cleanExit 
     
    228233     
    229234    echo "Commit operation started" >&2 
    230     $nocommit || conf_commit "$(conf_get_recipe)" $msg || return $? 
     235    $nocommit || conf_commit_file $msg $modules $symlinks || return $? 
    231236    for layer in $(conf_get_recipe) ; do 
    232237        echo "Rolling on $layer..." 
     
    256261            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
    257262            F)  LOG_FILE="$OPTARG" ;; 
    258             N)  innercall=true ;; 
    259263            *)  echo "Invalid option '-${OPTARG}'." >&4 
    260264                print_usage 1 
     
    274278    $SUDO ${SUDO:+-v} 
    275279 
    276     # This stuff we only do in the top-level call, not on recursive calls... 
    277     if ! conf_lock_is_recursive $wcopy_lock ; then 
    278         conf_update_tree || conf_cleanExit 
    279         if status=$(get_status $files) ; then 
    280             nocommit=false 
    281             msg=$(get_log "$status") || conf_cleanExit 
    282             rm -f "$status" 
    283         fi 
    284         echo "Installation operation started." >&2 
    285         $nocommit || conf_commit_file "$msg" "$files" || return $? 
    286     fi 
    287      
    288     for file in "$@" ; do 
    289         for layer in $(conf_get_recipe) ; do 
    290             conf_install $layer "$@" 
    291         done 
    292         for sing in $SINGULARITIES ; do 
    293             if [ "$sing" = "$file" ] ; then 
    294                 conf_assemble_sing $file || conf_cleanExit 
    295             fi 
    296         done 
     280    conf_update_tree || conf_cleanExit 
     281    if status=$(get_status $files) ; then 
     282        nocommit=false 
     283        msg=$(get_log "$status") || conf_cleanExit 
     284        rm -f "$status" 
     285    fi 
     286    echo "Installation operation started." >&2 
     287    $nocommit || conf_commit_file "$msg" "$files" || return $? 
     288     
     289    for layer in $(conf_get_recipe) ; do 
     290        conf_install $layer "$@" 
     291    done 
     292    for file in $SINGULARITIES ; do 
     293        conf_assemble_sing $file || conf_cleanExit 
    297294    done 
    298295    conf_recordAction install 
     
    859856    wcopy_lock=$(conf_lock_wcopy) 
    860857    conf_ln $target $link $forced 
    861     conf_unlock_wcopy $(wcopy_lock) 
     858    conf_unlock_wcopy $wcopy_lock 
    862859} 
    863860 
     
    880877    wcopy_lock=$(conf_lock_wcopy) 
    881878    conf_chattr "$attr" "$value" "$@" 
    882     conf_unlock_wcopy $(wcopy_lock) 
     879    conf_unlock_wcopy $wcopy_lock 
    883880} 
    884881 
  • branches/confman-1.9/confmanlib.sh.in

    r483 r484  
    263263 
    264264    return 0 
    265 } 
    266  
    267 # Commits module $1 with message $2 
    268 function conf_commit { 
    269         local modules=$(echo $1 | tr ' ' ',') 
    270         local msg="$2" 
    271     local symlinks 
    272  
    273     # $modules is in the form foo,bar,baz. This eval trick forces 
    274     # curly brace expansion. 
    275     if echo "$modules" | grep ',' > /dev/null ; then 
    276         for module in $(eval echo ${WORK_PATH}/{$modules}); do 
    277             symlinks="$symlinks `find ${module} -type l \ 
    278                 -exec ${readlink_cmd} -m {} \;`" 
    279         done 
    280             @SVN@ commit -F "$msg" $(eval echo ${WORK_PATH}/{$modules}) \ 
    281             $symlinks 
    282     else 
    283         symlinks="$symlinks `find ${modules} -type l \ 
    284             -exec ${readlink_cmd} -m {} \;`" 
    285         @SVN@ commit -F "$msg" ${WORK_PATH}/$modules \ 
    286             $symlinks 
    287     fi 
    288265} 
    289266 
     
    474451} 
    475452 
     453function conf_livefile { 
     454    local file="$1" 
     455    local path=$(conf_rel_path "$file") || return 
     456    echo ${path#*/}/ 
     457} 
     458 
     459function conf_wfile_is_singularity { 
     460    local file=$(${readlink_cmd} -m "$1") 
     461    ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 
     462    local module=${file#${ABS_WORK}/} 
     463    module=${module%%/*} 
     464    local livefile=$(conf_livefile $file) 
     465    local sing 
     466    for sing in $SINGULARITIES ; do 
     467        if [ "$sing" = "${livefile%-$module}" ] ; then 
     468            return 0 
     469        fi 
     470    done 
     471    return 1 
     472} 
     473 
     474# Takes a file as an argument and returns the path of the file relative 
     475# to WORK_PATH/ABS_WORK 
     476function conf_rel_path { 
     477    local file="$1" 
     478    local result 
     479 
     480    if ! result=$(conf_rel_path_helper "$file") ; then 
     481        echo "$file" does not appear to be located within $WORK_PATH >&2 
     482        return 1 
     483    fi 
     484 
     485    echo ${result#/} 
     486    return 0 
     487} 
     488 
     489# Recursive helper for determining conf_rel_path 
     490function conf_rel_path_helper { 
     491    local file="$1" 
     492    local target=$(${readlink_cmd} -m "$file") 
     493    local ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 
     494    local dir rc sofar 
     495 
     496    if [ "$target" = "$ABS_WORK" ] ; then 
     497        return 0 
     498    elif [ "$file" = "/" ] ; then 
     499        return 1 
     500    else 
     501        dir=$(dirname "$file") 
     502        case "$dir" in 
     503            ".")    dir=$(pwd);; 
     504            "..")   dir=$(cd ..; pwd);; 
     505        esac 
     506        sofar=$(conf_rel_path "$dir") || return $? 
     507        printf "%s/%s" "$sofar" $(basename "$file") 
     508        return 0 
     509    fi 
     510} 
     511 
    476512function conf_install { 
     513    conf_debug conf_install called with args "$@" 
     514    ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 
    477515        local module="$1" 
    478         shift 
    479         local file=`$ABSPATH $1` 
    480         shift 
    481         local moduledir="${WORK_PATH}/$module" 
    482         local livefile=`echo "$file" | ${sed_cmd} -e "s:${WORK_PATH}/[^/]+::"` 
    483         local pathmodule=`echo "$file" | ${sed_cmd} -e "s:${WORK_PATH}/([^/]+).*:\1:"` 
    484         local suffix 
    485     local targetfile=`${readlink_cmd} -m $file` 
    486         livefile=`echo "$livefile" | ${sed_cmd} -e "s:-${pathmodule}$::"` 
    487         if [[ $SINGULARITIES =~ $livefile ]] && [ ! -d "$targetfile" ] ; then 
    488                 suffix="-${module}" 
    489         fi 
    490         livefile="${livefile}${suffix}" 
    491  
     516    local file="$2" 
     517    shift 2 
     518    local livefile 
     519    local failures=false 
     520 
     521    # Recursive base case 
     522    if [ -z "$file" ] ; then 
     523        conf_debug "conf_install base case reached" 
     524        return 0 
     525    fi 
     526 
     527    file=$(conf_rel_path "$file") || return 1 
     528    livefile="/${file#*/}" 
     529    file="${ABS_WORK}/${file}" 
    492530 
    493531        # See if it even exists 
    494         file="${moduledir}${livefile}" 
    495     targetfile=`${readlink_cmd} -m $file` 
    496         if [ ! -e "$targetfile" ] && [ -z "$1" ] ; then 
    497                 return 0 
    498         elif [ ! -f "$targetfile" ] && [ ! -d "$targetfile" ] ; then 
    499                 conf_install $module "$@" 
    500                 return 
    501         fi 
     532    if [ ! -e "$file" ] ; then 
     533        conf_debug "$file" does not appear to exist 
     534        conf_install $module "$@" 
     535        return 1 
     536    fi 
    502537 
    503538        # If we got here, figure it out 
     
    507542    local symlink="`conf_get_prop ${file} symlink`" 
    508543 
    509     file="$targetfile" 
    510544        if [ -f "$file" ] ; then 
    511545                local opts="-o $owner -g $group -m $mode" 
     
    520554    fi 
    521555 
    522         ${NFS_HACK:-false} && chmod o+rx ${WORK_PATH} 
     556        ${NFS_HACK:-false} && chmod o+rx ${ABS_WORK} 
    523557        echo $cmd 
    524         $cmd 
    525         ${NFS_HACK:-false} && chmod o-rx ${WORK_PATH} 
     558        $cmd || failures=true 
     559        ${NFS_HACK:-false} && chmod o-rx ${ABS_WORK} 
    526560 
    527561    if [ -d "$file" ] ; then 
    528         conf_install $module "$file"/* 
    529     fi 
    530         if [ ! -z $1 ] ; then 
    531                 conf_install $module "$@" 
    532         fi 
    533 } 
    534  
     562        conf_debug "conf_install encountered a directory. Recursing." 
     563        conf_install $module $(find "$file" \ 
     564            -mindepth 1 -maxdepth 1 -not -name '.svn') || failures=true 
     565    fi 
     566    conf_debug "conf_install recursing" 
     567        conf_install $module "$@" || failures=true 
     568    conf_debug "conf_install returning" 
     569    if $failures ; then  
     570        return 1 
     571    else 
     572        return 0 
     573    fi 
     574} 
    535575 
    536576function conf_list { 
Note: See TracChangeset for help on using the changeset viewer.