OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src                      Date:   04-Jun-2004 17:25:17
  Branch: HEAD                             Handle: 2004060416251700

  Modified files:
    openpkg-src/openpkg     HISTORY rc rc.8 rc.pod

  Log:
    - revise the stderr processing of run-command processor in case of -d/--debug
    - add -k/--keep option to run-command processor for debug purposes
    
    Submitted by: Christian Reiber <[EMAIL PROTECTED]>

  Summary:
    Revision    Changes     Path
    1.189       +2  -0      openpkg-src/openpkg/HISTORY
    1.57        +80 -23     openpkg-src/openpkg/rc
    1.5         +5  -3      openpkg-src/openpkg/rc.8
    1.5         +4  -2      openpkg-src/openpkg/rc.pod
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/HISTORY
  ============================================================================
  $ cvs diff -u -r1.188 -r1.189 HISTORY
  --- openpkg-src/openpkg/HISTORY       4 Jun 2004 14:38:31 -0000       1.188
  +++ openpkg-src/openpkg/HISTORY       4 Jun 2004 15:25:17 -0000       1.189
  @@ -2,6 +2,8 @@
   2004
   ====
   
  +20040604 revise the stderr processing of run-command processor in case of -d/--debug
  +20040604 add -k/--keep option to run-command processor for debug purposes
   20040604 add GNU bash 2.05b vendor patches 001-007
   20040604 port to HP-UX 11.11 platform
   20040602 upgrade to cURL 7.12.0
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc
  ============================================================================
  $ cvs diff -u -r1.56 -r1.57 rc
  --- openpkg-src/openpkg/rc    2 Jun 2004 08:52:59 -0000       1.56
  +++ openpkg-src/openpkg/rc    4 Jun 2004 15:25:17 -0000       1.57
  @@ -64,6 +64,7 @@
   verbose=0
   debug=0
   help=0
  +keep=0
   print=0
   eval=0
   config=0
  @@ -81,6 +82,7 @@
           -v|--verbose ) verbose=1     ;;
           -d|--debug   ) debug=1       ;;
           -h|--help    ) help="Usage"  ;;
  +        -k|--keep    ) keep=1        ;;
           -p|--print   ) print=1       ;;
           -e|--eval    ) eval=1        ;;
           -c|--config  ) config=1      ;;
  @@ -96,7 +98,7 @@
       if [ ".$help" != ".Usage" ]; then
           echo "$progname:ERROR: $help" 1>&2
       fi
  -    echo "Usage: $progname [-s|--silent] [-v|--verbose] [-d|--debug] [-h|--help]" 
1>&2
  +    echo "Usage: $progname [-s|--silent] [-v|--verbose] [-d|--debug] [-k|--keep] 
[-h|--help]" 1>&2
       echo "       [-p|--print] [-e|--eval] [-c|--config] [-q|--query]" 1>&2
       echo "       <package> <command> [<command> ...]"  1>&2
       if [ ".$help" != ".Usage" ]; then
  @@ -411,8 +413,13 @@
           echo ". $rcconf" >>$tmpfile
   
           #   for --eval redirect stderr and stdout (but remember stdout)
  +        #   (let stderr pass unfiltered in case of debug mode)
           if [ ".$eval" = .1 ]; then
  -            echo "exec 3<&1- 1>/dev/null 2>/dev/null" >>$tmpfile
  +            if [ ".$debug" = .1 ]; then
  +               echo "exec 3<&1- 1>/dev/null" >>$tmpfile
  +            else
  +               echo "exec 3<&1- 1>/dev/null 2>/dev/null" >>$tmpfile
  +            fi
           fi
       fi
   
  @@ -507,9 +514,17 @@
               #   execute the generated script with GNU Bash
               if [ ".$user" != ".$s_user" ]; then
                   #   execute as different user
  +                if [ ".$verbose" = .1 ]; then
  +                    echo "openpkg:rc:NOTICE: $prefix:$s_name:%$cmd: executing as 
user $s_user"
  +                fi 
                   if [ ".$user" = "[EMAIL PROTECTED]@" -a "[EMAIL PROTECTED]@" = 
".root" ]; then
  -                    su - $s_user -c "PATH=\"$PATH\"; $bash $tmpfile" >$outfile 
2>$errfile
  -                    rc=$?
  +                    if [ ".$debug" = .1 ]; then
  +                        su - $s_user -c "PATH=\"$PATH\"; $bash $tmpfile" >$outfile
  +                        rc=$?
  +                    else
  +                        su - $s_user -c "PATH=\"$PATH\"; $bash $tmpfile" >$outfile 
2>$errfile
  +                        rc=$?
  +                    fi
                   elif [ "[EMAIL PROTECTED]@" != ".root" ]; then
                       #   do not complain if we would not have any chance
                       #   at all to switch the user because we are running
  @@ -523,8 +538,16 @@
                   fi
               else
                   #   execute as current user
  -                $bash $tmpfile >$outfile 2>$errfile
  -                rc=$?
  +                if [ ".$verbose" = .1 ]; then
  +                    echo "openpkg:rc:NOTICE: $prefix:$s_name:%$cmd: executing as 
