Index: ossp-pkg/shiela/shtool RCS File: /v/ossp/cvs/ossp-pkg/shiela/Attic/shtool,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/shiela/Attic/shtool,v' 2>/dev/null --- shtool 2000/06/18 14:30:49 1.1 +++ shtool 2000/07/18 15:27:59 1.2 @@ -6,7 +6,7 @@ ## See http://www.gnu.org/software/shtool/ for more information. ## See ftp://ftp.gnu.org/gnu/shtool/ for latest version. ## -## Version: 1.4.10 (18-Jun-2000) +## Version: 1.5.0 (01-Jul-2000) ## Contents: 7/17 available modules ## @@ -43,7 +43,7 @@ ## mkdir Make one or more directories ## fixperm Fix file permissions inside a source tree ## tarball Roll distribution tarballs -## version Generate and maintain a version information file +## version Maintain a version information file ## path Deal with program paths ## ## Not available commands (because module was not built-in): @@ -65,7 +65,7 @@ exit 1 fi if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then - echo "This is GNU shtool, version 1.4.10 (18-Jun-2000)" + echo "This is GNU shtool, version 1.5.0 (01-Jul-2000)" echo "Copyright (c) 1994-2000 Ralf S. Engelschall " echo "Report bugs to " echo '' @@ -75,6 +75,7 @@ echo ' -v, --version display shtool version information' echo ' -h, --help display shtool usage help page (this one)' echo ' -d, --debug display shell trace information' + echo ' -r, --recreate recreate this shtool script via shtoolize' echo '' echo 'Available [] []:' echo ' echo [-n] [-e] [ ...]' @@ -84,8 +85,8 @@ echo ' fixperm [-v] [-t] [ ...]' echo ' tarball [-t] [-v] [-o ] [-c ] [-d ] [-u' echo ' ] [-g ] [-e ] [ ...]' - echo ' version [-l] [-n] [-p] [-s] [-i]' - echo ' [-d] ' + echo ' version [-l] [-n] [-p] [-s] [-e]' + echo ' [-i] [-d] ' echo ' path [-s] [-r] [-d] [-b] [-m] [-p] [ ...]' echo '' echo 'Not available (because module was not built-in):' @@ -104,7 +105,11 @@ exit 0 fi if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then - echo "GNU shtool 1.4.10 (18-Jun-2000)" + echo "GNU shtool 1.5.0 (01-Jul-2000)" + exit 0 +fi +if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then + shtoolize -oshtool echo install mkdir fixperm tarball version path exit 0 fi if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then @@ -190,16 +195,16 @@ ;; version ) str_tool="version" - str_usage="[-l] [-n] [-p] [-s] [-i] [-d] " - arg_spec="1+" - opt_spec="l:n:p:s:i:d:" + str_usage="[-l] [-n] [-p] [-s] [-e] [-i] [-d] " + arg_spec="1=" + opt_spec="l:n:p:s:i:e.d:" opt_l="txt" opt_n="unknown" - opt_p="unknown" - opt_s="unknown" - opt_i="P" - opt_d="NO" - gen_tmpfile=yes + opt_p="" + opt_s="" + opt_e="no" + opt_i="" + opt_d="short" ;; path ) str_tool="path" @@ -1007,142 +1012,97 @@ version ) ## - ## version -- Generate and maintain a version information file + ## version -- Maintain a version information file ## Copyright (c) 1994-2000 Ralf S. Engelschall - ## Originally written for ePerl + ## Originally written for ePerl, rewritten from scratch for shtool ## - LANGUAGE="$opt_l" - NAME="$opt_n" - PREFIX="$opt_p" - FULLVERSION="$opt_s" - INCREASE="$opt_i" - REPORT="$opt_d" - FILE="$1" - - # determine language - if [ ".$LANGUAGE" = .unknown ]; then - case $FILE in - *.txt ) LANGUAGE=txt ;; - *.c ) LANGUAGE=c ;; - *.pl | *.pm ) LANGUAGE=perl ;; - *.py) LANGUAGE=python ;; - * ) echo "$tool:Error: unknown language type" 1>&2; exit 1 ;; - esac - fi + file="$1" - # determine prefix from name and vice versa - if [ ".$PREFIX" = . -o ".$PREFIX" = .unknown ]; then - if [ ".$NAME" != . -a ".$NAME" != .unknown ]; then - PREFIX="$NAME" - fi - fi - if [ ".$NAME" = . -o ".$NAME" = .unknown ]; then - if [ ".$PREFIX" != . -a ".$PREFIX" != .unknown ]; then - NAME="$PREFIX" + # determine prefix and name + name="$opt_n" + prefix="$opt_p" + + # determine current version + triple="$opt_s" + if [ ".$triple" != . ]; then + # use given triple + if [ ".`echo $triple | grep '[0-9]*.[0-9]*[sabp.][0-9]*'`" = . ]; then + echo "$msgprefix:Error: invalid argument to option \`-s': \`$opt_s'" 1>&2 + exit 1 fi + eval `echo $triple |\ + sed -e 's%\([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\).*%\ + ver="\1";rev="\2";typ="\3";lev="\4"%'` + tim=calc + elif [ -r $file ]; then + # determine triple from given file + eval `grep 'Version [0-9]*.[0-9]*[sabp.][0-9]* ([0-9]*-[a-zA-Z]*-[0-9]*)' $file |\ + head -1 | sed -e 's%.*Version \([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\) (\([0-9]*-[a-zA-Z]*-[0-9]*\)).*%\ + ver="\1";rev="\2";typ="\3";lev="\4";tim="\5"%'` + else + # intialise to first version + ver=0 + rev=1 + typ=. + lev=0 + tim=calc fi - # determine version - date=unknown - version=0 - revision=0 - bplevel=0 - if [ ".$FULLVERSION" = .unknown ]; then - if [ -r "$FILE" ]; then - # grep out current information - id=`grep 'Version [0-9]*.[0-9]*[.abps][0-9]* ([0-9]*-[a-zA-Z]*-[0-9]*)' $FILE | \ - head -1 | \ - sed -e 's%.*Version \([0-9]*\)\.\([0-9]*\)\([.abps]\)\([0-9]*\) (\([0-9]*-[a-zA-Z]*-[0-9]*\)).*%\1:\2:\3:\4:\5%'` - version=`echo $id | awk -F: '{ print $1 }'` - revision=`echo $id | awk -F: '{ print $2 }'` - bptype=`echo $id | awk -F: '{ print $3 }'` - bplevel=`echo $id | awk -F: '{ print $4 }'` - date=`echo $id | awk -F: '{ print $5 }'` - if [ .$REPORT = .NO ]; then - case $INCREASE in - b ) bplevel=`expr $bplevel + 1` - bptype=b - ;; - a ) bplevel=`expr $bplevel + 1` - bptype=a - ;; - s ) bplevel=`expr $bplevel + 1` - bptype=s - ;; - P ) bplevel=`expr $bplevel + 1` - bptype=. - ;; - p ) bplevel=`expr $bplevel + 1` - bptype=p - ;; - r ) revision=`expr $revision + 1` - bptype=. - bplevel=0 - ;; - v ) version=`expr $version + 1` - revision=0 - bptype=. - bplevel=0 - ;; - esac - date=calc - fi - FULLVERSION="$version.$revision$bptype$bplevel" - else - # intialise to first version - version=0 - revision=5 - bptype=b - bplevel=0 - date=calc - fi - else - # take given version - V=`echo $FULLVERSION | sed -e 's%\([0-9]*\)\.\([0-9]*\)\([.abps]\)\([0-9]*\).*%\1:\2:\3:\4%'` - version=`echo $V | awk -F: '{ print $1 }'` - revision=`echo $V | awk -F: '{ print $2 }'` - bptype=`echo $V | awk -F: '{ print $3 }'` - bplevel=`echo $V | awk -F: '{ print $4 }'` - date=calc + # determine new version in batch + if [ ".$opt_i" != . ]; then + case $opt_i in + v ) ver=`expr $ver + 1` + rev=0 + lev=0 + ;; + r ) rev=`expr $rev + 1` + lev=0 + ;; + l ) lev=`expr $lev + 1` + ;; + * ) echo "$msgprefix:Error: invalid argument to option \`-i': \`$opt_i'" 1>&2 + exit 1 + ;; + esac + tim=calc fi - # determine hex value of version - case $FULLVERSION in - *.*a* ) - HEX=`echo "$FULLVERSION" | sed -e 's/a.*//' | awk -F. '{ printf("%d%02d", $1, $2); }' && - echo "$FULLVERSION" | sed -e 's/.*a//' | awk '{ printf("0%02d", $1); }'` - ;; - *.*b* ) - HEX=`echo "$FULLVERSION" | sed -e 's/b.*//' | awk -F. '{ printf("%d%02d", $1, $2); }' && - echo "$FULLVERSION" | sed -e 's/.*b//' | awk '{ printf("1%02d", $1); }'` - ;; - *.*.* ) - HEX=`echo "$FULLVERSION" | awk -F. '{ printf("%d%02d2%02d", $1, $2, $3); }'` - ;; - esac + # determine new version interactively + if [ ".$opt_e" = .yes ]; then + echo "old version: ${ver}.${rev}${typ}${lev}" + while [ 1 ]; do + echo dummy | awk '{ printf("new version: "); }' + read triple + case $triple in + [0-9]*.[0-9]*[sabp.][0-9]* ) + ;; + * ) echo "$msgprefix:Error: invalid version string entered: \`$triple'" 1>&2 + continue + ;; + esac + break + done + eval `echo $triple |\ + sed -e 's%^\([0-9]*\)\.\([0-9]*\)\([sabp.]\)\([0-9]*\)$%\ + ver="\1";rev="\2";typ="\3";lev="\4"%'` + tim=calc + fi - # determine libtool version - case $FULLVERSION in - *.*a* ) - LTV=`echo "$FULLVERSION" | sed -e 's/a.*//' | awk -F. '{ printf("%d:0", $1*10+$2); }'` - ;; - *.*b* ) - LTV=`echo "$FULLVERSION" | sed -e 's/b.*//' | awk -F. '{ printf("%d:0", $1*10+$2); }'` - ;; - *.*.* ) - LTV=`echo "$FULLVERSION" | awk -F. '{ printf("%d:%d", $1*10+$2, $3); }'` - ;; + # determine hexadecimal and libtool value of version + case $typ in + a ) typnum=0; levnum=$lev ;; + b ) typnum=1; levnum=$lev ;; + p | . ) typnum=2; levnum=$lev ;; + s ) typnum=15; levnum=255 ;; # snapshots are special esac - - # determine string out of filename - # (don't try to optimize this in any way - portability!) - FILESTR=`echo "$FILE" |\ - tr 'abcdefghijklmnopqrstuvwxyz./%+' \ - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ____' | sed -e 's/-/_/g'` + hex=`echo "$ver:$rev:$typnum:$levnum" |\ + awk -F: '{ printf("0x%X%02X%1X%02X", $1, $2, $3, $4); }'` + ltv=`echo "$ver:$rev:$typnum:$levnum" |\ + awk -F: '{ printf("%d:%d", $1*10 + $2, $3*10 + $4); }'` # determine date - if [ ".$date" = .calc ]; then + if [ ".$tim" = .calc ]; then day=`date '+%d'` month=`date '+%m'` year=`date '+%Y' 2>/dev/null` @@ -1167,131 +1127,147 @@ 11) month='Nov' ;; 12) month='Dec' ;; esac - date="${day}-${month}-${year}" + tim="${day}-${month}-${year}" fi - if [ .$REPORT != .NO ]; then - case $REPORT in - long ) - echo "$version.$revision$bptype$bplevel ($date)" - ;; + # perform result actions + mode=show + if [ ".$opt_i" != . ]; then + mode=edit + elif [ ".$opt_e" = .yes ]; then + mode=edit + elif [ ".$opt_s" != . ]; then + mode=edit + fi + if [ ".$mode" = .show ]; then + # just display the current version + case $opt_d in short ) - echo "$version.$revision$bptype$bplevel" + echo "${ver}.${rev}${typ}${lev}" + ;; + long ) + echo "${ver}.${rev}${typ}${lev} ($tim)" ;; libtool ) - echo "$LTV" + echo "${ltv}" ;; hex ) - echo "0x$HEX" + echo "${hex}" + ;; + * ) echo "$msgprefix:Error: invalid argument to option \`-d': \`$opt_d'" 1>&2 + exit 1 ;; esac - rm -f $tmpfile >/dev/null 2>&1 - exit 0 - fi - - # create the version file according the the selected language - echo "new version: $version.$revision$bptype$bplevel ($date)" - case $LANGUAGE in - txt ) - cat >$tmpfile <<'EOT' - - This is @NAME@, Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@) - -EOT - ;; - c ) - cat >$tmpfile <<'EOT' -/* -** @FILE@ -- Version Information -** [automatically generated and maintained by GNU shtool] -*/ - -#ifdef _AS_HEADER - -#ifndef _@FILESTR@ -#define _@FILESTR@ -#define @PREFIX@_VERSION 0x@HEX@ -extern const int @PREFIX@_Version; -extern const char @PREFIX@_VersionStr[]; -extern const char @PREFIX@_Hello[]; -extern const char @PREFIX@_GNUVersion[]; -extern const char @PREFIX@_WhatID[]; -extern const char @PREFIX@_RCSIdentID[]; -extern const char @PREFIX@_WebID[]; -extern const char @PREFIX@_PlainID[]; -#endif /* _@FILESTR@ */ - -#else - -const int @PREFIX@_Version = 0x@HEX@; -const char @PREFIX@_VersionStr[] = "@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)"; -const char @PREFIX@_Hello[] = "This is @NAME@, Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)"; -const char @PREFIX@_GNUVersion[] = "@NAME@ Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@"; -const char @PREFIX@_WhatID[] = "@(#)@NAME@ Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)"; -const char @PREFIX@_RCSIdentID[] = "$Id$"; -const char @PREFIX@_WebID[] = "@NAME@/@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@"; -const char @PREFIX@_PlainID[] = "@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@"; - -#endif - -EOT - ;; - perl ) - cat >$tmpfile <<'EOT' -## -## @FILE@ -- Version Information -## [automatically generated and maintained by GNU shtool] -## - -$@PREFIX@_Version = 0x@HEX@; -$@PREFIX@_VersionStr = "@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)"; -$@PREFIX@_Hello = "This is @NAME@, Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)"; -$@PREFIX@_GNUVersion = "@NAME@ Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@"; -$@PREFIX@_WhatID = "@(#)@NAME@ Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)"; -$@PREFIX@_RCSIdentID = "\$Id$/"; -$@PREFIX@_WebID = "@NAME@/@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@"; -$@PREFIX@_PlainID = "@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@"; - -1; -EOT - ;; - python ) - cat >$tmpfile <<'EOT' -## -## @FILE@ -- Version Information -## [automatically generated and maintained by GNU shtool] -## - -@PREFIX@_Version = 0x@HEX@ -@PREFIX@_VersionStr = "@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)" -@PREFIX@_Hello = "This is @NAME@, Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)" -@PREFIX@_GNUVersion = "@NAME@ Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@" -@PREFIX@_WhatID = "@(#)@NAME@ Version @VERSION@.@REVISION@@BPTYPE@@BPLEVEL@ (@DAY@-@MONTH@-@YEAR@)" -@PREFIX@_RCSIdentID = "$Id$" -@PREFIX@_WebID = "@NAME@/@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@" -@PREFIX@_PlainID = "@VERSION@.@REVISION@@BPTYPE@@BPLEVEL@" - -EOT - ;; - esac + else + # update the version file - # now create the version file - rm -f $FILE >/dev/null 2>&1 - sed \ - -e "s|@FILE@|$FILE|g" \ - -e "s|@FILESTR@|$FILESTR|g" \ - -e "s|@PREFIX@|$PREFIX|g" \ - -e "s|@NAME@|$NAME|g" \ - -e "s|@HEX@|$HEX|g" \ - -e "s|@VERSION@|$version|g" \ - -e "s|@REVISION@|$revision|g" \ - -e "s|@BPTYPE@|$bptype|g" \ - -e "s|@BPLEVEL@|$bplevel|g" \ - -e "s|@YEAR@|$year|g" \ - -e "s|@MONTH@|$month|g" \ - -e "s|@DAY@|$day|g" <$tmpfile >$FILE - rm -f $tmpfile >/dev/null 2>&1 - exit 0 + # pre-generate various strings + triple="${ver}.${rev}${typ}${lev}" + vHex="$hex" + vShort="${triple}" + vLong="${triple} (${tim})" + vTeX="This is ${name}, Version ${triple} (${tim})" + vGNU="${name} ${triple} (${tim})" + vWeb="${name}/${triple}" + vSCCS="@(#)${name} ${triple} (${tim})" + vRCS="\$Id${name} ${triple} (${tim}) \$" + + # determine string out of filename + # (do NOT try to optimize this in any way because of portability) + filestr=`echo $file |\ + tr 'abcdefghijklmnopqrstuvwxyz./%+' \ + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ____' | sed -e 's/-/_/g'` + + # generate uppercase prefix + prefixupper=`echo $prefix |\ + tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + + # create the version file according the the selected language + echo "new version: ${vLong}" + + cp /dev/null $file + case $opt_l in + txt ) + echo >>$file "" + echo >>$file " ${file} -- Version Information for ${name} (syntax: Text)" + echo >>$file " [automatically generated and maintained by GNU shtool]" + echo >>$file "" + echo >>$file " $vTeX" + echo >>$file "" + ;; + c ) + echo >>$file "/*" + echo >>$file "** ${file} -- Version Information for ${name} (syntax: C/C++)" + echo >>$file "** [automatically generated and maintained by GNU shtool]" + echo >>$file "*/" + echo >>$file "" + echo >>$file "#ifdef _${filestr}_AS_HEADER_" + echo >>$file "" + echo >>$file "#ifndef _${filestr}_" + echo >>$file "#define _${filestr}_" + echo >>$file "" + echo >>$file "#define ${prefixupper}VERSION ${vHex}" + echo >>$file "" + echo >>$file "typedef struct {" + echo >>$file " const int v_hex;" + echo >>$file " const char *v_short;" + echo >>$file " const char *v_long;" + echo >>$file " const char *v_tex;" + echo >>$file " const char *v_gnu;" + echo >>$file " const char *v_web;" + echo >>$file " const char *v_sccs;" + echo >>$file " const char *v_rcs;" + echo >>$file "} ${prefix}version_t;" + echo >>$file "" + echo >>$file "extern ${prefix}version_t ${prefix}version;" + echo >>$file "" + echo >>$file "#endif /* _${filestr}_ */" + echo >>$file "" + echo >>$file "#else /* _${filestr}_AS_HEADER_ */" + echo >>$file "" + echo >>$file "#define _${filestr}_AS_HEADER_" + echo >>$file "#include \"${file}\"" + echo >>$file "#undef _${filestr}_AS_HEADER_" + echo >>$file "" + echo >>$file "${prefix}version_t ${prefix}version = {" + echo >>$file " ${vHex}," + echo >>$file " \"${vShort}\"," + echo >>$file " \"${vLong}\"," + echo >>$file " \"${vTeX}\"," + echo >>$file " \"${vGNU}\"," + echo >>$file " \"${vWeb}\"," + echo >>$file " \"${vSCCS}\"," + echo >>$file " \"${vRCS}\"" + echo >>$file "};" + echo >>$file "" + echo >>$file "#endif /* _${filestr}_AS_HEADER_ */" + echo >>$file "" + ;; + perl ) + echo >>$file "##" + echo >>$file "## ${file} -- Version Information for ${name} (syntax: Perl)" + echo >>$file "## [automatically generated and maintained by GNU shtool]" + echo >>$file "##" + echo >>$file "" + echo >>$file "my \$${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 >>$file "" + echo >>$file "1;" + echo >>$file "" + ;; + * ) echo "$msgprefix:Error: invalid argument to option \`-l': \`$opt_l'" 1>&2 + exit 1 + ;; + esac + fi ;; path ) @@ -1378,10 +1354,8 @@ # MAGIC SITUATION # C pre-processor (cpp) if [ ".$opt_m" = .yes ] && [ ".$namelist" = .cpp ]; then - cat >$tmpfile.c <<'EOT' -#include -Syntax Error -EOT + echo >$tmpfile.c "#include " + echo >>$tmpfile.c "Syntax Error" # 1. try the standard cc -E approach cpp="${CC-cc} -E" (eval "$cpp $tmpfile.c >/dev/null") 2>$tmpfile.out @@ -1426,7 +1400,7 @@ path=`echo $path | sed -e 's;/*$;;'` if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then if [ ".$opt_s" != .yes ]; then - echo "$path/$name" 2>&1 + echo "$path/$name" fi exit 0 fi