Changeset 484 for branches/confman-1.9/confmanlib.sh.in
- Timestamp:
- 11/11/2009 14:21:33 (3 years ago)
- Location:
- branches/confman-1.9
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
confmanlib.sh.in (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/confman-1.9
-
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.
