Changeset 481 for branches/confman-1.9


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

Merging improved recipe creation and editing from trunk.

Resolves #83, #84

Location:
branches/confman-1.9
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/confman-1.9

  • branches/confman-1.9/Makefile.am

    r458 r481  
    1212sysconf_DATA = confman.conf.sample 
    1313sysconfdefaults_DATA = confman.conf 
     14dist_sysconfdefaults_DATA = recipe.template 
    1415bashcomp_DATA = confman_completion 
    1516man_MANS = confman.8 confman.conf.5 
  • branches/confman-1.9/confman.8.in

    r461 r481  
    3636.Op Fl v | Cm version 
    3737.Nm 
    38 .Ar command Oo Ar command_opts Oc Op Ar command_args 
     38.Oo Ar flags Oc Ar command Oo Ar command_opts Oc Op Ar command_args 
    3939.Sh DESCRIPTION 
    4040The 
     
    9696operations can bring the system up-to-date. 
    9797.El 
    98 .\" TODO 
     98.Ss FLAGS 
     99.Bl -tag -width "FLAGS " 
     100.It Global flags 
     101The following flags can be specified before the commands: 
     102.Bl -tag -width indent 
     103.It Fl h Op Ar command  
     104Synonymous to the 
     105.Ar help 
     106command below. 
     107.It Fl v 
     108Causes 
     109.Nm 
     110to print the version string and exit. 
     111.El 
     112.It Log flags 
     113The following flags can be used where 
     114.Ar log_flags 
     115appears in the usage statements (See 
     116.Sx COMMANDS ) : 
     117.Bl -tag -width indent 
     118.It Fl m Ar message 
     119The string in the 
     120.Ar message 
     121argument will be used instead of prompting the user for a log message for 
     122.Cm commit 
     123and 
     124.Cm install 
     125operations. 
     126.It Fl F Ar filename 
     127Like 
     128.Fl m , 
     129except the log's contents are read from 
     130.Ar filename 
     131instead of the command line. 
     132.El 
     133.El 
    99134.Ss COMMANDS 
    100135The following commands are supported by  
     
    125160that will cause the latest repository revision to be reflected in your working 
    126161copy.  command does not alter the repository or the system. 
    127 .It Cm commit 
     162.It Cm commit Oo log_flags Oc 
    128163The commit command causes your changes to take effect.  
    129164.Bl -bullet 
     
    171206working copy of 
    172207.Ar module . 
    173 .It Cm install Ar 
     208.It Cm install Oo Ar log_flags Oc Ar 
    174209Roll out the specified working files and directories to the live filesystem. 
    175210Note that recipe ordering will be respected, so using install in a low-priority 
    176211module will still cause the highest priority module's copy of the file to 
    177212ultimately be installed. 
    178 .It Cm status [ Ar working_copy ] 
     213.It Cm status Oo Ar working_copy Oc 
    179214Look at the status entries for the file or directory specified by  
    180215.Ar working_copy . 
     
    183218.It Cm recipe  
    184219.Brq Cm get | list 
    185 .It Cm recipe  
    186 .Brq Cm create | edit | print | remove | set  
    187 .Ar recipe  
     220.It Cm recipe create Oo Fl R Ar filename Oc Oo Ar log_flags Oc Ar recipe 
     221.It Cm recipe print Ar recipe 
     222.It Cm recipe Bro Cm edit | remove Brc Oo Ar log_flags Oc Ar recipe  
     223.It Cm recipe set Ar recipe 
    188224.Bl -tag -width indent 
    189225.It Cm create 
    190226Create a recipe named  
    191 .Ar recipe 
     227.Ar recipe.  
     228Use -R to specify a file with the recipe's contents to bypass interactive  
     229mode. 
    192230.It Cm edit 
    193231Open 
  • branches/confman-1.9/confman.conf.5.in

    r439 r481  
    137137.It CONF_WARNING 
    138138This is the first line of confman banners for managed files. 
     139.It LOG_TEMPLATE 
     140If defined, the contents of this file will be the default log message visible 
     141in a user's editor for repository commits. This can be useful if you use 
     142hooks to log commits into an external issue tracker and you want to remind 
     143your users to fill in the ticket number. 
     144.It RECIPE_TEMPLATE 
     145When new recipes are created, the contents of this file will be used. The 
     146string  
     147.Ar __NAME__  
     148will be replaced with the name of the recipe. This defaults to  
     149@sysconfdefaultsdir@/recipe.template.  
    139150.It DEFAULT_MODE_DIRECTORY 
    140151Defaults to "0555". When new directories are created in 
  • branches/confman-1.9/confman.conf.in

    r436 r481  
    4545# The template for log messages 
    4646LOG_TEMPLATE="/dev/null" 
     47 
     48# The template for new recipes 
     49RECIPE_TEMPLATE="@sysconfdefaultsdir@/recipe.template" 
    4750 
    4851# The warning message for all files 
  • branches/confman-1.9/confman.in

    r480 r481  
    111111} 
    112112 
     113# Either by prompting or respecting -m/-F, returns a filename on stdout 
     114# with a log message in it 
     115# $1 contains a file with the output of svn status to display in interactive 
     116# log messages 
     117#   Returns 1 if an abort was requested by the user 
     118#   Returns 0 if the returned filename is good for a commit 
     119function get_log { 
     120    local status="$1" 
     121    local finished=false 
     122    local ignoreline="--This line, and those below, will be ignored--" 
     123    local orig_log logfile 
     124 
     125    # local seems to return true, overwriting the return of the nested 
     126    # call for && evaluation 
     127    logfile=$(conf_log_message) && finished=true 
     128 
     129    if $finished ; then 
     130        echo "$logfile" 
     131        return 0 
     132    fi 
     133 
     134    orig_log=$(conf_tmp_file) 
     135    printf "\n$ignoreline\n" >> "$logfile" 
     136    cat "$status" >> "$logfile" 
     137    cp "$logfile" "$orig_log" 
     138 
     139    # I apologize for the redirect, but stdout is being written into a 
     140    # variable, and at least vim (probably other editors too) gets cranky when 
     141    # stdout doesn't go to the user. Luckily, the fork in the common section 
     142    # leaves a copy of the original stdout in fd 3. 
     143    ${EDITOR} "$logfile" >&3 
     144 
     145    while diff "$logfile" "$orig_log" >/dev/null 2>&1 ; do 
     146        echo "Log message unchanged. (E)dit / (a)bort / (c)ontinue?" 
     147        read response 
     148        case "$response" in 
     149            [cC]*)      break;; 
     150            [aA]*)      return 1;; 
     151            ""|[eE]*)   ${EDITOR} "$logfile";; 
     152        esac 
     153    done 
     154    rm -f "$orig_log" 
     155    ${sed_cmd} -i '' -e "/${ignoreline}/,\$d" "$logfile" 2>/dev/null 
     156    echo "$logfile" 
     157    return 0 
     158} 
     159 
     160# Arguments are full paths to files within $WORK_PATH to check via svn status. 
     161#   Returns 1 if the files are unchanged 
     162#   Returns 0 if the files are changed and prints a filename to stdout 
     163#     with status info suitable for log message footers 
     164function get_status { 
     165    local status=$(conf_tmp_file) 
     166    local ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 
     167 
     168    # Using a subshell to preserve CWD 
     169    ( 
     170        cd "$WORK_PATH" 
     171        until [ -z "$1" ] ; do 
     172            @SVN@ status "${1#${ABS_WORK}/}" >> "$status" 
     173            shift 
     174        done 
     175    ) 
     176 
     177    if [ $(wc -l < "$status") -eq 0 ] ; then 
     178        rm -f "$status" 
     179        return 1 
     180    fi 
     181 
     182    echo "$status" 
     183    return 0 
     184} 
     185 
    113186function commit { 
    114     if [ -z "$*" ] ; then 
    115         conf_require_recipe  
    116         conf_lock_system 
    117         conf_lock_wcopy 
    118         local msg=$(conf_tmp_file) 
    119         local orig_msg=$(conf_tmp_file) 
    120         local status=$(conf_tmp_file) 
    121         local modules=$(conf_get_recipe | tr '\n' ',')  
    122         local ignoreline="--This line, and those below, will be ignored--" 
    123         # Moved up per Ian's request. 
    124         $SUDO ${SUDO:+-v} 
    125         cat $LOG_TEMPLATE > $msg 
    126         printf "\n${ignoreline}\n" >> $msg 
    127         conf_get_recipe | tr ' ' '\n' | xargs -I % @SVN@ status \ 
    128             ${WORK_PATH}/% >> $status 
    129                 cat $status >> $msg 
    130         cp $msg $orig_msg 
    131                 if [ $(wc -l < $status) -gt 0 ] ; then 
    132                 ${EDITOR} $msg 
    133             if diff $msg $orig_msg >/dev/null 2>&1 ; then 
    134                 echo "Log message unchanged. (a)bort / (C)ontinue?" 
    135                 read response 
    136                 if [ "${response}" = "a" ] ; then 
    137                     conf_unlock_wcopy 
    138                     conf_unlock_system 
    139                     return 1 
    140                 fi 
    141             fi 
    142                 fi 
    143                 rm -f $status $orig_msg 
    144         ${sed_cmd} -i '' -e '/'"$ignoreline"'/,$d' $msg 2>/dev/null 
    145         $SUDO ${SUDO:+-v} 
    146  
    147         #Changed this from just update to fix locking issue - arjun 
    148         conf_update_tree || conf_cleanExit 
    149  
    150         echo "Commit operation started" >&2 
    151         conf_commit "$(conf_get_recipe)" $msg || return $? 
    152         for layer in $(conf_get_recipe) ; do 
    153             echo "Rolling on $layer..." 
    154             conf_rollout $layer || return $? 
    155         done 
    156         for file in $SINGULARITIES ; do 
    157             conf_assemble_sing $file || return $? 
    158         done 
    159         conf_recordAction commit 
    160         conf_markclean 
    161         echo "Commit operation finished successfully" >&2 
    162         rm -f $msg 
    163         conf_unlock_wcopy 
    164         conf_unlock_system 
    165     else 
    166         print_usage 1 
    167     fi 
     187    local msg status modules module modpath 
     188    local nocommit=true 
     189    local opt OPTIND OPTARG 
     190 
     191    while getopts ":m:F:" opt ; do 
     192        case $opt in 
     193            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     194            F)  LOG_FILE="$OPTARG" ;; 
     195            *)  echo "Invalid option '-${OPTARG}'." >&4 
     196                print_usage 1 
     197                ;; 
     198        esac 
     199    done 
     200    shift $(($OPTIND - 1)) 
     201 
     202    [ -z "$1" ] || print_usage 1 
     203 
     204    conf_require_recipe  
     205    conf_lock_system 
     206    conf_lock_wcopy 
     207     
     208    for module in $(conf_get_recipe) ; do 
     209        modpath=$(${readlink_cmd} -m ${WORK_PATH}/${module}) 
     210        modules=${modules:+${modules} }${modpath} 
     211    done 
     212     
     213    $SUDO ${SUDO:+-v} 
     214    conf_update_tree || conf_cleanExit 
     215     
     216    if status=$(get_status $modules) ; then 
     217        nocommit=false 
     218        msg=$(get_log "$status") || conf_cleanExit 
     219        rm -f "$status" 
     220    fi 
     221     
     222    $SUDO ${SUDO:+-v} 
     223     
     224    echo "Commit operation started" >&2 
     225    $nocommit || conf_commit "$(conf_get_recipe)" $msg || return $? 
     226    for layer in $(conf_get_recipe) ; do 
     227        echo "Rolling on $layer..." 
     228        conf_rollout $layer || return $? 
     229    done 
     230    for file in $SINGULARITIES ; do 
     231        conf_assemble_sing $file || return $? 
     232    done 
     233    conf_recordAction commit 
     234    conf_markclean 
     235    echo "Commit operation finished successfully" >&2 
     236    rm -f $msg 
     237    conf_unlock_wcopy 
     238    conf_unlock_system 
    168239} 
    169240 
     
    171242function inst { 
    172243    local file livefile 
    173  
    174     if [ -z "$*" ] ; then 
    175         print_usage 1 
    176     else 
    177         conf_require_recipe  
    178         conf_lock_wcopy 
    179         conf_lock_system 
    180         local msg=$(conf_tmp_file) 
    181         local orig_msg=$(conf_tmp_file) 
    182         local status=$(conf_tmp_file) 
    183         local modules=$(conf_get_recipe | tr '\n' ',') 
    184         local ignoreline="---Everything after this line will be ignored---" 
    185         local files 
    186         # Moved up per Ian's request. 
    187         cat $LOG_TEMPLATE > $msg 
    188         printf "\n${ignoreline}\n" >> $msg 
    189         for file in "$@"; do 
    190             if [ -L "$file" ]; then 
    191                 files="$files `${readlink_cmd} -m $file`" 
    192             fi 
    193             files="$files $file" 
    194         done 
    195         @SVN@ status $files >> $status 
    196         cat $status >> $msg 
    197         cp $msg $orig_msg 
    198         if [ $(wc -l < $status) -gt 0 ] ; then 
    199             ${EDITOR} $msg 
    200             if diff $msg $orig_msg >/dev/null 2>&1 ; then 
    201                 echo "Log message unchanged. (a)bort / (C)ontinue?" 
    202                 read response 
    203                 if [ "${response}" = "a" ] ; then 
    204                     conf_unlock_wcopy 
    205                     conf_unlock_system 
    206                     return 1 
    207                 fi 
    208             fi 
    209         fi 
    210         rm $status $orig_msg 
    211         ${sed_cmd} -i '' -e '/'"$ignoreline"'/,$d' $msg 2>/dev/null 
    212         $SUDO ${SUDO:+-v} 
    213         #changed from update to conf_update_tree to implement locking - arjun 
    214         conf_update_tree || conf_cleanExit 
    215  
    216         echo "Installation operation started." >&2 
    217         conf_commit_file "$msg" "$files" || return $? 
    218         for layer in $(conf_get_recipe) ; do 
    219             conf_install $layer "$@" 
    220         done 
    221         for file in $SINGULARITIES ; do 
    222             conf_assemble_sing $file || conf_cleanExit 
    223         done 
    224         conf_recordAction install 
    225         if ! conf_isclean ; then 
    226             echo "WARNING: Recent 'install' operations prevented a 'sync'" >&2 
    227             echo "Running a 'commit' is highly recommended." >&2 
    228         fi 
    229         echo "Installation operation succeeded." >&2 
    230         conf_unlock_wcopy 
    231         conf_unlock_system 
    232     fi 
     244    local msg status files file 
     245    local nocommit=true 
     246    local opt OPTIND OPTARG 
     247 
     248    while getopts ":m:F:" opt ; do 
     249        case $opt in 
     250            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     251            F)  LOG_FILE="$OPTARG" ;; 
     252            *)  echo "Invalid option '-${OPTARG}'." >&4 
     253                print_usage 1 
     254                ;; 
     255        esac 
     256    done 
     257    shift $(($OPTIND - 1)) 
     258 
     259    conf_require_recipe  
     260    conf_lock_wcopy 
     261    conf_lock_system 
     262     
     263    for file in "$@"; do 
     264        files="${files:+${files} }$(${readlink_cmd} -m "$file")" 
     265    done 
     266     
     267     
     268    $SUDO ${SUDO:+-v} 
     269    conf_update_tree || conf_cleanExit 
     270     
     271    if status=$(get_status $files) ; then 
     272        nocommit=false 
     273        msg=$(get_log "$status") || conf_cleanExit 
     274        rm -f "$status" 
     275    fi 
     276     
     277    echo "Installation operation started." >&2 
     278    $nocommit || conf_commit_file "$msg" "$files" || return $? 
     279    for layer in $(conf_get_recipe) ; do 
     280        conf_install $layer "$@" 
     281    done 
     282    for file in $SINGULARITIES ; do 
     283        conf_assemble_sing $file || conf_cleanExit 
     284    done 
     285    conf_recordAction install 
     286    if ! conf_isclean ; then 
     287        echo "WARNING: Recent 'install' operations prevented a 'sync'" >&2 
     288        echo "Running a 'commit' is highly recommended." >&2 
     289    fi 
     290    echo "Installation operation succeeded." >&2 
     291    conf_unlock_wcopy 
     292    conf_unlock_system 
    233293} 
    234294         
     
    894954 
    895955function recipe_edit { 
     956    local recipe 
     957    local new_recipe_file recipe_file 
     958    local repeat msg status 
     959    local opt OPTIND OPTARG 
     960 
     961    while getopts ":m:F:" opt ; do 
     962        case $opt in 
     963            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     964            F)  LOG_FILE="$OPTARG" ;; 
     965            *)  echo "Invalid option '-${OPTARG}'." >&4 
     966                print_usage 1 
     967                ;; 
     968        esac 
     969    done 
     970    shift $(($OPTIND - 1)) 
     971 
    896972    if [ -z "$1" ] ; then print_usage 1 ; fi 
    897     local recipe="$1" 
    898     local recipe_file=$(conf_tmp_file) 
    899     cat "$(conf_recipe_dir)/${recipe}" > "$recipe_file" 
    900     $EDITOR "$recipe_file" 
    901     for module in $(conf_get_recipe ${recipe_file}) ; do 
    902         if ! [ -d "${WORK_PATH}/${module}" ] ; then 
    903             echo "Error: recipe references non-existent module $module" >&2 
     973 
     974    conf_lock_wcopy 
     975    recipe="$1" 
     976    recipe_file=$(conf_recipe_dir)/${recipe} 
     977    new_recipe_file=$(conf_tmp_file) 
     978 
     979    cat "$recipe_file" > "$new_recipe_file" 
     980    $EDITOR "$new_recipe_file" 
     981    until conf_recipe_verify "$new_recipe_file" ; do 
     982        echo -n "(E)dit / (c)ancel? " 
     983        read repeat 
     984        case "$repeat" in 
     985            [Cc]*)  return 1;;  
     986            *)      $EDITOR "$new_recipe_file";; 
     987        esac 
     988    done 
     989 
     990    cat "$new_recipe_file" > "$recipe_file" 
     991 
     992    if status=$(get_status "${recipe_file#${WORK_PATH}/}") ; then 
     993        msg=$(get_log "$status") || return 1 
     994        conf_commit_recipe "$msg" "$recipe"  
     995    fi 
     996    rm -f "$new_recipe_file" 
     997    conf_unlock_wcopy 
     998} 
     999 
     1000function recipe_create { 
     1001    local recipe recipe_file opt OPTIND msg status 
     1002    while getopts ":m:F:R:" opt ; do 
     1003        case $opt in 
     1004            R)  new_recipe_file="$OPTARG" ;; 
     1005            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     1006            F)  LOG_FILE="$OPTARG" ;; 
     1007            *)  echo "Invalid option '-${OPTARG}' for recipe create." >&4 
     1008                print_usage 1  
     1009                ;; 
     1010        esac 
     1011    done 
     1012    shift $(($OPTIND - 1)) 
     1013 
     1014    eval recipe=$1 
     1015 
     1016    if [ -z "$recipe" ] ; then  
     1017        print_usage 1  
     1018    fi 
     1019 
     1020    conf_lock_wcopy 
     1021    recipe_file=$(conf_recipe_dir)/${recipe} 
     1022    conf_recipe_create "$recipe" || return 1 
     1023 
     1024    if [ -z "$new_recipe_file" ] ; then 
     1025        if ! recipe_edit "$recipe" ; then 
     1026            conf_rm_file --force "${new_recipe_file}" 
     1027            conf_unlock_wcopy 
    9041028            return 1 
    9051029        fi 
    906     done 
    907     conf_update_recipe "$recipe" "$recipe_file" 
    908     rm -f "$recipe_file" 
    909 } 
    910  
    911 function recipe_create { 
    912     if [ -z "$1" ] ; then print_usage 1 ; fi 
    913     local recipe="$1" 
    914     conf_recipe_create "$recipe" 
    915     recipe_edit "$recipe" 
     1030        conf_unlock_wcopy 
     1031        return 0 
     1032    fi 
     1033 
     1034    if conf_recipe_verify "$new_recipe_file" ; then 
     1035        cp "$new_recipe_file" "$recipe_file" 
     1036        if status=$(get_status "${recipe_file#${WORK_PATH}/}") ; then 
     1037            msg=$(get_log "$status") || return 1 
     1038            conf_commit_recipe "$msg" "$recipe"  
     1039        fi 
     1040        conf_unlock_wcopy 
     1041        return 0 
     1042    else 
     1043        conf_rm_file --force "${recipe_file}" 
     1044        conf_unlock_wcopy 
     1045        return 1 
     1046    fi 
    9161047} 
    9171048 
    9181049function recipe_remove { 
    919     if [ -z "$*" ] ; then print_usage 1 ; fi 
     1050    local opt OPTIND OPTARG 
     1051    local msg status recipes recipe 
     1052    local nocommit=true 
     1053    while getopts ":m:F:" opt ; do 
     1054        case $opt in 
     1055            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     1056            F)  LOG_FILE="$OPTARG" ;; 
     1057            *)  echo "Invalid option '-${OPTARG}'." >&4 
     1058                print_usage 1 
     1059                ;; 
     1060        esac 
     1061    done 
     1062    shift $(($OPTIND - 1)) 
     1063 
     1064    conf_lock_wcopy 
     1065 
    9201066    conf_remove_recipes "$@" || exit 1 
     1067 
     1068    for recipe in "$@" ; do 
     1069        recipes="${recipes:+${recipes} }$(conf_recipe_dir)/${recipe}" 
     1070    done 
     1071 
     1072    if status=$(get_status $recipes) ; then 
     1073        nocommit=false 
     1074        msg=$(get_log "$status") || conf_cleanExit 
     1075        rm -f "$status" 
     1076    fi 
     1077 
     1078    $nocommit || conf_commit_recipes "$msg" "$@" 
     1079 
     1080    conf_unlock_wcopy 
    9211081} 
    9221082 
     
    9351095        exit 1 
    9361096    fi 
     1097    conf_lock_wcopy 
     1098    conf_lock_system 
    9371099    conf_set_recipe "$recipe" 
     1100    conf_unlock_system 
     1101    conf_unlock_wcopy 
    9381102} 
    9391103 
     
    9491113     
    9501114function recipe_list { 
    951     cd $(conf_recipe_dir) 
    952     ls 
     1115    ( 
     1116        cd $(conf_recipe_dir) 
     1117        ls 
     1118    ) 
    9531119} 
    9541120 
     
    9731139 
    9741140# Debug mode? 
    975 while getopts "hdv-" opt ; do 
     1141while getopts ":h:dv-" opt ; do 
    9761142        case $opt in 
    977                 d) DEBUG="true" ; shift ;; 
    978         h) shift ; print_help "$@" ; conf_cleanExit 0 ;; 
     1143                d) DEBUG="true" ;; 
     1144        h) print_help "$OPTARG" ; conf_cleanExit 0 ;; 
    9791145        v) print_version ; conf_cleanExit 0 ;; 
    980                 *) print_usage 1 ;; 
     1146                *) echo "Invalid options '-${OPTARG}'." >&4 
     1147           print_usage 1  
     1148           ;; 
    9811149        esac 
    9821150done 
    9831151 
     1152# Argument checking 
     1153if [ -n "$LOG_FILE" ] && ! [ -r "$LOG_FILE" ] ; then 
     1154    echo "Log file $LOG_FILE does not exist or is not readable." >&4 
     1155    conf_cleanExit 1 
     1156fi 
     1157 
     1158if $LOG_MESSAGE_SET && [ -n "$LOG_FILE" ] ; then 
     1159    echo "Cannot specify both a message with -m and a file with -F." >&4 
     1160    conf_cleanExit 1 
     1161fi 
     1162 
    9841163# Dispatch the subcommand. This must happen last and in the global context. 
    985 subcommand=$1 
    986 shift 
     1164eval subcommand=\$$OPTIND 
     1165shift $OPTIND 
     1166 
    9871167trap "conf_interrupt_trap" HUP INT QUIT TERM 
    9881168case $subcommand in 
  • branches/confman-1.9/confmancommon.sh.in

    r459 r481  
    4040# we re-spawn confman inside a pipe. 
    4141if (true >&5) 2>/dev/null ; then 
    42         exec 4>&2 2>&5 >&3- 
     42        exec 4>&2 2>&5 >&3 
    4343else 
    4444        exec 3>&1 
  • branches/confman-1.9/confmandoc.sh

    r459 r481  
    224224 
    225225Usage: 
    226   $MYNAME commit 
     226    $MYNAME commit [ -F filename | -m message ] 
    227227 
    228228The commit command causes your changes to take effect. This means that 
     
    238238ORDER OF APPEARANCE. 
    239239 
     240If -F or -m are used, the log message will be read from the filename or 
     241the commandline, respectively, instead of prompting the user. 
     242 
    240243EOF 
    241244;; 
     
    257260 
    258261Usage: 
    259   $MYNAME install workingfile [ workingfile ... ] 
     262    $MYNAME install [-F filename | -m message] workingfile [workingfile [...]] 
    260263 
    261264The install subcommand allows you to roll out a single file from your working 
    262265copy. 
     266 
     267If -F or -m are used, the log message will be read from the filename or 
     268the commandline, respectively, instead of prompting the user. 
    263269 
    264270EOF 
     
    495501Usage: 
    496502  $MYNAME recipe [ get | list ] 
    497   $MYNAME recipe [ create | edit | print | remove | set ] recipe_name 
     503  $MYNAME recipe set recipe_name 
     504  $MYNAME recipe [ create | edit | remove ] [ -F file | -m msg ] recipe_name 
    498505 
    499506The recipe command provides an interface to manage confman recipes. 
  • 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.