user $user"
  +                fi 
  +                if [ ".$debug" = .1 ]; then
  +                    $bash $tmpfile >$outfile
  +                    rc=$?
  +                else
  +                    $bash $tmpfile >$outfile 2>$errfile
  +                    rc=$?
  +                fi
               fi
               if [ $rc -ne 0 ]; then
                   if [ ".$silent" = .0 ]; then
  @@ -533,17 +556,33 @@
                       verbose_pos=0
                   fi
                   #   give details of execution failure
  -                ( echo "openpkg:rc:WARNING: $prefix:$s_name:%$cmd: failed with 
return code $rc" 1>&2
  +                ( echo "openpkg:rc:WARNING: $prefix:$s_name:%$cmd: failed with 
return code $rc"
                     if [ ".`cat $outfile $errfile`" != . ]; then
  -                      echo 
"+----Log:--------------------------------------------------------------"
  +                      echo "openpkg:rc:NOTICE: output from stdout/stderr is 
following:"
  +                      echo 
"+----------------------------------------------------------------------"
                         cat $outfile $errfile | sed -e 's;^;| ;'
                         echo 
"+----------------------------------------------------------------------"
  +                  else
  +                      echo "openpkg:rc:NOTICE: no output occurred on stdout/stderr"
                     fi
                   ) 1>&2
   
                   #   enforce global return value
                   rv=1
               else
  +                #   give details of execution success in case verbose operation is 
requested
  +                if [ ".$verbose" = .1 ]; then
  +                    ( echo "openpkg:rc:NOTICE: $prefix:$s_name:%$cmd: succeeded 
with return code $rc"
  +                      if [ ".`cat $outfile $errfile`" != . ]; then
  +                          echo "openpkg:rc:NOTICE: output from stdout/stderr is 
following:"
  +                          echo 
"+----------------------------------------------------------------------"
  +                          cat $outfile $errfile | sed -e 's;^;| ;'
  +                          echo 
"+----------------------------------------------------------------------"
  +                      else
  +                          echo "openpkg:rc:NOTICE: no output occurred on 
stdout/stderr"
  +                      fi
  +                    ) 1>&2
  +                fi
                   if [ ".$s_output" = .yes ]; then
                       #   accumulate script output for later display
                       cat $outfile >>$allfile
  @@ -580,17 +619,32 @@
   
           #   now replace temporary script with its output
           #   by executing it and capturing its output
  -        env -i \
  -            HOME="$HOME" \
  -            USER="$USER" \
  -            LOGNAME="$LOGNAME" \
  -            TERM="$TERM" \
  -            PATH="$PATH_ORIG" \
  -            MANPATH="$MANPATH" \
  -            INFOPATH="$INFOPATH" \
  -            LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
  -            $bash --norc --noprofile --posix \
  -            $tmpfile >$outfile 2>/dev/null
  +        #   (let stderr pass unfiltered in case of debug mode)
  +        if [ ".$debug" = .1 ]; then
  +            env -i \
  +                HOME="$HOME" \
  +                USER="$USER" \
  +                LOGNAME="$LOGNAME" \
  +                TERM="$TERM" \
  +                PATH="$PATH_ORIG" \
  +                MANPATH="$MANPATH" \
  +                INFOPATH="$INFOPATH" \
  +                LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
  +                $bash --norc --noprofile --posix \
  +                $tmpfile >$outfile
  +        else
  +            env -i \
  +                HOME="$HOME" \
  +                USER="$USER" \
  +                LOGNAME="$LOGNAME" \
  +                TERM="$TERM" \
  +                PATH="$PATH_ORIG" \
  +                MANPATH="$MANPATH" \
  +                INFOPATH="$INFOPATH" \
  +                LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
  +                $bash --norc --noprofile --posix \
  +                $tmpfile >$outfile 2>/dev/null
  +        fi
           cp $outfile $tmpfile
   
           #   for --eval we cannot just print the resulting script because
  @@ -622,10 +676,13 @@
   
   #   cleanup temporary files except the result script in
   #   case of --eval (which is then removed by the caller).
  -rm -f $outfile $errfile $allfile >/dev/null 2>&1 || true
  -if [ ".$eval" = .0 ]; then
  -    rm -f $tmpfile >/dev/null 2>&1 || true
  -    rm -rf $tmpdir >/dev/null 2>&1 || true
  +#   keep those files for debugging purposes if requested.
  +if [ ".$keep" = .0 ]; then
  +    rm -f $outfile $errfile $allfile >/dev/null 2>&1 || true
  +    if [ ".$eval" = .0 ]; then
  +        rm -f $tmpfile >/dev/null 2>&1 || true
  +        rm -rf $tmpdir >/dev/null 2>&1 || true
  +    fi
   fi
   
   #   now clean the exit trap and exit with the global return value
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc.8
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 rc.8
  --- openpkg-src/openpkg/rc.8  21 Feb 2004 19:11:34 -0000      1.4
  +++ openpkg-src/openpkg/rc.8  4 Jun 2004 15:25:17 -0000       1.5
  @@ -134,7 +134,7 @@
   \&[EMAIL PROTECTED]@/etc/rc\fR \- OpenPKG Run\-Command Processor
   .SH "SYNOPSIS"
   .IX Header "SYNOPSIS"
  -\&[EMAIL PROTECTED]@/etc/rc\fR [\fB\-s\fR|\fB\-\-silent\fR] 
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] \fIpackage\fR \fIcommand\fR 
[\fIcommand\fR ...]
  +\&[EMAIL PROTECTED]@/etc/rc\fR [\fB\-s\fR|\fB\-\-silent\fR] 
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] [\fB\-k\fR|\fB\-\-keep\fR] 
\fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]
   .PP
   \&[EMAIL PROTECTED]@/etc/rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR 
