Changeset 123 for trunk/confman/confmanlib.sh
- Timestamp:
- 12/04/2006 20:38:36 (5 years ago)
- File:
-
- 1 edited
-
trunk/confman/confmanlib.sh (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/confman/confmanlib.sh
r122 r123 10 10 11 11 REPO_URI="${REPO_PROTOCOL}${REPO_HOSTNAME}${REPO_PATH}" 12 REPO_ACTION="${REPO_DB}/last_action" 13 REPO_SYNC_STATE="${REPO_DB}/state" 12 14 13 15 # Checks out the conf tree if we don't already have it. Updates it if we do. … … 55 57 # Commits module $1 with message $2 56 58 function conf_commit { 57 local modules=$(echo $ modules| tr ' ' ',')59 local modules=$(echo $1 | tr ' ' ',') 58 60 local msg="$2" 59 61 60 62 # $modules is in the form foo,bar,baz. This eval trick forces 61 63 # curly brace expansion. 62 svn commit -F "$msg" $(eval echo foo/{$modules}) 64 if echo "$modules" | grep ',' > /dev/null ; then 65 svn commit -F "$msg" $(eval echo ${WORK_PATH}/{$modules}) 66 else 67 svn commit -F "$msg" ${WORK_PATH}/$modules 68 fi 63 69 } 64 70 … … 72 78 remote="${CONF_EXPORT_URI#*://}" 73 79 remote="${remote/\//:/}" 74 scp $remote $tmpfile80 scp -p $remote $tmpfile 75 81 ;; 76 82 http|https|ftp) … … 79 85 file) 80 86 remote="${CONF_EXPORT_URI#*://}" 81 cp $remote $tmpfile87 cp -p $remote $tmpfile 82 88 ;; 83 89 *) … … 97 103 # This exports a working copy of the repository to a tarball 98 104 function conf_export { 99 local tmpdir=`mktemp -d -t confman`100 105 local tarball="$1" 101 svn checkout "${REPO_URI}" "${tmpdir}/conf" 102 tar -czf "$tarball" -C "$tmpdir" conf 103 rm -rf "$tmpdir" 106 conf_checkout_tree 107 tar -czf "$tarball" -C "${WORK_PATH}" . 104 108 } 105 109 … … 159 163 # See if it even exists 160 164 file="${moduledir}${livefile}" 161 echo Install: $file162 165 if [ ! -e "$file" ] && [ -z "$1" ] ; then 163 166 return 0 … … 240 243 local checkpoint=$2 241 244 local chkpath="${WORK_PATH}/${REPO_CHECKPTS}/${module}/${checkpoint}" 242 local revision=` svn info ${WORK_PATH}|awk '/Last Changed Rev:/ {print $4}'`245 local revision=`conf_revision` 243 246 echo $revision > $chkpath 244 247 svn add $chkpath … … 470 473 } 471 474 475 function conf_markclean { 476 echo clean > $REPO_SYNC_STATE 477 } 478 479 function conf_markdirty { 480 echo dirty > $REPO_SYNC_STATE 481 } 482 483 function conf_isclean { 484 local state=`cat $REPO_SYNC_STATE` 485 case $state in 486 clean) return 0 ;; 487 dirty) return 1 ;; 488 *) echo "Invalid state. Reporting dirty." >&2 ; return 1 ;; 489 esac 490 } 491 492 # Returns the current revision number of the repository on stdout 493 function conf_revision { 494 svn info ${WORK_PATH} | awk '/Last Changed Rev:/ {print $4}' 495 } 496 497 # Returns the revision of the last commit or install operation on stdout 498 function conf_sysrev { 499 cut -d ':' -f 2 $REPO_ACTION 500 } 501 502 # Returns the last action of the repository on stdout 503 function conf_lastact { 504 cut -d ':' -f 1 $REPO_ACTION 505 } 506 507 # Records the specified action 508 function conf_recordAction { 509 local action="$1" 510 local revision=`conf_revision` 511 echo "${action}:${revision}" > $REPO_ACTION 512 } 513 472 514 # WARNING: If you refer to fd 2 in this code, this function will silently 473 515 # fail when called by trap. DO NOT ATTEMPT TO LOG TO fd 2 IN THIS FUNCTION! … … 484 526 485 527 echo "Removing leftover temp files..." >&4 486 find /tmp -maxdepth 1 -user `whoami` -name 'confman*'-exec rm -rf {} \;528 find /tmp/confman* -maxdepth 0 -user `whoami` -exec rm -rf {} \; 487 529 488 530 # And this clears any locks we may have created on our working copy:
Note: See TracChangeset
for help on using the changeset viewer.
