Ignore:
Timestamp:
11/11/2009 14:09:39 (3 years ago)
Author:
ccowart
Message:

Merging improved recipe creation and editing from trunk.

Resolves #83, #84

Location:
branches/confman-1.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/confman-1.9

  • branches/confman-1.9/confmanlib.sh.in

    r474 r481  
    3232WCOPY_DIRTY="false" 
    3333CONF_EXPORT="false" 
     34LOG_MESSAGE_SET="false" 
    3435 
    3536VERSION='@VERSION@' 
     
    698699 
    699700function conf_rm_file { 
    700         @SVN@ rm $* 
     701        @SVN@ rm "$@" 
    701702} 
    702703 
     
    963964        return 1 
    964965    fi 
    965     touch "$recipe_file" 
     966    ${sed_cmd} -e "s:__NAME__:${recipe}:" $RECIPE_TEMPLATE > "$recipe_file" 
    966967    @SVN@ add "$recipe_file" 
    967968} 
    968969 
    969 function conf_update_recipe { 
    970     local recipe="$1" 
    971     local recipe_file="$2" 
    972     cat "$recipe_file" > "$(conf_recipe_dir)/${recipe}" 
    973     @SVN@ commit "$(conf_recipe_dir)/${recipe}" 
     970function conf_recipe_verify { 
     971    local recipe_file="$1" 
     972    local module 
     973    for module in $(conf_get_recipe ${recipe_file}) ; do 
     974        if ! [ -d "${WORK_PATH}/${module}" ] ; then 
     975            echo "Error: recipe references non-existent module $module" >&2 
     976            return 1 
     977        fi 
     978    done 
     979    return 0 
     980} 
     981 
     982function conf_commit_recipes { 
     983    local recipe recipes 
     984 
     985    local logfile="$1" 
     986    shift 
     987 
     988    for recipe in "$@" ; do 
     989        recipes="${recipes:+${recipes} }$(conf_recipe_dir)/${recipe}" 
     990    done 
     991 
     992    @SVN@ commit -F "$logfile" $recipes 
    974993} 
    975994 
    976995function conf_remove_recipes { 
    977     local recipe 
     996    local recipe recipe_file 
    978997    local oldrecipes 
    979998    local rc=0 
     
    9811000    for recipe in "$@"; do 
    9821001        if conf_remove_recipe "$recipe"; then 
    983             # Keep track of the recipes that were successfully removed 
    984             # to avoid inadvertent commits 
    985             if [ -z "$oldrecipes" ]; then 
    986                 oldrecipes="$recipe" 
    987             else 
    988                 oldrecipes="$oldrecipes,$recipe" 
    989             fi 
     1002            recipe_file="$(conf_recipe_dir)/${recipe}" 
     1003            oldrecipes="${oldrecipes:+${oldrecipes} }${recipe_file}" 
    9901004        else 
    9911005            rc=1 
    9921006        fi 
    9931007    done 
    994  
    995     # $oldrecipes is in the form foo,bar,baz. This eval trick forces 
    996     # curly brace expansion. 
    997     if echo "$oldrecipes" | grep -q ','; then 
    998         @SVN@ commit $(eval echo $(conf_recipe_dir)/{$oldrecipes})  
    999     else 
    1000         @SVN@ commit "$(conf_recipe_dir)/$oldrecipes" 
    1001     fi 
    10021008 
    10031009    return $rc 
     
    10121018    fi 
    10131019    @SVN@ rm "${recipe_file}" || return 1 
     1020    return 0 
     1021} 
     1022 
     1023# Implements logic for selecting logfile based on -m/-F or interactive mode 
     1024#   Returns 0 if the log is "complete", 1 if the log needs editing 
     1025#   Prints filename containing the log on stdout 
     1026function conf_log_message { 
     1027    local logfile 
     1028 
     1029    if [ -n "$LOG_FILE" ] ; then 
     1030        echo "$LOG_FILE" 
     1031        return 0 
     1032    fi 
     1033     
     1034    logfile=$(conf_tmp_file) 
     1035    echo "$logfile" 
     1036 
     1037    if $LOG_MESSAGE_SET ; then 
     1038        echo "$LOG_MESSAGE" > "$logfile" 
     1039    else 
     1040        cat "$LOG_TEMPLATE" > "$logfile" 
     1041        return 1 
     1042    fi 
    10141043    return 0 
    10151044} 
Note: See TracChangeset for help on using the changeset viewer.