Changeset 464


Ignore:
Timestamp:
10/12/2009 20:15:29 (3 years ago)
Author:
ccowart
Message:

I've significantly improved the new log message handling features.

The -m/-F now are expected in the more intuitive placement of after the
command they modify (just like svn).

They were also adopted to the recipe create, edit, and remove commands with
their new placement.

See #83, #84

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/confman.8.in

    r463 r464  
    9797.El 
    9898.Ss FLAGS 
     99.Bl -tag -width "FLAGS " 
     100.It Global flags 
    99101The following flags can be specified before the commands: 
    100102.Bl -tag -width indent 
     
    107109.Nm 
    108110to 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 
    109118.It Fl m Ar message 
    110119The string in the 
     
    121130.Ar filename 
    122131instead of the command line. 
     132.El 
    123133.El 
    124134.Ss COMMANDS 
     
    150160that will cause the latest repository revision to be reflected in your working 
    151161copy.  command does not alter the repository or the system. 
    152 .It Cm commit 
     162.It Cm commit Oo log_flags Oc 
    153163The commit command causes your changes to take effect.  
    154164.Bl -bullet 
     
    196206working copy of 
    197207.Ar module . 
    198 .It Cm install Ar 
     208.It Cm install Oo Ar log_flags Oc Ar 
    199209Roll out the specified working files and directories to the live filesystem. 
    200210Note that recipe ordering will be respected, so using install in a low-priority 
    201211module will still cause the highest priority module's copy of the file to 
    202212ultimately be installed. 
    203 .It Cm status [ Ar working_copy ] 
     213.It Cm status Oo Ar working_copy Oc 
    204214Look at the status entries for the file or directory specified by  
    205215.Ar working_copy . 
     
    208218.It Cm recipe  
    209219.Brq Cm get | list 
    210 .It Cm recipe create Oo Fl R Ar filename Oc Ar recipe 
     220.It Cm recipe create Oo Fl R Ar filename Oc Oo Ar log_flags Oc Ar recipe 
    211221.It Cm recipe print Oo Ar recipe Oc 
    212 .It Cm recipe Bro Cm edit | remove | set Brc 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 
    213224.Bl -tag -width indent 
    214225.It Cm create 
  • trunk/confman.in

    r463 r464  
    185185 
    186186function commit { 
    187     if [ -z "$*" ] ; then 
    188         conf_require_recipe  
    189         conf_lock_system 
    190         conf_lock_wcopy 
    191         local msg status modules module modpath 
    192         local nocommit=true 
    193  
    194         for module in $(conf_get_recipe) ; do 
    195             modpath=$(${readlink_cmd} -m ${WORK_PATH}/${module}) 
    196             modules=${modules:+${modules} }${modpath} 
    197         done 
    198  
    199         $SUDO ${SUDO:+-v} 
    200         conf_update_tree || conf_cleanExit 
    201  
    202         if status=$(get_status $modules) ; then 
    203             nocommit=false 
    204             msg=$(get_log "$status") || conf_cleanExit 
    205             rm -f "$status" 
    206         fi 
    207  
    208         $SUDO ${SUDO:+-v} 
    209  
    210         echo "Commit operation started" >&2 
    211         $nocommit || conf_commit "$(conf_get_recipe)" $msg || return $? 
    212         for layer in $(conf_get_recipe) ; do 
    213             echo "Rolling on $layer..." 
    214             conf_rollout $layer || return $? 
    215         done 
    216         for file in $SINGULARITIES ; do 
    217             conf_assemble_sing $file || return $? 
    218         done 
    219         conf_recordAction commit 
    220         conf_markclean 
    221         echo "Commit operation finished successfully" >&2 
    222         rm -f $msg 
    223         conf_unlock_wcopy 
    224         conf_unlock_system 
    225     else 
    226         print_usage 1 
    227     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 
    228239} 
    229240 
     
    231242function inst { 
    232243    local file livefile 
    233  
    234     if [ -z "$*" ] ; then 
    235         print_usage 1 
    236     else 
    237         conf_require_recipe  
    238         conf_lock_wcopy 
    239         conf_lock_system 
    240         local msg status files file 
    241         local nocommit=true 
    242  
    243         for file in "$@"; do 
    244             files="${files:+${files} }$(${readlink_cmd} -m "$file")" 
    245         done 
    246  
    247  
    248         $SUDO ${SUDO:+-v} 
    249         conf_update_tree || conf_cleanExit 
    250  
    251         if status=$(get_status $files) ; then 
    252             nocommit=false 
    253             msg=$(get_log "$status") || conf_cleanExit 
    254             rm -f "$status" 
    255         fi 
    256  
    257         echo "Installation operation started." >&2 
    258         $nocommit || conf_commit_file "$msg" "$files" || return $? 
    259         for layer in $(conf_get_recipe) ; do 
    260             conf_install $layer "$@" 
    261         done 
    262         for file in $SINGULARITIES ; do 
    263             conf_assemble_sing $file || conf_cleanExit 
    264         done 
    265         conf_recordAction install 
    266         if ! conf_isclean ; then 
    267             echo "WARNING: Recent 'install' operations prevented a 'sync'" >&2 
    268             echo "Running a 'commit' is highly recommended." >&2 
    269         fi 
    270         echo "Installation operation succeeded." >&2 
    271         conf_unlock_wcopy 
    272         conf_unlock_system 
    273     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 
    274293} 
    275294         
     
    935954 
    936955function 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 
     972    echo "$@" >&2 
     973 
    937974    if [ -z "$1" ] ; then print_usage 1 ; fi 
    938     local recipe="$1" 
    939     local new_recipe_file=$(conf_tmp_file) 
    940     local recipe_file=$(conf_recipe_dir)/${recipe} 
    941     local repeat msg status 
     975 
     976    conf_lock_wcopy 
     977    recipe="$1" 
     978    recipe_file=$(conf_recipe_dir)/${recipe} 
     979    new_recipe_file=$(conf_tmp_file) 
    942980 
    943981    cat "$recipe_file" > "$new_recipe_file" 
     
    956994    if status=$(get_status "${recipe_file#${WORK_PATH}/}") ; then 
    957995        msg=$(get_log "$status") || return 1 
    958         conf_commit_recipe "$recipe" "$msg" 
     996        conf_commit_recipe "$msg" "$recipe"  
    959997    fi 
    960998    rm -f "$new_recipe_file" 
     999    conf_unlock_wcopy 
    9611000} 
    9621001 
    9631002function recipe_create { 
    9641003    local recipe recipe_file opt OPTIND msg status 
    965     local recipe_file 
    966     while getopts ":R:" opt ; do 
     1004    while getopts ":m:F:R:" opt ; do 
    9671005        case $opt in 
    9681006            R)  new_recipe_file="$OPTARG" ;; 
     1007            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     1008            F)  LOG_FILE="$OPTARG" ;; 
    9691009            *)  echo "Invalid option '-${OPTARG}' for recipe create." >&4 
    9701010                print_usage 1  
     
    9721012        esac 
    9731013    done 
    974  
    975     eval recipe=\$$OPTIND 
    976     recipe_file=$(conf_recipe_dir)/${recipe} 
     1014    shift $(($OPTIND - 1)) 
     1015 
     1016    eval recipe=$1 
    9771017 
    9781018    if [ -z "$recipe" ] ; then  
     
    9801020    fi 
    9811021 
     1022    conf_lock_wcopy 
     1023    recipe_file=$(conf_recipe_dir)/${recipe} 
    9821024    conf_recipe_create "$recipe" || return 1 
    9831025 
     
    9851027        if ! recipe_edit "$recipe" ; then 
    9861028            conf_rm_file --force "${new_recipe_file}" 
     1029            conf_unlock_wcopy 
    9871030            return 1 
    9881031        fi 
     1032        conf_unlock_wcopy 
    9891033        return 0 
    9901034    fi 
     
    9941038        if status=$(get_status "${recipe_file#${WORK_PATH}/}") ; then 
    9951039            msg=$(get_log "$status") || return 1 
    996             conf_commit_recipe "$recipe" "$msg" 
     1040            conf_commit_recipe "$msg" "$recipe"  
    9971041        fi 
     1042        conf_unlock_wcopy 
    9981043        return 0 
    9991044    else 
    10001045        conf_rm_file --force "${recipe_file}" 
     1046        conf_unlock_wcopy 
    10011047        return 1 
    10021048    fi 
     
    10041050 
    10051051function recipe_remove { 
    1006     if [ -z "$*" ] ; then print_usage 1 ; fi 
     1052    local opt OPTIND OPTARG 
     1053    local msg status recipes recipe 
     1054    local nocommit=true 
     1055    while getopts ":m:F:" opt ; do 
     1056        case $opt in 
     1057            m)  LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
     1058            F)  LOG_FILE="$OPTARG" ;; 
     1059            *)  echo "Invalid option '-${OPTARG}'." >&4 
     1060                print_usage 1 
     1061                ;; 
     1062        esac 
     1063    done 
     1064    shift $(($OPTIND - 1)) 
     1065 
     1066    conf_lock_wcopy 
     1067 
    10071068    conf_remove_recipes "$@" || exit 1 
     1069 
     1070    for recipe in "$@" ; do 
     1071        recipes="${recipes:+${recipes} }$(conf_recipe_dir)/${recipe}" 
     1072    done 
     1073 
     1074    if status=$(get_status $recipes) ; then 
     1075        nocommit=false 
     1076        msg=$(get_log "$status") || conf_cleanExit 
     1077        rm -f "$status" 
     1078    fi 
     1079 
     1080    $nocommit || conf_commit_recipes "$msg" "$@" 
     1081 
     1082    conf_unlock_wcopy 
    10081083} 
    10091084 
     
    10221097        exit 1 
    10231098    fi 
     1099    conf_lock_wcopy 
     1100    conf_lock_system 
    10241101    conf_set_recipe "$recipe" 
     1102    conf_unlock_system 
     1103    conf_unlock_wcopy 
    10251104} 
    10261105 
     
    10411120     
    10421121function recipe_list { 
    1043     cd $(conf_recipe_dir) 
    1044     ls 
     1122    ( 
     1123        cd $(conf_recipe_dir) 
     1124        ls 
     1125    ) 
    10451126} 
    10461127 
     
    10651146 
    10661147# Debug mode? 
    1067 while getopts ":h:dvm:F:-" opt ; do 
     1148while getopts ":h:dv-" opt ; do 
    10681149        case $opt in 
    10691150                d) DEBUG="true" ;; 
    10701151        h) print_help "$OPTARG" ; conf_cleanExit 0 ;; 
    10711152        v) print_version ; conf_cleanExit 0 ;; 
    1072         m) LOG_MESSAGE="$OPTARG"; LOG_MESSAGE_SET="true" ;; 
    1073         F) LOG_FILE="$OPTARG" ;; 
    10741153                *) echo "Invalid options '-${OPTARG}'." >&4 
    10751154           print_usage 1  
  • trunk/confmandoc.sh

    r463 r464  
    224224 
    225225Usage: 
    226     $MYNAME [ -F filename | -m message ] commit 
     226    $MYNAME commit [ -F filename | -m message ] 
    227227 
    228228The commit command causes your changes to take effect. This means that 
     
    260260 
    261261Usage: 
    262     $MYNAME [-F filename | -m message] install workingfile [workingfile [...]] 
     262    $MYNAME install [-F filename | -m message] workingfile [workingfile [...]] 
    263263 
    264264The install subcommand allows you to roll out a single file from your working 
     
    502502  $MYNAME recipe [ get | list ] 
    503503  $MYNAME recipe print [ recipe_name ] 
    504   $MYNAME recipe [ create | edit | print | remove | set ] recipe_name 
     504  $MYNAME recipe set recipe_name 
     505  $MYNAME recipe [ create | edit | remove ] [ -F file | -m msg ] recipe_name 
    505506 
    506507The recipe command provides an interface to manage confman recipes. 
  • trunk/confmanlib.sh.in

    r462 r464  
    980980} 
    981981 
    982 function conf_commit_recipe { 
    983     local recipe="$1" 
    984     local logfile="$2" 
    985     @SVN@ commit -F "$logfile" "$(conf_recipe_dir)/${recipe}" 
     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 
    986993} 
    987994 
    988995function conf_remove_recipes { 
    989     local recipe 
     996    local recipe recipe_file 
    990997    local oldrecipes 
    991998    local rc=0 
     
    9931000    for recipe in "$@"; do 
    9941001        if conf_remove_recipe "$recipe"; then 
    995             # Keep track of the recipes that were successfully removed 
    996             # to avoid inadvertent commits 
    997             if [ -z "$oldrecipes" ]; then 
    998                 oldrecipes="$recipe" 
    999             else 
    1000                 oldrecipes="$oldrecipes,$recipe" 
    1001             fi 
     1002            recipe_file="$(conf_recipe_dir)/${recipe}" 
     1003            oldrecipes="${oldrecipes:+${oldrecipes} }${recipe_file}" 
    10021004        else 
    10031005            rc=1 
    10041006        fi 
    10051007    done 
    1006  
    1007     # $oldrecipes is in the form foo,bar,baz. This eval trick forces 
    1008     # curly brace expansion. 
    1009     if echo "$oldrecipes" | grep -q ','; then 
    1010         @SVN@ commit $(eval echo $(conf_recipe_dir)/{$oldrecipes})  
    1011     else 
    1012         @SVN@ commit "$(conf_recipe_dir)/$oldrecipes" 
    1013     fi 
    10141008 
    10151009    return $rc 
Note: See TracChangeset for help on using the changeset viewer.