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:   09-Jul-2003 14:42:04
  Branch: HEAD                             Handle: 2003070913420300

  Modified files:
    openpkg-src/openpkg     HISTORY rc rpmmacros

  Log:
    1. make sure l_fsl_{ldflags,libs} do not produce an error if fsl-config
       is not existing
    
    2. fully work-off rc script:
       - update copyright message
       - do not double complain about unknown username
       - provide hook for "openpkg-rc" package
       - execute scripts under own "bash" now
       - fixed error message on failed return code
       - output verbose message on exec operation
       - add new --silent/-s option to disable verbose message on exec operation
       - output stdout/stderr of script only on error
       - add check for unresolved config file conflicts
       - rename --verbose/-v option to --debug/-d
       - cleanup some error message
       - complain about command not found (under "all" only if not found anywhere)
       - do not complain and return 0 on --help

  Summary:
    Revision    Changes     Path
    1.8         +2  -0      openpkg-src/openpkg/HISTORY
    1.25        +106 -26    openpkg-src/openpkg/rc
    1.36        +2  -2      openpkg-src/openpkg/rpmmacros
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/HISTORY
  ============================================================================
  $ cvs diff -u -r1.7 -r1.8 HISTORY
  --- openpkg-src/openpkg/HISTORY       9 Jul 2003 08:22:42 -0000       1.7
  +++ openpkg-src/openpkg/HISTORY       9 Jul 2003 12:42:03 -0000       1.8
  @@ -2,6 +2,8 @@
   2003
   ====
   
  +20030709 fully work-off rc script
  +20030709 make sure l_fsl_{ldflags,libs} do not produce an error if fsl-config is 
not existing
   20030709 change syntax of append/prepend feature for %{l_cppflags} and %{l_ldflags} 
macros; fix DB autoconf checks
   20030708 provide append/prepend feature for %{l_cppflags} and %{l_ldflags} macros
   20030707 remove now officially deprecated usage of %{name} macro
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc
  ============================================================================
  $ cvs diff -u -r1.24 -r1.25 rc
  --- openpkg-src/openpkg/rc    5 Mar 2003 18:13:00 -0000       1.24
  +++ openpkg-src/openpkg/rc    9 Jul 2003 12:42:03 -0000       1.25
  @@ -1,9 +1,9 @@
   [EMAIL PROTECTED]@/lib/openpkg/bash --noprofile
   ##
   ##  @l_prefix@/etc/rc -- Run-Command Handling for OpenPKG Hierarchy
  -##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
   ##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
   ##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
  +##  Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.com/>
   ##
   ##  Permission to use, copy, modify, and distribute this software for
   ##  any purpose with or without fee is hereby granted, provided that
  @@ -24,10 +24,16 @@
   ##  SUCH DAMAGE.
   ##
   
  +#   provide hook for "openpkg-rc" package which contains the
  +#   new OSSP rc implementation as a replacement for this script.
  +if [ -f @l_prefix@/lib/openpkg/rc ]; then
  +    exec @l_prefix@/lib/openpkg/rc ${1+"$@"}
  +fi
  +
   #   program name, version and date
   progname="rc"
  -progvers="1.0.10"
  -progdate="21-Feb-2003"
  +progvers="1.1.0"
  +progdate="09-Jul-2003"
   
   #   helper variables
   NL="
  @@ -38,7 +44,8 @@
   ##
   
   #   default parameters
  -verbose=0
  +silent=0
  +debug=0
   help=0
   print=0
   eval=0
  @@ -55,8 +62,9 @@
              *) arg='' ;;
       esac
       case $opt in
  -        -v|--verbose ) verbose=1     ;;
  -        -h|--help    ) help=1        ;;
  +        -s|--silent  ) silent=1      ;;
  +        -d|--debug   ) debug=1       ;;
  +        -h|--help    ) help="Usage"  ;;
           -p|--print   ) print=1       ;;
           -e|--eval    ) eval=1        ;;
           -c|--config  ) config=1      ;;
  @@ -78,9 +86,14 @@
       if [ ".$help" != ".Usage" ]; then
           echo "$progname:ERROR: $help" 1>&2
       fi
  -    echo "Usage: $progname [-v|--verbose] [-h|--help]" 1>&2
  +    echo "Usage: $progname [-d|--debug] [-h|--help]" 1>&2
       echo "       [-p|--print] [-e|--eval] [-c|--config] [-q|--query] [-r|--raw]" 
