--- shtool 2000/07/18 15:27:59 1.2
+++ shtool 2001/02/10 16:40:26 1.3
@@ -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.0 (01-Jul-2000)
+## Version: 1.5.2 (05-Oct-2000)
## Contents: 7/17 available modules
##
@@ -65,8 +65,8 @@
exit 1
fi
if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
- echo "This is GNU shtool, version 1.5.0 (01-Jul-2000)"
- echo "Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>"
+ echo "This is GNU shtool, version 1.5.2 (05-Oct-2000)"
+ 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>]]"
@@ -80,7 +80,7 @@
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'
@@ -105,7 +105,7 @@
exit 0
fi
if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
- echo "GNU shtool 1.5.0 (01-Jul-2000)"
+ echo "GNU shtool 1.5.2 (05-Oct-2000)"
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=""
@@ -366,6 +366,7 @@
tmpfile="$tmpdir/.shtool.$$"
rm -f $tmpfile >/dev/null 2>&1
touch $tmpfile
+ chmod 600 $tmpfile
fi
##
@@ -377,7 +378,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
##
@@ -600,7 +601,7 @@
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
##
@@ -630,19 +631,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
@@ -652,18 +647,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
@@ -679,8 +674,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
@@ -699,14 +702,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
@@ -717,7 +720,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
@@ -735,7 +738,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
##
@@ -744,7 +747,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
@@ -794,7 +797,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
##
@@ -850,7 +853,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
##
@@ -876,7 +879,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
@@ -902,7 +905,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
@@ -1013,7 +1016,7 @@
version )
##
## version -- Maintain a version information file
- ## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1994-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for ePerl, rewritten from scratch for shtool
##
@@ -1097,7 +1100,8 @@
s ) typnum=15; levnum=255 ;; # snapshots are special
esac
hex=`echo "$ver:$rev:$typnum:$levnum" |\
- awk -F: '{ printf("0x%X%02X%1X%02X", $1, $2, $3, $4); }'`
+ awk -F: '{ printf("0x%x%02x%1x%02x", $1, $2, $3, $4); }' |\
+ tr 'abcdef' 'ABCDEF'`
ltv=`echo "$ver:$rev:$typnum:$levnum" |\
awk -F: '{ printf("%d:%d", $1*10 + $2, $3*10 + $4); }'`
@@ -1170,7 +1174,7 @@
vGNU="${name} ${triple} (${tim})"
vWeb="${name}/${triple}"
vSCCS="@(#)${name} ${triple} (${tim})"
- vRCS="\$Id: shtool,v 1.2 2000/07/18 15:27:59 rse Exp ${name} ${triple} (${tim}) \$"
+ vRCS="\$Id: shtool,v 1.3 2001/02/10 16:40:26 rse Exp ${name} ${triple} (${tim}) \$"
# determine string out of filename
# (do NOT try to optimize this in any way because of portability)
@@ -1263,6 +1267,23 @@
echo >>$file "1;"
echo >>$file ""
;;
+ python )
+ echo >>$file "##"
+ echo >>$file "## ${file} -- Version Information for ${name} (syntax: Python)"
+ echo >>$file "## [automatically generated and maintained by GNU shtool]"
+ echo >>$file "##"
+ echo >>$file ""
+ echo >>$file "class ${prefix}version:"
+ echo >>$file " v_hex = ${vHex}"
+ echo >>$file " v_short = \"${vShort}\""
+ echo >>$file " v_long = \"${vLong}\""
+ echo >>$file " v_tex = \"${vTeX}\""
+ echo >>$file " v_gnu = \"${vGNU}\""
+ echo >>$file " v_web = \"${vWeb}\""
+ echo >>$file " v_sccs = \"${vSCCS}\""
+ echo >>$file " v_rcs = \"${vRCS}\""
+ echo >>$file ""
+ ;;
* ) echo "$msgprefix:Error: invalid argument to option \`-l': \`$opt_l'" 1>&2
exit 1
;;
@@ -1273,7 +1294,7 @@
path )
##
## path -- Deal with program paths
- ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2001 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for Apache
##
@@ -1323,7 +1344,7 @@
# MAGIC SITUATION
# Perl Interpreter (perl)
- if [ ".$opt_m" = .yes ] && [ ".$namelist" = .perl ]; then
+ if [ ".$opt_m" = .yes -a ".$namelist" = .perl ]; then
rm -f $tmpfile
touch $tmpfile
found=0
@@ -1332,7 +1353,7 @@
dir=`echo $dir | sed -e 's;/*$;;'`
nc=99
for name in perl perl5 miniperl; do
- if [ $minusx "$dir/$name" ] && [ ! -d "$dir/$name" ]; then
+ if [ $minusx "$dir/$name" -a ! -d "$dir/$name" ]; then
perl="$dir/$name"
pv=`$perl -e 'printf("%.3f", $]);'`
echo "$pv:$pc:$nc:$perl" >>$tmpfile
@@ -1353,7 +1374,7 @@
# MAGIC SITUATION
# C pre-processor (cpp)
- if [ ".$opt_m" = .yes ] && [ ".$namelist" = .cpp ]; then
+ if [ ".$opt_m" = .yes -a ".$namelist" = .cpp ]; then
echo >$tmpfile.c "#include <assert.h>"
echo >>$tmpfile.c "Syntax Error"
# 1. try the standard cc -E approach
@@ -1369,7 +1390,7 @@
# 3. try a standalone cpp command in path and lib dirs
for path in $paths /lib /usr/lib /usr/local/lib; do
path=`echo $path | sed -e 's;/*$;;'`
- if [ $minusx "$path/cpp" ] && [ ! -d "$path/cpp" ]; then
+ if [ $minusx "$path/cpp" -a ! -d "$path/cpp" ]; then
cpp="$path/cpp"
break
fi
@@ -1398,7 +1419,7 @@
# iterate over paths
for path in $paths; do
path=`echo $path | sed -e 's;/*$;;'`
- if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then
+ if [ $minusx "$path/$name" -a ! -d "$path/$name" ]; then
if [ ".$opt_s" != .yes ]; then
echo "$path/$name"
fi
|