Ignore:
Timestamp:
12/04/2006 20:38:36 (5 years ago)
Author:
ccowart
Message:

Developed the pull mechanism for confman. It's ready to go into production!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/confman/confmanlib.sh

    r122 r123  
    1010 
    1111REPO_URI="${REPO_PROTOCOL}${REPO_HOSTNAME}${REPO_PATH}" 
     12REPO_ACTION="${REPO_DB}/last_action" 
     13REPO_SYNC_STATE="${REPO_DB}/state" 
    1214 
    1315# Checks out the conf tree if we don't already have it. Updates it if we do. 
     
    5557# Commits module $1 with message $2 
    5658function conf_commit { 
    57         local modules=$(echo $modules | tr ' ' ',') 
     59        local modules=$(echo $1 | tr ' ' ',') 
    5860        local msg="$2" 
    5961 
    6062    # $modules is in the form foo,bar,baz. This eval trick forces 
    6163    # 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 
    6369} 
    6470 
     
    7278            remote="${CONF_EXPORT_URI#*://}" 
    7379            remote="${remote/\//:/}" 
    74             scp $remote $tmpfile  
     80            scp -p $remote $tmpfile  
    7581            ;; 
    7682        http|https|ftp) 
     
    7985        file) 
    8086            remote="${CONF_EXPORT_URI#*://}" 
    81             cp $remote $tmpfile 
     87            cp -p $remote $tmpfile 
    8288            ;; 
    8389        *) 
     
    97103# This exports a working copy of the repository to a tarball 
    98104function conf_export { 
    99     local tmpdir=`mktemp -d -t confman` 
    100105    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}" . 
    104108} 
    105109 
     
    159163        # See if it even exists 
    160164        file="${moduledir}${livefile}" 
    161         echo Install: $file 
    162165        if [ ! -e "$file" ] && [ -z "$1" ] ; then 
    163166                return 0 
     
    240243        local checkpoint=$2 
    241244        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` 
    243246        echo $revision > $chkpath 
    244247        svn add $chkpath 
     
    470473} 
    471474 
     475function conf_markclean { 
     476    echo clean > $REPO_SYNC_STATE 
     477} 
     478 
     479function conf_markdirty { 
     480    echo dirty > $REPO_SYNC_STATE 
     481} 
     482 
     483function 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 
     493function 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 
     498function conf_sysrev { 
     499    cut -d ':' -f 2 $REPO_ACTION 
     500} 
     501 
     502# Returns the last action of the repository on stdout 
     503function conf_lastact { 
     504    cut -d ':' -f 1 $REPO_ACTION 
     505} 
     506 
     507# Records the specified action 
     508function conf_recordAction { 
     509    local action="$1" 
     510    local revision=`conf_revision` 
     511    echo "${action}:${revision}" > $REPO_ACTION 
     512} 
     513 
    472514# WARNING: If you refer to fd 2 in this code, this function will silently 
    473515# fail when called by trap. DO NOT ATTEMPT TO LOG TO fd 2 IN THIS FUNCTION! 
     
    484526 
    485527        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 {} \; 
    487529 
    488530        # And this clears any locks we may have created on our working copy: 
Note: See TracChangeset for help on using the changeset viewer.