OSSP CVS Repository

ossp - Difference in ossp-pkg/pcre/shtool versions 1.6 and 1.7
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/pcre/shtool 1.6 -> 1.7

--- shtool       2000/08/02 09:46:06     1.6
+++ shtool       2001/08/11 19:51:49     1.7
@@ -1,12 +1,12 @@
 #!/bin/sh
 ##
 ##  GNU shtool -- The GNU Portable Shell Tool
-##  Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
+##  Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>
 ##
 ##  See http://www.gnu.org/software/shtool/ for more information.
 ##  See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
 ##
-##  Version:  1.5.1 (29-Jul-2000)
+##  Version:  1.5.4 (14-Jun-2001)
 ##  Contents: 6/17 available modules
 ##
 
@@ -26,7 +26,7 @@
 ##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
 ##
-##  Notice: Given that you include this file verbatim into your own
+##  NOTICE: Given that you include this file verbatim into your own
 ##  source tree, you are justified in saying that it remains separate
 ##  from your package, and that this way you are simply just using GNU
 ##  shtool. So, in this situation, there is no requirement that your
@@ -65,11 +65,11 @@
     exit 1
 fi
 if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
-    echo "This is GNU shtool, version 1.5.1 (29-Jul-2000)"
-    echo "Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>"
+    echo "This is GNU shtool, version 1.5.4 (14-Jun-2001)"
+    echo "Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>"
     echo "Report bugs to <bug-shtool@gnu.org>"
     echo ''
-    echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]" 
+    echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
     echo ''
     echo 'Available global <options>:'
     echo '  -v, --version   display shtool version information'
@@ -80,11 +80,11 @@
     echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
     echo '  echo     [-n] [-e] [<str> ...]'
     echo '  install  [-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>]'
-    echo '           [-e<ext>] <file> [<file> ...] <path>'
+    echo '           [-e<sed-cmd>] <file> [<file> ...] <path>'
     echo '  mkdir    [-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]'
     echo '  fixperm  [-v] [-t] <path> [<path> ...]'
-    echo '  tarball  [-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u'
-    echo '           <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]'
+    echo '  tarball  [-t] [-v] [-o<tarball>] [-c<prog>] [-d<dir>] [-u<user>]'
+    echo '           [-g<group>] [-e<pattern>] <path> [<path> ...]'
     echo '  guessos  '
     echo ''
     echo 'Not available <cmd-name> (because module was not built-in):'
@@ -105,7 +105,7 @@
     exit 0
 fi
 if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
-    echo "GNU shtool 1.5.1 (29-Jul-2000)"
+    echo "GNU shtool 1.5.4 (14-Jun-2001)"
     exit 0
 fi
 if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
@@ -147,15 +147,15 @@
         ;;
     install )
         str_tool="install"
-        str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<ext>] <file> [<file> ...] <path>"
+        str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<sed-cmd>] <file> [<file> ...] <path>"
         arg_spec="2+"
-        opt_spec="v.t.c.C.s.m:o:g:e:"
+        opt_spec="v.t.c.C.s.m:o:g:e+"
         opt_v=no
         opt_t=no
         opt_c=no
         opt_C=no
         opt_s=no
-        opt_m=""
+        opt_m="0755"
         opt_o=""
         opt_g=""
         opt_e=""
@@ -180,7 +180,7 @@
         ;;
     tarball )
         str_tool="tarball"
-        str_usage="[-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]"
+        str_usage="[-t] [-v] [-o<tarball>] [-c<prog>] [-d<dir>] [-u<user>] [-g<group>] [-e<pattern>] <path> [<path> ...]"
         gen_tmpfile=yes
         arg_spec="1+"
         opt_spec="t.v.o:c:d:u:g:e:"
@@ -346,6 +346,7 @@
     tmpfile="$tmpdir/.shtool.$$"
     rm -f $tmpfile >/dev/null 2>&1
     touch $tmpfile
+    chmod 600 $tmpfile
 fi
 
 ##
@@ -357,7 +358,7 @@
 echo )
     ##
     ##  echo -- Print string with optional construct expansion
-    ##  Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+    ##  Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
     ##  Originally written for WML as buildinfo
     ##
     
@@ -381,7 +382,7 @@
     fi
     
     #   determine terminal bold sequence
