Changeset 568


Ignore:
Timestamp:
12/16/2011 18:27:12 (5 months ago)
Author:
blee
Message:

Merge fix for #120 into confman-1.9.

Closes #120

Location:
branches/confman-1.9
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/confman-1.9

  • branches/confman-1.9/confaudit.in

    r556 r568  
    109109tmproot=$(conf_tmp_dir) 
    110110live_root="${LIVE_ROOT}" 
     111statefile=$(conf_tmp_file) 
    111112 
    112113# Override LIVE_ROOT to commit into our temporary directory. 
     
    114115 
    115116echo "Audit operation started" | conf_logger 
    116 for layer in $(conf_get_recipe) ; do 
     117for layer in $(conf_get_reverse_recipe) ; do 
    117118    echo "Rolling on $layer..." 
    118     conf_rollout $layer || conf_cleanExit 
     119    conf_rollout $layer $statefile || conf_cleanExit 
    119120done 
    120121for file in $SINGULARITIES ; do 
  • branches/confman-1.9/confman.in

    r567 r568  
    249249 
    250250function commit_full { 
    251     local msg status modules module symlink abswork files 
     251    local msg status modules module symlink abswork files statefile 
    252252    local nocommit=true 
    253253    local opt OPTIND OPTARG 
     
    272272    abswork=$(conf_abswork) 
    273273     
    274     for module in $(conf_get_recipe); do 
     274    for module in $(conf_get_reverse_recipe); do 
    275275        modules=${modules:+${modules} }${module} 
    276276        for symlink in $(find ${WORK_PATH}/${module} \ 
     
    295295    echo "Commit operation started" >&2 
    296296    $nocommit || conf_commit_file $msg $files || return $? 
    297  
    298297    update 
    299298 
    300     for layer in $(conf_get_recipe) ; do 
     299    statefile=$(conf_tmp_file) 
     300    for layer in $(conf_get_reverse_recipe) ; do 
    301301        echo "Rolling on $layer..." 
    302         conf_rollout $layer || return $? 
     302        conf_rollout $layer $statefile || return $? 
    303303    done 
    304304    for file in $SINGULARITIES ; do 
     
    329329    local opt OPTIND OPTARG 
    330330    local module 
     331    local statefile 
    331332 
    332333    while getopts ":m:F:" opt ; do 
     
    363364    update 
    364365     
    365     for layer in $(conf_get_recipe) ; do 
     366    statefile=$(conf_tmp_file) 
     367    for layer in $(conf_get_reverse_recipe) ; do 
    366368        for file in "$@"; do 
    367369            module=$(conf_wfile_module $file) 
    368370            if conf_wfile_is_singularity $file; then 
    369                 conf_install $layer "${file%-$module}-${layer}" 
     371                conf_install $layer $statefile "${file%-$module}-${layer}" 
    370372            else 
    371                 conf_install $layer "$file" 
     373                conf_install $layer $statefile "$file" 
    372374            fi 
    373375        done 
     
    832834    local checkpoint=$2 
    833835    local clock=$3 
    834     local wcopy_lock system_lock 
     836    local wcopy_lock system_lock statefile 
    835837 
    836838    if [ -z "$2" ] ; then 
     
    842844        echo "Rolling $module back to $checkpoint $clock" >&2 
    843845        conf_rollback $module $checkpoint $clock || conf_cleanExit 
    844         for layer in $(conf_get_recipe) ; do 
     846        statefile=$(conf_tmp_file) 
     847        for layer in $(conf_get_reverse_recipe) ; do 
    845848            echo "Rolling on $layer..." 
    846             conf_rollout $layer || conf_cleanExit 
     849            conf_rollout $layer $statefile || conf_cleanExit 
    847850        done 
    848851 
     
    996999        local tmproot=$(conf_tmp_dir) 
    9971000        local live_root="${LIVE_ROOT}" 
     1001        local statefile 
    9981002 
    9991003        # Override LIVE_ROOT to commit into our tmporary directory. 
     
    10031007 
    10041008        echo "Audit operation started" >&2 
    1005         for layer in $(conf_get_recipe) ; do 
     1009        statefile=$(conf_tmp_file) 
     1010        for layer in $(conf_get_reverse_recipe) ; do 
    10061011            echo "Rolling on $layer..." 
    1007             conf_rollout $layer || return $? 
     1012            conf_rollout $layer $statefile || return $? 
    10081013        done >/dev/null 
    10091014        for file in $SINGULARITIES ; do 
  • branches/confman-1.9/confmanlib.sh.in

    r565 r568  
    523523} 
    524524 
     525# Test to see if the pathname has been added to a statefile yet 
     526function conf_beenthere { 
     527    local statefile="$1" 
     528    local pathname="$2" 
     529    fgrep -xq "$pathname" "$statefile" 
     530} 
     531 
     532# Record this file in the given statefile 
     533function conf_gothere { 
     534    local statefile="$1" 
     535    local pathname="$2" 
     536    echo "$pathname" >> $statefile 
     537} 
     538 
    525539# Roll out the specified module, optionally at the specified checkpoint 
    526 # eg:   conf_rollout MODULE [checkpoint] 
     540# A statefile is a place to record the files that have been rolled out to 
     541# prevent a lower-priority module from installing a committed file. 
     542# eg:   conf_rollout MODULE STATEFILE [checkpoint] 
    527543function conf_rollout { 
    528544        local module="$1" 
    529         if [ -z $2 ] ; then 
     545    local statefile="$2" 
     546        if [ -z $3 ] ; then 
    530547                local moduledir="${WORK_PATH}/$module" 
    531548        else  
     
    545562                local livedir=`echo $directory | ${sed_cmd} -e "s:$moduledir::"` 
    546563                livedir="${LIVE_ROOT}${livedir}" 
    547                 local owner=`conf_get_prop ${directory} owner` 
    548                 local group=`conf_get_prop ${directory} group` 
    549                 local mode=`conf_get_prop ${directory} mode` 
    550                 local opts="-d -o $owner -g $group -m $mode" 
    551                 local cmd="$SUDO $install_cmd $opts $livedir" 
    552                 echo $cmd 
    553                 $cmd 
    554         done 
     564        if ! conf_beenthere $statefile "$livedir" ; then 
     565                    local owner=`conf_get_prop ${directory} owner` 
     566                    local group=`conf_get_prop ${directory} group` 
     567                    local mode=`conf_get_prop ${directory} mode` 
     568                    local opts="-d -o $owner -g $group -m $mode" 
     569                    local cmd="$SUDO $install_cmd $opts $livedir" 
     570                    echo $cmd 
     571            conf_gothere $statefile "$livedir" 
     572                    $cmd 
     573        else 
     574            conf_debug "Ignoring directory ${livedir} in module ${module}" 
     575        fi 
     576        done     
    555577        for file in `find -L $moduledir -type f | grep -v "\.svn"` ; do 
    556578                local livefile=`echo "$file" | ${sed_cmd} -e "s:$moduledir::"` 
    557                 local owner=`conf_get_prop ${file} owner` 
    558                 local group=`conf_get_prop ${file} group` 
    559                 local mode=`conf_get_prop ${file} mode` 
    560         local symlink="`conf_get_prop ${file} symlink`" 
    561         file=`$readlink_cmd -m $file` 
    562         if [ -n "$symlink" ]; then 
    563             local cmd="$SUDO ln -snf $symlink ${LIVE_ROOT}$livefile" 
    564             echo $cmd 
    565             $cmd 
     579        livefile="${LIVE_ROOT}${livefile}" 
     580        if ! conf_beenthere $statefile "$livefile" ; then 
     581            local owner=`conf_get_prop ${file} owner` 
     582            local group=`conf_get_prop ${file} group` 
     583            local mode=`conf_get_prop ${file} mode` 
     584            local symlink="`conf_get_prop ${file} symlink`" 
     585            file=`$readlink_cmd -m $file` 
     586            if [ -n "$symlink" ]; then 
     587                local cmd="$SUDO ln -snf $symlink $livefile" 
     588            else 
     589                        local opts="-o $owner -g $group -m $mode" 
     590                        local cmd="$SUDO $install_cmd $opts $file $livefile" 
     591            fi 
     592                    echo $cmd 
     593            conf_gothere $statefile "$livefile" 
     594                    $cmd 
    566595        else 
    567                     local opts="-o $owner -g $group -m $mode" 
    568                     local cmd="$SUDO $install_cmd $opts $file ${LIVE_ROOT}$livefile" 
    569                     echo $cmd 
    570                     $cmd 
     596            conf_debug "Ignoring file ${livefile} in module ${module}" 
    571597        fi 
    572598        done 
     
    648674    ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 
    649675        local module="$1" 
    650     local file="$2" 
    651     shift 2 
     676    local statefile="$2" 
     677    local file="$3" 
     678    shift 3 
    652679    local livefile 
    653680    local failures=false 
     
    662689    livefile="/${file#*/}" 
    663690    file="${ABS_WORK}/${module}${livefile}" 
     691    livefile="${LIVE_ROOT}${livefile}" 
    664692 
    665693        # See if it even exists 
    666694    if [ ! -e "$file" ] ; then 
    667695        conf_debug "$file" does not appear to exist 
    668         conf_install $module "$@" 
     696        conf_install $module $statefile "$@" 
    669697        return 1 
    670698    fi 
     
    683711     
    684712    if [ -n "$symlink" ] ; then 
    685         local cmd="$SUDO ln -snf $symlink ${LIVE_ROOT}$livefile" 
    686     else 
    687             local cmd="$SUDO $install_cmd $opts $file ${LIVE_ROOT}$livefile" 
    688     fi 
    689  
    690         ${NFS_HACK:-false} && chmod o+rx ${ABS_WORK} 
    691         echo $cmd 
    692         $cmd || failures=true 
    693         ${NFS_HACK:-false} && chmod o-rx ${ABS_WORK} 
     713        local cmd="$SUDO ln -snf $symlink $livefile" 
     714    else 
     715            local cmd="$SUDO $install_cmd $opts $file $livefile" 
     716    fi 
     717 
     718    if ! conf_beenthere $statefile "$livefile" ; then 
     719            ${NFS_HACK:-false} && chmod o+rx ${ABS_WORK} 
     720            echo $cmd 
     721        conf_gothere $statefile "$livefile" 
     722            $cmd || failures=true 
     723            ${NFS_HACK:-false} && chmod o-rx ${ABS_WORK} 
     724    else 
     725        conf_debug "Ignoring file ${livefile} in module ${module}" 
     726    fi 
    694727 
    695728    if [ -d "$file" ] ; then 
    696729        conf_debug "conf_install encountered a directory. Recursing." 
    697         conf_install $module $(find "$file" \ 
     730        conf_install $module $statefile $(find "$file" \ 
    698731            -mindepth 1 -maxdepth 1 -not -name '.svn') || failures=true 
    699732    fi 
    700733    conf_debug "conf_install recursing" 
    701         conf_install $module "$@" || failures=true 
     734        conf_install $module $statefile "$@" || failures=true 
    702735    conf_debug "conf_install returning" 
    703736    if $failures ; then  
     
    11521185} 
    11531186 
     1187# Gets a reversed copy of the recipe 
     1188function conf_get_reverse_recipe { 
     1189    local fwd_recipe=$(conf_get_recipe "$@") 
     1190    local rev_recipe 
     1191    for module in $fwd_recipe ; do 
     1192        rev_recipe="$module $rev_recipe" 
     1193    done 
     1194    echo $rev_recipe 
     1195} 
     1196 
    11541197# Spits the recipe, modules separated by whitespace, out on stdout 
    11551198function conf_get_recipe { 
  • branches/confman-1.9/confsync.in

    r564 r568  
    116116sys_revision=`conf_sysrev` 
    117117last_action=$(conf_lastact) 
     118statefile=$(conf_tmp_file) 
    118119 
    119120if [ -n "${sys_revision}" ] ; then 
     
    131132 
    132133echo "Sync operation started" | conf_logger 
    133 for layer in $(conf_get_recipe) ; do 
     134for layer in $(conf_get_reverse_recipe) ; do 
    134135    echo "Rolling on $layer..." 
    135     conf_rollout $layer || conf_cleanExit 
     136    conf_rollout $layer $statefile || conf_cleanExit 
    136137done 
    137138for file in $SINGULARITIES ; do 
Note: See TracChangeset for help on using the changeset viewer.