1>&2
       echo "       <package> <command> [<command> ...]"  1>&2
  +    if [ ".$help" != ".Usage" ]; then
  +        exit 1
  +    else
  +        exit 0
  +    fi
   fi
   
   #   extend run-time environment with our local tools (shtool, rpmtool, etc)
  @@ -91,6 +104,7 @@
   #   set a reasonable temporary location
   tmpdir="/tmp"
   tmpfile="$tmpdir/rc.$$.tmp"
  +logfile="$tmpdir/rc.$$.log"
   TMPDIR="$tmpdir";  export TMPDIR
   TEMPDIR="$tmpdir"; export TEMPDIR
   
  @@ -157,13 +171,19 @@
   fi
   
   #   determine script(s) to use
  +if [ $# -lt 1 ]; then
  +    echo "openpkg:rc:ERROR: no package and command(s) specified" 1>&2
  +    exit 1
  +fi
   if [ $# -lt 2 ]; then
  -    echo "$0:ERROR: no package and command(s) specified" 1>&2
  +    echo "openpkg:rc:ERROR: no command(s) specified for package" 1>&2
       exit 1
   fi
   scripts=`echo "$1" | sed -e 's;^.*rc\.;;'`
   shift
  +isall=0
   if [ ".$scripts" = ".all" ]; then
  +    isall=1
       . $rcconf
       case "$openpkg_runall" in
           [Nn][Oo] | [Ff][Aa][Ll][Ss][Ee] | [Oo][Ff][Ff] | 0 ) exit 0 ;;
  @@ -171,7 +191,7 @@
       scripts=`/bin/ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;"`
   else
       if [ ! -f "$rcdir/rc.$scripts" ]; then
  -        echo "$0:ERROR: script \`$rcdir/rc.$scripts' not found" 1>&2
  +        echo "openpkg:rc:ERROR: package \"$scripts\" not found" 1>&2
           exit 1
       fi
   fi
  @@ -186,11 +206,10 @@
               user="$LOGNAME"
           fi
           if [ ".$user" = . ]; then
  -            echo "$0:ERROR: unable to determine current username" 1>&2
               if [ ".$user" = . ]; then
                   user="$USER"
                   if [ ".$user" = . ]; then
  -                    echo "$0:ERROR: unable to determine current username" 1>&2
  +                    echo "openpkg:rc:ERROR: unable to determine current username" 
1>&2
                       exit 1
                   fi
               fi
  @@ -209,6 +228,13 @@
       for s_name in $scripts; do
           enable=yes
   
  +        #   check for upgraded package with unresolved configuration file conflicts
  +        if [ -d @l_prefix@/etc/$s_name ]; then
  +            if [ ".`find @l_prefix@/etc/$s_name -print 2>/dev/null | egrep 
'.*\.rpm(new|orig|save)$'`" != . ]; then
  +                echo "openpkg:rc:WARNING: package \"$s_name\" has unresolved 
configuration file conflicts" 1>&2
  +            fi
  +        fi
  +
           #   check script options
           shebangline=`head -1 $rcdir/rc.$s_name | grep "^#!rc"`
           if [ ".$shebangline" != . ]; then
  @@ -229,7 +255,7 @@
                   case $opt in
                       -e|--enable  ) enable=yes ;;
                       -d|--disable ) enable=no  ;;
  -                    *          ) echo "$0:ERROR: invalid option \`$opt' in 
\`$rcdir/rc.$s_name:#!rc'"; break ;;
  +                    *            ) echo "openpkg:rc:WARNING: invalid option 
\"$opt\" in \"$rcdir/rc.$s_name:#!rc\""; break ;;
                   esac
                   shift
               done
  @@ -260,12 +286,12 @@
                       -d|--disable  ) enable=no    ;;
                       -u*|--user=*  ) s_user=$arg  ;;
                       -p*|--prio=*  ) s_prio=$arg  ;;
  -                    *             ) echo "$0:ERROR: invalid option \`$opt' in 
\`$rcdir/rc.$s_name'"; break ;;
  +                    *             ) echo "openpkg:rc:WARNING: invalid option 
\"$opt\" in \"$rcdir/rc.$s_name:%$cmd\""; break ;;
                   esac
                   shift
               done
               if [ ".$s_user" != ".$user" -a ".$user" != ".root" ]; then
  -                echo "$0:ERROR: require root privileges to run 
\`$rcdir/rc.$s_name:$cmd' as user \`$s_user'" 1>&2
  +                echo "openpkg:rc:ERROR: $s_name:%$cmd: require root privileges to 
run as user \"$s_user\"" 1>&2
                   exit 1
               fi
               #   skip script if disabled
  @@ -273,22 +299,58 @@
                   continue
               fi
               list="$list,$s_prio:$s_name:$s_user"
  +        else
  +            if [ ".$isall" = .0 ]; then
  +                echo "openpkg:rc:ERROR: $s_name: command \"$cmd\" not found" 1>&2
  +                exit 1
  +            fi
           fi
       done
  +    if [ ".$list" = . -a ".$isall" = .1 ]; then
  +        echo "openpkg:rc:ERROR: command \"$cmd\" not found in any script" 1>&2
  +        exit 1
  +    fi
   
       #   execute/print the scripts in order
       if [ ".$print" = .1 -o ".$eval" = .1 ]; then
           rm -f $tmpfile
           touch $tmpfile
  -        if [ ".$verbose" = .1 ]; then
  +        if [ ".$debug" = .1 ]; then
               echo "set -x" >>$tmpfile
           fi
       fi
  +    verbose_first=1
  +    verbose_output=0
  +    verbose_pos=0
       for entry in `echo $list | tr ',' '\012' | sort -n`; do
           test ".$entry" = . && continue
           eval `echo $entry | sed -e 's%^[0-9]*:\(.*\):\(.*\)$%s_name="\1"; 
s_user="\2"%'`
  -        if [ ".$verbose" = .1 ]; then
  -            echo "$0: executing $rcdir/rc.$s_name [%$cmd] as user $s_user" 1>&2
  +        if [ ".$print" = .0 -a ".$eval" = .0 ]; then
  +            if [ $verbose_pos -gt 70 ]; then
  +                verbose_pos=0
  +                verbose_first=1
  +                echo "" 1>&2
  +            fi
  +            if [ ".$verbose_first" = .1 ]; then
  +                verbose_first=0
  +                if [ ".$silent" != .1 ]; then
  +                    verbose_output=1
  +                    echo . | awk '{ printf("OpenPKG: %s: ", cmd); }' cmd="$cmd" 1>&2
  +                    l=`echo . | awk '{ printf("OpenPKG: %s: ", cmd); }' cmd="$cmd" 
| wc -c`
  +                    verbose_pos=`expr $verbose_pos + $l`
  +                fi
  +                prefix=""
  +            else
  +                prefix=", "
  +            fi
  +            if [ ".$silent" != .1 ]; then
  +                echo . | awk '{ printf("%s%s", prefix, s_name); }' prefix="$prefix" 
s_name="$s_name" 1>&2
  +                l=`echo . | awk '{ printf("%s%s", prefix, s_name); }' 
prefix="$prefix" s_name="$s_name" | wc -c`
  +                verbose_pos=`expr $verbose_pos + $l`
  +            fi
  +        fi
  +        if [ ".$debug" = .1 ]; then
  +            echo "openpkg:rc:DEBUG: executing \"$rcdir/rc.$s_name:%$cmd\" as user 
\"$s_user\"" 1>&2
           fi
           if [ ".$print" = .1 -o ".$eval" = .1 ]; then
               echo ". $rcfunc" >>$tmpfile
  @@ -303,7 +365,9 @@
           fi
           rm -f $tmpfile
           touch $tmpfile
  -        if [ ".$verbose" = .1 ]; then
  +        rm -f $logfile
  +        touch $logfile
  +        if [ ".$debug" = .1 ]; then
               echo "set -x" >>$tmpfile
           fi
           echo ". $rcfunc" >>$tmpfile
  @@ -314,26 +378,42 @@
           echo ". $rcconf" >>$tmpfile
           sed <$rcdir/rc.$s_name >>$tmpfile -e "1,/^%common/d" -e '/^%.*/,$d'
           sed <$rcdir/rc.$s_name >>$tmpfile -e "1,/^%$cmd/d" -e '/^%.*/,$d'
  -        sh='sh'
  +        sh="@l_prefix@/lib/openpkg/bash"
           if [ ".$user" != ".$s_user" ]; then
  -            su - $s_user -c "PATH=\"$PATH\"; sh $tmpfile"
  +            su - $s_user -c "PATH=\"$PATH\"; $sh $tmpfile" >$logfile 2>&1
               rc=$?
           else
  -            sh $tmpfile
  +            $sh $tmpfile >$logfile 2>&1
               rc=$?
           fi
           if [ $rc -ne 0 ]; then
  -            echo "$0:WARNING: script \`$rcdir/rc.$s_name:$cmd' returned non-null 
($#) return code" 1>&2
  +            echo ":FAILED" 1>&2
  +            echo "openpkg:rc:WARNING: $s_name:%$cmd: failed with return code $rc" 
1>&2
  +            if [ ".`cat $logfile`" != . ]; then
  +                ( echo 
"+----Output:-----------------------------------------------------------"
  +                  cat $logfile | sed -e 's;^;| ;'
  +                  echo 
"+----------------------------------------------------------------------"
  +                ) 1>&2
  +            fi
  +            verbose_first=1
  +            verbose_pos=0
           fi
       done
  -    if [ ".$print" = .1 ]; then
  -        cat $tmpfile
  -    elif [ ".$eval" = .1 ]; then
  -        echo ". $tmpfile; rm -f $tmpfile 2>/dev/null || true"
  +    if [ ".$print" = .1 -o ".$eval" = .1 ]; then
  +        if [ ".$print" = .1 ]; then
  +            cat $tmpfile
  +        elif [ ".$eval" = .1 ]; then
  +            echo ". $tmpfile; rm -f $tmpfile 2>/dev/null || true"
  +        fi
  +    else
  +        if [ ".$silent" != .1 -a ".$verbose_output" = .1 ]; then
  +            echo "." 1>&2
  +        fi
       fi
   done
   
   #   cleanup
  +rm -f $logfile >/dev/null 2>&1 || true
   if [ ".$eval" = .0 ]; then
       rm -f $tmpfile >/dev/null 2>&1 || true
   fi
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpmmacros
  ============================================================================
  $ cvs diff -u -r1.35 -r1.36 rpmmacros
  --- openpkg-src/openpkg/rpmmacros     8 Jul 2003 12:19:09 -0000       1.35
  +++ openpkg-src/openpkg/rpmmacros     9 Jul 2003 12:42:03 -0000       1.36
  @@ -166,8 +166,8 @@
   %l_ldflags()             %(%{l_sane_env}; %{l_rpmtool} ldflags  -p%{l_prefix} -- %*)
   
   #   OSSP fake syslog library
  -%l_fsl_ldflags()         %(if [ ".%{with_fsl}" = ".yes" ]; then 
flags=`%{l_prefix}/bin/fsl-config --all --ldflags`; else flags=''; fi; echo $flags)
  -%l_fsl_libs()            %(if [ ".%{with_fsl}" = ".yes" ]; then 
flags=`%{l_prefix}/bin/fsl-config --all --libs`; else flags=''; fi; echo $flags)
  +%l_fsl_ldflags()         %(if [ ".%{with_fsl}" = ".yes" ]; then 
flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; else flags=''; fi; 
echo $flags)
  +%l_fsl_libs()            %(if [ ".%{with_fsl}" = ".yes" ]; then 
flags=`(%{l_prefix}/bin/fsl-config --all --libs   ) 2>/dev/null`; else flags=''; fi; 
echo $flags)
   
   #   determine the current username
   %l_whoami                %((id -un) 2>/dev/null || (whoami) 2>/dev/null || (who am 
i | cut "-d " -f1) 2>/dev/null || echo $LOGNAME)
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to