-    term_bold='' 
+    term_bold=''
     term_norm=''
     if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
         case $TERM in
@@ -432,7 +433,7 @@
     
     #   determine user name
     username=''
-    if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then
+    if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uUgG]'`" != . ]; then
         username="$LOGNAME"
         if [ ".$username" = . ]; then
             username="$USER"
@@ -474,8 +475,38 @@
         fi
     fi
     
-    #   determine host name
+    #   determine (primary) group id
+    groupid=''
+    if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[gG]'`" != . ]; then
+        groupid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
+                 sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
+        if [ ".$groupid" = . ]; then
+            groupid=`(ypcat passwd) 2>/dev/null | egrep "^${username}:" | \
+                     sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
+            if [ ".$groupid" = . ]; then
+                groupid='?'
+            fi
+        fi
+    fi
+    
+    #   determine (primary) group name
+    groupname=''
+    if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%g'`" != . ]; then
+        groupname=`egrep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
+                   sed -e 's/:.*$//'`
+        if [ ".$groupname" = . ]; then
+            groupname=`(ypcat group) 2>/dev/null | \
+                       egrep "^[^:]*:[^:]*:${groupid}:" | \
+                       sed -e 's/:.*$//'`
+            if [ ".$groupname" = . ]; then
+                groupname='?'
+            fi
+        fi
+    fi
+    
+    #   determine host and domain name
     hostname=''
+    domainname=''
     if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%h'`" != . ]; then
         hostname="`(uname -n) 2>/dev/null |\
                    awk '{ printf("%s", $1); }'`"
@@ -493,9 +524,6 @@
                 ;;
         esac
     fi
-    
-    #   determine domain name
-    domainname=''
     if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%d'`" != . ]; then
         if [ ".$domainname" = . ]; then
             if [ -f /etc/resolv.conf ]; then
@@ -555,6 +583,8 @@
                   -e "s/%b/${term_norm}/g" \
                   -e "s/%u/${username}/g" \
                   -e "s/%U/${userid}/g" \
+                  -e "s/%g/${groupname}/g" \
+                  -e "s/%G/${groupid}/g" \
                   -e "s/%h/${hostname}/g" \
                   -e "s/%d/${domainname}/g" \
                   -e "s/%D/${time_day}/g" \
@@ -580,11 +610,11 @@
 install )
     ##
     ##  install -- Install a program, script or datafile
-    ##  Copyright (c) 1997-2000 Ralf S. Engelschall <rse@engelschall.com>
+    ##  Copyright (c) 1997-2001 Ralf S. Engelschall <rse@engelschall.com>
     ##  Originally written for shtool
     ##
     
-    #   determine source(s) and destination 
+    #   determine source(s) and destination
     argc=$#
     srcs=""
     while [ $# -gt 1 ]; do
@@ -610,19 +640,13 @@
     for src in $srcs; do
         dst=$dstpath
     
-        #  If destination is a directory, append the input filename
+        #   if destination is a directory, append the input filename
         if [ $dstisdir = 1 ]; then
             dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
             dst="$dst/$dstfile"
         fi
     
-        #  Add a possible extension to src and dst
-        if [ ".$opt_e" != . ]; then
-            src="$src$opt_e"
-            dst="$dst$opt_e"
-        fi
-    
-        #  Check for correct arguments
+        #   check for correct arguments
         if [ ".$src" = ".$dst" ]; then
             echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
             continue
@@ -632,18 +656,18 @@
             continue
         fi
     
-        #  Make a temp file name in the destination directory
+        #   make a temp file name in the destination directory
         dsttmp=`echo $dst |\
                 sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
                     -e "s;\$;/#INST@$$#;"`
     
-        #  Verbosity
+        #   verbosity
         if [ ".$opt_v" = .yes ]; then
             echo "$src -> $dst" 1>&2
         fi
     
-        #  Copy or move the file name to the temp name
-        #  (because we might be not allowed to change the source)
+        #   copy or move the file name to the temp name
+        #   (because we might be not allowed to change the source)
         if [ ".$opt_C" = .yes ]; then
             opt_c=yes
         fi
@@ -659,8 +683,16 @@
             mv $src $dsttmp || exit $?
         fi
     
-        #  Adjust the target file
-        #  (we do chmod last to preserve setuid bits)
+        #   adjust the target file
+        if [ ".$opt_e" != . ]; then
+            sed='sed'
+            for e in $opt_e; do
+                sed="$sed -e '$e'"
+            done
+            cp $dsttmp $dsttmp.old
+            eval "$sed <$dsttmp.old >$dsttmp" || exit $?
+            rm -f $dsttmp.old
+        fi
         if [ ".$opt_s" = .yes ]; then
             if [ ".$opt_t" = .yes ]; then
                 echo "strip $dsttmp" 1>&2
@@ -679,14 +711,14 @@
             fi
             chgrp $opt_g $dsttmp || exit $?
         fi
-        if [ ".$opt_m" != . ]; then
+        if [ ".$opt_m" != ".-" ]; then
             if [ ".$opt_t" = .yes ]; then
                 echo "chmod $opt_m $dsttmp" 1>&2
             fi
             chmod $opt_m $dsttmp || exit $?
         fi
     
-        #   Determine whether to do a quick install
+        #   determine whether to do a quick install
         #   (has to be done _after_ the strip was already done)
         quick=no
         if [ ".$opt_C" = .yes ]; then
@@ -697,7 +729,7 @@
             fi
         fi
     
-        #   Finally install the file to the real destination
+        #   finally, install the file to the real destination
         if [ $quick = yes ]; then
             if [ ".$opt_t" = .yes ]; then
                 echo "rm -f $dsttmp" 1>&2
@@ -715,7 +747,7 @@
 mkdir )
     ##
     ##  mkdir -- Make one or more directories
