- Timestamp:
- 11/11/2009 14:21:33 (3 years ago)
- Location:
- branches/confman-1.9
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
confman.in (modified) (8 diffs)
-
confmanlib.sh.in (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/confman-1.9
-
branches/confman-1.9/confman.in
r483 r484 189 189 190 190 function commit { 191 local msg status modules module modpath191 local msg status modules module symlink symlinks 192 192 local nocommit=true 193 193 local opt OPTIND OPTARG … … 211 211 wcopy_lock=$(conf_lock_wcopy) 212 212 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 216 221 done 217 222 … … 219 224 conf_update_tree || conf_cleanExit 220 225 221 if status=$(get_status $modules ); then226 if status=$(get_status $modules $symlinks); then 222 227 nocommit=false 223 228 msg=$(get_log "$status") || conf_cleanExit … … 228 233 229 234 echo "Commit operation started" >&2 230 $nocommit || conf_commit "$(conf_get_recipe)" $msg|| return $?235 $nocommit || conf_commit_file $msg $modules $symlinks || return $? 231 236 for layer in $(conf_get_recipe) ; do 232 237 echo "Rolling on $layer..." … … 256 261 m) LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 257 262 F) LOG_FILE="$OPTARG" ;; 258 N) innercall=true ;;259 263 *) echo "Invalid option '-${OPTARG}'." >&4 260 264 print_usage 1 … … 274 278 $SUDO ${SUDO:+-v} 275 279 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 297 294 done 298 295 conf_recordAction install … … 859 856 wcopy_lock=$(conf_lock_wcopy) 860 857 conf_ln $target $link $forced 861 conf_unlock_wcopy $ (wcopy_lock)858 conf_unlock_wcopy $wcopy_lock 862 859 } 863 860 … … 880 877 wcopy_lock=$(conf_lock_wcopy) 881 878 conf_chattr "$attr" "$value" "$@" 882 conf_unlock_wcopy $ (wcopy_lock)879 conf_unlock_wcopy $wcopy_lock 883 880 } 884 881 -
branches/confman-1.9/confmanlib.sh.in
r483 r484 263 263 264 264 return 0 265 }266 267 # Commits module $1 with message $2268 function conf_commit {269 local modules=$(echo $1 | tr ' ' ',')270 local msg="$2"271 local symlinks272 273 # $modules is in the form foo,bar,baz. This eval trick forces274 # curly brace expansion.275 if echo "$modules" | grep ',' > /dev/null ; then276 for module in $(eval echo ${WORK_PATH}/{$modules}); do277 symlinks="$symlinks `find ${module} -type l \278 -exec ${readlink_cmd} -m {} \;`"279 done280 @SVN@ commit -F "$msg" $(eval echo ${WORK_PATH}/{$modules}) \281 $symlinks282 else283 symlinks="$symlinks `find ${modules} -type l \284 -exec ${readlink_cmd} -m {} \;`"285 @SVN@ commit -F "$msg" ${WORK_PATH}/$modules \286 $symlinks287 fi288 265 } 289 266 … … 474 451 } 475 452 453 function conf_livefile { 454 local file="$1" 455 local path=$(conf_rel_path "$file") || return 456 echo ${path#*/}/ 457 } 458 459 function 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 476 function 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 490 function 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 476 512 function conf_install { 513 conf_debug conf_install called with args "$@" 514 ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 477 515 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}" 492 530 493 531 # 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 502 537 503 538 # If we got here, figure it out … … 507 542 local symlink="`conf_get_prop ${file} symlink`" 508 543 509 file="$targetfile"510 544 if [ -f "$file" ] ; then 511 545 local opts="-o $owner -g $group -m $mode" … … 520 554 fi 521 555 522 ${NFS_HACK:-false} && chmod o+rx ${ WORK_PATH}556 ${NFS_HACK:-false} && chmod o+rx ${ABS_WORK} 523 557 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} 526 560 527 561 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 } 535 575 536 576 function conf_list {
Note: See TracChangeset
for help on using the changeset viewer.
