--- shtool 2004/09/11 15:18:56 1.2
+++ shtool 2005/10/05 18:04:52 1.3
@@ -1,12 +1,12 @@
#!/bin/sh
##
## GNU shtool -- The GNU Portable Shell Tool
-## Copyright (c) 1994-2004 Ralf S. Engelschall <rse@engelschall.com>
+## Copyright (c) 1994-2005 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: 2.0.1 (11-Aug-2004)
+## Version: 2.0.3 (02-Oct-2005)
## Contents: all available modules
##
@@ -65,8 +65,8 @@
exit 1
fi
if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
- echo "This is GNU shtool, version 2.0.1 (11-Aug-2004)"
- echo "Copyright (c) 1994-2004 Ralf S. Engelschall <rse@engelschall.com>"
+ echo "This is GNU shtool, version 2.0.3 (02-Oct-2005)"
+ echo "Copyright (c) 1994-2005 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>]]"
@@ -132,7 +132,7 @@
exit 0
fi
if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then
- echo "GNU shtool 2.0.1 (11-Aug-2004)"
+ echo "GNU shtool 2.0.3 (02-Oct-2005)"
exit 0
fi
if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then
@@ -571,6 +571,7 @@
# establish a temporary file on request
if [ ".$gen_tmpfile" = .yes ]; then
+ # create (explicitly) secure temporary directory
if [ ".$TMPDIR" != . ]; then
tmpdir="$TMPDIR"
elif [ ".$TEMPDIR" != . ]; then
@@ -578,10 +579,19 @@
else
tmpdir="/tmp"
fi
- tmpfile="$tmpdir/.shtool.$$"
- rm -f $tmpfile >/dev/null 2>&1
- touch $tmpfile
- chmod 600 $tmpfile
+ tmpdir="$tmpdir/.shtool.$$"
+ ( umask 077
+ rm -rf "$tmpdir" >/dev/null 2>&1 || true
+ mkdir "$tmpdir" >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2
+ exit 1
+ fi
+ )
+
+ # create (implicitly) secure temporary file
+ tmpfile="$tmpdir/shtool.tmp"
+ touch "$tmpfile"
fi
# utility function: map string to lower case
@@ -598,7 +608,7 @@
shtool_exit () {
rc="$1"
if [ ".$gen_tmpfile" = .yes ]; then
- rm -f $tmpfile >/dev/null 2>&1 || true
+ rm -rf "$tmpdir" >/dev/null 2>&1 || true
fi
exit $rc
}
@@ -612,7 +622,7 @@
echo )
##
## echo -- Print string with optional construct expansion
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
text="$*"
@@ -911,7 +921,7 @@
##
## mdate -- Pretty-print modification time of a file or dir
## Copyright (c) 1995-1997 Free Software Foundation, Inc.
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
fod="$1"
@@ -932,6 +942,14 @@
LC_ALL=C; export LC_ALL
LC_TIME=C; export LC_TIME
+ # GNU ls changes its time format in response to the TIME_STYLE
+ # variable. Since we cannot assume "unset" works, revert this
+ # variable to its documented default.
+ if [ ".$TIME_STYLE" != . ]; then
+ TIME_STYLE=posix-long-iso
+ export TIME_STYLE
+ fi
+
# get the extended ls output of the file or directory.
if /bin/ls -L /dev/null >/dev/null 2>&1; then
set - x`/bin/ls -L -l -d $fod`
@@ -1036,7 +1054,7 @@
table )
##
## table -- Pretty-print a field-separated list as a table
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
if [ $opt_c -gt 4 ]; then
@@ -1101,7 +1119,7 @@
prop )
##
## prop -- Display progress with a running propeller
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
perl=''
@@ -1147,7 +1165,7 @@
move )
##
## move -- Move files with simultaneous substitution
- ## Copyright (c) 1999-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2005 Ralf S. Engelschall <rse@engelschall.com>
##
src="$1"
@@ -1239,7 +1257,7 @@
install )
##
## install -- Install a program, script or datafile
- ## Copyright (c) 1997-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1997-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# special case: "shtool install -d <dir> [...]" internally
@@ -1402,7 +1420,7 @@
mkdir )
##
## mkdir -- Make one or more directories
- ## Copyright (c) 1996-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1996-2005 Ralf S. Engelschall <rse@engelschall.com>
##
errstatus=0
@@ -1490,7 +1508,7 @@
mkln )
##
## mkln -- Make link with calculation of relative paths
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# determine source(s) and destination
@@ -1641,7 +1659,7 @@
mkshadow )
##
## mkshadow -- Make a shadow tree through symbolic links
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# source and destination directory
@@ -1759,7 +1777,7 @@
fixperm )
##
## fixperm -- Fix file permissions inside a source tree
- ## Copyright (c) 1996-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1996-2005 Ralf S. Engelschall <rse@engelschall.com>
##
paths="$*"
@@ -1816,7 +1834,7 @@
rotate )
##
## rotate -- Logfile rotation
- ## Copyright (c) 2001-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 2001-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# make sure we have at least one file to rotate
@@ -2180,7 +2198,7 @@
tarball )
##
## tarball -- Roll distribution tarballs
- ## Copyright (c) 1999-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2005 Ralf S. Engelschall <rse@engelschall.com>
##
srcs="$*"
@@ -2344,7 +2362,7 @@
subst )
##
## subst -- Apply sed(1) substitution operations
- ## Copyright (c) 2001-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 2001-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# remember optional list of file(s)
@@ -2505,7 +2523,7 @@
platform )
##
## platform -- Platform Identification Utility
- ## Copyright (c) 2003-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 2003-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# option post-processing
@@ -2599,13 +2617,14 @@
i386 ) AC="iX86" ;;
esac
AP="${AC}"
- AT=`(/sbin/sysctl -n hw.model) 2>&1`
- case "${AT}" in
- *"Xeon"* | *"Pentium Pro"* | *"Cyrix 6x86MX"* | *"Pentium II"* | *"Pentium III"* | *"Pentium 4"* | *"Celeron"* ) AT="i686" ;;
- *"Pentium"* ) AT="i586" ;; *"i486[SD]X"* | *"Cyrix 486"* | *"Cyrix [56]x86"* | *"Blue Lightning" | *"Cyrix 486S/DX" ) AT="i486" ;;
- *"i386[SD]X"* | *"NexGen 586"* ) AT="i386" ;;
- * ) AT="${AP}" ;;
- esac
+ AT="${AP}"
+ if [ ".${AT}" = ".iX86" ]; then
+ case "`(/sbin/sysctl -n hw.model) 2>&1`" in
+ *"Xeon"* | *"Pentium Pro"* | *"Cyrix 6x86MX"* | *"Pentium II"* | *"Pentium III"* | *"Pentium 4"* | *"Celeron"* ) AT="i686" ;;
+ *"Pentium"* ) AT="i586" ;; *"i486[SD]X"* | *"Cyrix 486"* | *"Cyrix [56]x86"* | *"Blue Lightning" | *"Cyrix 486S/DX" ) AT="i486" ;;
+ *"i386[SD]X"* | *"NexGen 586"* ) AT="i386" ;;
+ esac
+ fi
# determine system
r=`echo "${UNAME_RELEASE}" |\
sed -e 's;[()];;' -e 's/\(-.*\)$/[\1]/'`
@@ -2671,7 +2690,7 @@
v_kern=`echo "${UNAME_RELEASE}" |\
sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
v_libc=`(strings /lib/libc.so.* | grep '^GLIBC_' | sed -e 's/^GLIBC_//' |\
- sort -n | sed -n -e '$p' | sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/') 2>/dev/null`
+ env -i sort -n | sed -n -e '$p' | sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/') 2>/dev/null`
ST="GNU/<Linux >${v_libc}/<${v_kern}>"
if [ -f /etc/lsb-release ]; then
eval `( . /etc/lsb-release
@@ -2684,7 +2703,7 @@
if [ ".$SP" = . ]; then
for tagfile in x \
`cd /etc && \
- /bin/ls *[_-]release *[_-]version 2>/dev/null | \
+ /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \
sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \
echo redhat-release lsb-release`
do
@@ -2705,15 +2724,16 @@
n="<R>ed <H>at <L>inux"
fi
;;
- debian ) n="Debian[ GNU/Linux]" ;;
- fedora ) n="<Fedora> Core[ GNU/Linux]" ;;
- suse ) n="SuSE[ Linux]" ;;
- mandrake ) n="Mandrake[ Linux]" ;;
- gentoo ) n="Gentoo[ GNU/Linux]" ;;
- slackware ) n="Slackware[ Linux]" ;;
- turbolinux ) n="TurboLinux" ;;
- unitedlinux ) n="UnitedLinux" ;;
- * ) n="${n}[ GNU/Linux]" ;;
+ debian ) n="Debian[ GNU/Linux]" ;;
+ ubuntu ) n="Ubuntu[ GNU/Linux]" ;;
+ fedora ) n="<Fedora> Core[ GNU/Linux]" ;;
+ suse ) n="SuSE[ Linux]" ;;
+ mandrake*|mandriva ) n="Mandriva[ Linux]" ;;
+ gentoo ) n="Gentoo[ GNU/Linux]" ;;
+ slackware ) n="Slackware[ Linux]" ;;
+ turbolinux ) n="TurboLinux" ;;
+ unitedlinux ) n="UnitedLinux" ;;
+ * ) n="${n}[ GNU/Linux]" ;;
esac
case "$n" in
*"<"*">"* ) SP="$n <$v>" ;;
@@ -2868,11 +2888,14 @@
if [ ".`/usr/sbin/lsattr -El ${cpu_id} | grep -i powerpc`" != . ]; then
cpu_arch=powerpc
fi
+ elif [ -d /QOpenSys ]; then
+ # IBM i5/OS (aka OS/400) with PASE (Portable Application Solutions Environment)
+ cpu_arch=powerpc
fi
if [ -x /usr/bin/oslevel ]; then
os_level=`/usr/bin/oslevel`
else
- os_level="`uname -r`.`uname -v`"
+ os_level="`uname -v`.`uname -r`"
fi
os_level=`echo "${os_level}" |\
sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\)\(.*\)$;<\1>\2[\3];' \
@@ -2880,7 +2903,7 @@
AT="${cpu_arch}"
AP="${AT}"
AC="${AP}"
- ST="[IBM ]AIX ${os_level}"
+ ST="[IBM ]<AIX >${os_level}"
SP="${ST}"
case "${os_level}" in
[12]* ) SC="SVR2" ;;
@@ -3048,7 +3071,7 @@
arx )
##
## arx -- Extended archive command
- ## Copyright (c) 1999-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2005 Ralf S. Engelschall <rse@engelschall.com>
##
ar_prg="$opt_C"
@@ -3057,7 +3080,7 @@
files="$*"
# walk through the file list and expand archives members
- tmpdir=`echo $archive | sed -e 's;[^/]*$;.arx;'`
+ ar_tmpdir=`echo $archive | sed -e 's;[^/]*$;.arx;'`
nfiles=''
if [ ".$files" != . ]; then
for file in $files; do
@@ -3067,13 +3090,13 @@
fi
case $file in
*.a )
- if [ ! -d $tmpdir ]; then
+ if [ ! -d $ar_tmpdir ]; then
if [ ".$opt_t" = .yes ]; then
- echo "mkdir $tmpdir" 1>&2
+ echo "mkdir $ar_tmpdir" 1>&2
fi
- mkdir $tmpdir
+ mkdir $ar_tmpdir
fi
- case $tmpdir in
+ case $ar_tmpdir in
.arx )
from="../$file"
;;
@@ -3084,16 +3107,16 @@
;;
esac
if [ ".$opt_t" = .yes ]; then
- echo "(cd $tmpdir && $ar_prg x $from)" 1>&2
+ echo "(cd $ar_tmpdir && $ar_prg x $from)" 1>&2
fi
- (cd $tmpdir && eval $ar_prg x $from)
+ (cd $ar_tmpdir && eval $ar_prg x $from)
if [ $? -ne 0 ]; then
echo "$msgprefix:Error: member extraction failed for archive: $file" 1>&2
shtool_exit 1
fi
for member in - `eval $ar_prg t $file | sed -e '/_\.SYMDEF/d'`; do
[ ".$member" = .- ] && continue
- nfiles="$nfiles $tmpdir/$member"
+ nfiles="$nfiles $ar_tmpdir/$member"
done
;;
* )
@@ -3114,11 +3137,11 @@
fi
# cleanup and die gracefully
- if [ -d $tmpdir ]; then
+ if [ -d $ar_tmpdir ]; then
if [ ".$opt_t" = .yes ]; then
- echo "rm -rf $tmpdir" 1>&2
+ echo "rm -rf $ar_tmpdir" 1>&2
fi
- rm -rf $tmpdir
+ rm -rf $ar_tmpdir
fi
shtool_exit 0
@@ -3127,7 +3150,7 @@
slo )
##
## slo -- Separate linker options by library class
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
DIFS="$IFS"
@@ -3286,7 +3309,7 @@
scpp )
##
## scpp -- Sharing C Pre-Processor
- ## Copyright (c) 1999-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1999-2005 Ralf S. Engelschall <rse@engelschall.com>
##
srcs="$*"
@@ -3506,7 +3529,7 @@
version )
##
## version -- Maintain a version information file
- ## Copyright (c) 1994-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>
##
file="$1"
@@ -3663,7 +3686,7 @@
vGNU="${name} ${triple} (${tim})"
vWeb="${name}/${triple}"
vSCCS="@(#)${name} ${triple} (${tim})"
- vRCS="\$Id: shtool,v 1.2 2004/09/11 15:18:56 rse Exp ${name} ${triple} (${tim}) \$"
+ vRCS="\$Id: shtool,v 1.3 2005/10/05 18:04:52 rse Exp ${name} ${triple} (${tim}) \$"
# determine string out of filename
# (do NOT try to optimize this in any way because of portability)
@@ -3758,7 +3781,7 @@
echo >>$file "## [automatically generated and maintained by GNU shtool]"
echo >>$file "##"
echo >>$file ""
- echo >>$file "my \$${prefix}version = {"
+ echo >>$file "our \$${prefix}version = {"
echo >>$file " 'v_hex' => ${vHex},"
echo >>$file " 'v_short' => \"${vShort}\","
echo >>$file " 'v_long' => \"${vLong}\","
@@ -3801,7 +3824,7 @@
path )
##
## path -- Deal with program paths
- ## Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>
+ ## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
namelist="$*"
|