-    ##  Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
+    ##  Copyright (c) 1996-2001 Ralf S. Engelschall <rse@engelschall.com>
     ##  Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
     ##  Cleaned up and enhanced for shtool
     ##
@@ -724,7 +756,7 @@
     for p in ${1+"$@"}; do
         #   if the directory already exists...
         if [ -d "$p" ]; then
-            if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
+            if [ ".$opt_f" = .no -a ".$opt_p" = .no ]; then
                 echo "$msgprefix:Error: directory already exists: $p" 1>&2
                 errstatus=1
                 break
@@ -738,6 +770,12 @@
                 echo "mkdir $p" 1>&2
             fi
             mkdir $p || errstatus=$?
+            if [ ".$opt_m" != . ]; then
+                if [ ".$opt_t" = .yes ]; then
+                    echo "chmod $opt_m $p" 1>&2
+                fi
+                chmod $opt_m $p || errstatus=$?
+            fi
         else
             #   the smart situation
             set fnord `echo ":$p" |\
@@ -774,7 +812,7 @@
 fixperm )
     ##
     ##  fixperm -- Fix file permissions inside a source tree
-    ##  Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
+    ##  Copyright (c) 1996-2001 Ralf S. Engelschall <rse@engelschall.com>
     ##  Originally written for ePerl
     ##
     
@@ -830,7 +868,7 @@
 tarball )
     ##
     ##  tarball -- Roll distribution tarballs
-    ##  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+    ##  Copyright (c) 1999-2001 Ralf S. Engelschall <rse@engelschall.com>
     ##  Originally written for shtool
     ##
     
@@ -856,7 +894,7 @@
         for tool in `echo $tools | sed -e 's/,/ /g'`; do
             #   iterate over paths
             for path in $paths; do
-                if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then
+                if [ $minusx "$path/$tool" -a ! -d "$path/$tool" ]; then
                     eval "prg_${prg}=\"$path/$tool\""
                     break
                 fi
@@ -882,7 +920,7 @@
             if [ ".$opt_t" = .yes ]; then
                 echo "(cd $src && $prg_find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2
             fi
-            (cd $src && find . -type f -depth -print) |\
+            (cd $src && $prg_find . -type f -depth -print) |\
             sed -e 's:^\.$::' -e 's:^\./::' | eval cat $exclude >>$tmpfile.lst
         else
             if [ ".$opt_t" = .yes ]; then
@@ -1056,6 +1094,7 @@
             ;;
         HP-UX:*)
             HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+            MACHINE=`echo ${MACHINE}|sed -e 's:/:_:'`
             echo "${MACHINE}-hp-hpux${HPUXVER}"; exit 0
             ;;
         IRIX:*)

CVSTrac 2.0.1