\fIcommand\fR [\fIcommand\fR ...]
   .PP
  @@ -157,8 +157,8 @@
   procedures with periodical procedures into a single approach.
   .SH "USAGE"
   .IX Header "USAGE"
  -.IP "[EMAIL PROTECTED]@/etc/rc\fR [\fB\-s\fR|\fB\-\-silent\fR] 
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] \fIpackage\fR \fIcommand\fR 
[\fIcommand\fR ...]" 4
  -.IX Item "@l_prefix@/etc/rc [-s|--silent] [-v|--verbose] [-d|--debug] package 
command [command ...]"
  +.IP "[EMAIL PROTECTED]@/etc/rc\fR [\fB\-s\fR|\fB\-\-silent\fR] 
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] [\fB\-k\fR|\fB\-\-keep\fR] 
\fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]" 4
  +.IX Item "@l_prefix@/etc/rc [-s|--silent] [-v|--verbose] [-d|--debug] [-k|--keep] 
package command [command ...]"
   \&\fBRun-Command Execution.\fR This executes one or more specified
   \&\fIcommand\fRs in a particular \fIpackage\fR or in all installed packages if
   \&\fIpackage\fR is "\f(CW\*(C`all\*(C'\fR". Option \fB\-\-silent\fR can be used to 
explicitly
  @@ -166,6 +166,8 @@
   to explicitly enable progress messages on \f(CW\*(C`stderr\*(C'\fR. By default, 
\fBrc\fR
   automatically determines whether progress messages should be displayed
   or not depending on whether \f(CW\*(C`stderr\*(C'\fR is connected to a terminal 
device.
  +Option \fB\-\-keep\fR can be used for debugging purposes to keep the
  +temporary files were generated during internal processing.
   .IP "[EMAIL PROTECTED]@/etc/rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR 
\fIcommand\fR [\fIcommand\fR ...]" 4
   .IX Item "@l_prefix@/etc/rc -p|--print package command [command ...]"
   \&\fBRun-Command Printing.\fR This is like the run-command execution (see
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc.pod
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 rc.pod
  --- openpkg-src/openpkg/rc.pod        23 Jan 2004 12:46:08 -0000      1.4
  +++ openpkg-src/openpkg/rc.pod        4 Jun 2004 15:25:17 -0000       1.5
  @@ -31,7 +31,7 @@
   
   =head1 SYNOPSIS
   
  -B<@l_prefix@/etc/rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] [B<-d>|B<--debug>] 
I<package> I<command> [I<command> ...]
  +B<@l_prefix@/etc/rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] [B<-d>|B<--debug>] 
[B<-k>|B<--keep>] I<package> I<command> [I<command> ...]
   
   B<@l_prefix@/etc/rc> B<-p>|B<--print> I<package> I<command> [I<command> ...]
   
  @@ -58,7 +58,7 @@
   
   =over 4
   
  -=item B<@l_prefix@/etc/rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] 
[B<-d>|B<--debug>] I<package> I<command> [I<command> ...]
  +=item B<@l_prefix@/etc/rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] 
[B<-d>|B<--debug>] [B<-k>|B<--keep>] I<package> I<command> [I<command> ...]
   
   B<Run-Command Execution.> This executes one or more specified
   I<command>s in a particular I<package> or in all installed packages if
  @@ -67,6 +67,8 @@
   to explicitly enable progress messages on C<stderr>. By default, B<rc>
   automatically determines whether progress messages should be displayed
   or not depending on whether C<stderr> is connected to a terminal device.
  +Option B<--keep> can be used for debugging purposes to keep the
  +temporary files were generated during internal processing.
   
   =item B<@l_prefix@/etc/rc> B<-p>|B<--print> I<package> I<command> [I<command> ...]
   
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to