#!/bin/sh
export PATH || exec /bin/sh $0 $argv:q
#### WARNING: This shell script contains embedded tabs.
#
# DESCRIPTION
# 
# Generates a jar file using a temporary directory
#
# Peter Pilgrim
# Sun Sep 06 15:00:49 BST 1998
# 
# RCS HEADER ``make-jar.sh''
# 
# $Author: pilgpe $
# $Date: 1999/04/21 14:12:14 $
# $Source: /export/devel/cvs/OTC_WEB/java/make-jar.sh,v $
# $Revision: 1.2 $    $State: Exp $    $Locker:  $
#

# ********************************************************************************
PrintUsage() 
# ********************************************************************************
{
    cat << EOF
USAGE: 
    $myname  
	   [ --help (-u) | --usage (-u) ]
	   [ --dryrun (-dr) ] [ --silent (-s) ]
	   [ --verbose (-v) | --noverbose (+v) ]
	   [ --normal (-n) | 
	     ( [ --excl-bin ] [ --excl-objects ] [ --excl-libs ]
	       [ --excl-java | --incl-java ] [ --excl-cpp ] 
	       [ --excl-temp ] [ --excl-core ] [ --excl-rcs ] 
	       [ --excl-sccs ] [ --excl-dot ] [ --excl-tar ]
	       [ --excl-zip ] [ --excl-cpio ]
	     ) ]
	   [ --excl-patch ] [ --excl-tar ] [ --excl-zip ]
	   [ --excl-jar | --incl-jar ]
	   [ --store (-0) ] [ --nostore (+0) ]
	   [ --exclude (-x) <SED-PATTERN> ]
	   <TARFILE>  <ACTIVE-DIRECTORY>  <FILE/DIR>...

OPTIONS:-

    '--help'		produces this message text.
    '--usage'		ditto.

    '--verbose'		produces verbose output.
    '--noverbose'	no extra info is printed, quiet.

    '--excl-java'	exclude any java source file '.java', 
    '--incl-java'	include any java source file '.java'

    '--excl-jar'	exclude any java archive file '.jar', 
    '--incl-jar'	include any java archive file '.jar'

    '--excl-cpp'	exclude any C/C++ source files 
			'.[ch]', '.cc'  and '.[HC]'
 
    '--excl-bin'	exclude any executable files.
    '--excl-libs'	exclude library files 
			e.g. '.sa', '.so', '.a', '.sl' .
    '--excl-objs'	exclude object files '.o$', '.obj$'and '.obj$' .

    '--excl-temp'	exclude temporary files 
			e.g '.tmp' '.bak' '.BAK' '.flc' '*~' .
    '--excl-core'	exclude any core files '/core'
    '--excl-sccs'	exclude any SCCS files '*/SCCS/*' '*/[sp].*' .
    '--excl-rcs'	exclude any RCS | CVS file '*/RCS/*' '*/CVS/*' '*/*,v' .
    '--excl-dot'	exclude any hidden dot files '*/.*' .
    '--excl-patch'	exclude any patch files 
			e.g. '.save' '.orig' '.patch'
    '--excl-tar'	exclude any tar archive files '*.tar' .
    '--excl-zip'	exclude any compression files 
			e.g. '*.gz' '*.tgz' '*.z' '*.Z'.

    '--normal'		default mode of operation. Equivalent to setting 
			the options '--excl-objs --excl-bin --excl-libs 
			--excl-temp --excl-core --excl-rcs --excl-sccs 
			--excl-dot --excl-java --excl-cpp'
			
    '--exclude'		specifies an additional regular pattern for filenames
			to exclude from backup. NB: special characters must be
			_backslashified_, and the back slashes them too, 
			as in sed(1) e.g. '\\.foobar'. (see below examples)

    '--list'		also generate a long list flag which shows the size of
    '-l'		the jar file.

    '--keep-temp'	keep temporary files (for debugging purposes).
    '--store'		just store files in the JAR without ZLIB compression.
			Use this if you want to use the jar in your 'CLASSPATH'.
    '--nostore'		do NOT just store files but add ZLIB compression on the
			entire archive.

    '--silent'		run the script silently.
    '--dryrun'		dry run and test the configuration, do not configure the
    '-dr'		makefile.


DESCRIPTION:-
    '${myname}' creates a java archive of files in the root directory and
will automatically exclude a variety of files. This is new version for 
adaptable for Linux and most systems. By default the packager excludes
Java source files (for example '*.java').

o  The first ordinary argument __must__ be the jar filename.
o  The second ordinary argument __must__ be the active directory
   to start taring from.
o  The rest of the arguments are directories or filenames fed
   directly to the jar command.

NOTE:-
 
This software was created because the SunSoft jar command does not
support an exclusion file command line option like GNU tape archive
(tar) commands 'X' flag!!!

ENVIRONMENTALS:-
    'JAR_CMD'         specifies the tar command. (Default is 'jar')

EXAMPLES:-

    % $myname -v  myutils.tar   .  .
    % $myname -v --normal  projectX.tar  .  include src config doc
    % $myname -v --normal --excl-zip --exclude '\\.dvi\$' \\
	pegasus.jar   ~/org/xenon/beanbox  images docs[1-4] classes 
    % $myname -v --normal --excl-zip --exclude "\\\\.dvi\$" \\
	pegasus.jar   ~/org/xenon/beanbox  images docs[1-4] classes

FILES:-

    ${TMPDIR}/${myname}-exclusion<PID>
    <<JARFILE>>.EXCLUDE

Peter Pilgrim Sun Sep 06 17:37:42 BST 1998
Version 1.0
EOF

    echo '$RCSfile: make-jar.sh,v $ $Revision: 1.2 $ $Date: 1999/04/21 14:12:14 $ $Author: pilgpe $'
    exit 0
}

# ********************************************************************************
SysWarn ()
# ********************************************************************************
{
    # Print warning exception and allow the script to continue.
    echo "$myname: *WARNING* : $1" 1>&2
}

# ********************************************************************************
SysError ()
# ********************************************************************************
{
    # Print fatal error exception and terminate the script with error.
    echo "$myname: *ERROR* : $1" 1>&2
    exit 1
}

# ********************************************************************************
SignalCatcher() {
# ********************************************************************************
    # A generic signal handler for the shell script.
    echo "$myname: Got Signal $1"
    exit 3
}

# ********************************************************************************
CleanUp () 
# ********************************************************************************
{
    # clean up at exit remove temporary files etcetera
    echo "$myname: finito (total:$total,errors:$errors,cmpltd:$cmpltd,exclusions:$exclusions"
    test $keep_temp_files -eq 0 && \
     /bin/rm -f DUMMY_FILE $TempFile1 $TempFile2
}


# ********************************************************************************
# MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  MAIN  
# ********************************************************************************

myname=`basename $0`
PrefixCmd=""
DryRunFlag=0
VerboseOpt="+x"
DebugVerboseOpt="+x"
silent=
verbose=
debug=

# Save the current working directory now
SaveDir=`pwd`

# Where should temporaries go.
: ${TMPDIR:=/tmp}

# Reset the archiving flags
Directory=NOTHING
JarFile=NOTHING
JarVerboseFlag=""
ExtraExcludes=""
PipeCmd=0
ForceFlag=0
ListFlag=0

# Reset excludes string here.
default_AxcFlags=""
AxcFlags=$default_AxcFlags

# Set the jar 0 flag by OFF default.
JarStoreOnlyFlag=''

# Set up '--normal' as the default options!!
NormalFlag=1
keep_temp_files=0

ExcJavaFlag=0
IncJavaFlag=0
ExcCppFlag=0
ExcObjectsFlag=0
ExcBinFlag=0
ExcLibsFlag=0
ExcTempFlag=0
ExcCoreFlag=0
ExcRcsFlag=0
ExcSccsFlag=0
ExcDotFlag=0
ExcZipFlag=0
ExcJarFlag=0
ExcTarFlag=0
ExcCpioFlag=0
ExcPatchFlag=0
ExcEmacsFlag=0

total=0
exclusions=0
cmpltd=0
errors=0

# Temporary directory
: ${TMPDIR:=/tmp}

# Java Archive Command
: ${JAR_CMD:=jar}

#
# Command Line Arguments interpretation
#
with_opt=NONE
first_arg=dummy
prev_arg=0
while [ $# -gt 0 ]
do
    #
    # Interpret current command line argument
    #
    case $1 in

	-store | --store | --stor | --sto | --st | --0 | -0 )
	# Do NOT compress JAR with ZLIB algorithm
	JarStoreOnlyFlag='0'
	;;

	-nostore | --nostore | --nostor | --nosto | --nost | ++0 | +0 )
	# compress JAR into one large file with ZLIB algorithm
	JarStoreOnlyFlag=""
	;;

	-normal | -norm | --normal | --norma | \
	--norm | --nor | --no | --n | -n )
	    NormalFlag=1
	    ExcJavaFlag=1
	    ExcObjectsFlag=1
	    ExcBinFlag=1
	    ExcLibsFlag=1
	    ExcTempFlag=1
	    ExcCoreFlag=1
	    ExcRcsFlag=1
	    ExcSccsFlag=1
	    ExcDotFlag=1
	    ExcEmacsFlag=1
	    ;;
 
	-force | --force | --forc | --for | --fo | --f | -f )
	   ForceFlag=1;;

	-excl-java | --excl-java | --excl-jav | --excl-ja | \
	--excl-j | -excl-j )
	   # Exclude java source files
	   ExcJavaFlag=1;  NormalFlag=0 ;;

	-incl-java | --incl-java | --incl-jav | --incl-ja | \
	--incl-j | -incl-j )
	   # Include java source files
	   ExcJavaFlag=0;  IncJavaFlag=1; NormalFlag=0 ;;

	-excl-jar | --excl-jar )
	   # Exclude java archive files
	   ExcJarFlag=1;  NormalFlag=0 ;;

	-incl-jar | --incl-jar )
	   # Include java archive files
	   ExcJarFlag=0;  NormalFlag=0 ;;

	-excl-binaries | -excl-bin | \
	--excl-binaries | --excl-binarie | --excl-binari | --excl-binary | \
	--excl-binar | --excl-bina | --excl-bin | --excl-bi | --excl-b )
	   ExcBinFlag=1;  NormalFlag=0 ;;

	-excl-objects | -excl-obj | \
	--excl-objects | --excl-object | --excl-objec | --excl-obje | \
	--excl-objs | --excl-obj | --excl-ob | --excl-o )
	   ExcObjectsFlag=1;  NormalFlag=0 ;;

	-excl-libraries | -excl-lib | \
	--excl-libraries | --excl-librarie | --excl-librari | --excl-library | \
	--excl-librar | --excl-libra | --excl-libr | \
	--excl-libs | --excl-lib | --excl-li | --excl-l )
	   ExcLibsFlag=1;  NormalFlag=0 ;;

	-excl-temp | -excl-tmp | \
	--excl-temp | --excl-tem | --excl-tmp | --excl-te )
	   ExcTempFlag=1;  NormalFlag=0 ;;

	-excl-emacs | -excl-em | \
	--excl-emacs | --excl-ema | --excl-em )
	   ExcEmacsFlag=1;  NormalFlag=0 ;;

	-excl-core | -excl-co | \
	--excl-core | --excl-cor | --excl-co )
	   ExcCoreFlag=1;  NormalFlag=0 ;;

	-excl-rcs | -excl-rc | \
	--excl-rcs | --excl-rc | --excl-r )
	   ExcRcsFlag=1;  NormalFlag=0 ;;

	-excl-sccs | -excl-sc | \
	--excl-sccs | --excl-scc | --excl-sc | --excl-s )
	   ExcSccsFlag=1;  NormalFlag=0 ;;

	-excl-dot | -excl-do | \
	--excl-dot | --excl-do | --excl-d )
	   ExcDotFlag=1;  NormalFlag=0 ;;

	-excl-zip | -excl-zi | \
	--excl-zip | --excl-zi | --excl-z )
	   ExcZipFlag=1;  NormalFlag=0 ;;

	-excl-tar |  --excl-tar)
	   ExcTarFlag=1;  NormalFlag=0 ;;

	-excl-patch | -excl-pat | \
	--excl-patch | --excl-patc | --excl-pat )
	   ExcPatchFlag=1;  NormalFlag=0 ;;

	-exclude | -exclu | --exclude | --exclud | --exclu | --x | -x )
	   if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
	   AxcFlags="${AxcFlags}$2";
	   ExtraExcludes="${ExtraExcludes} -e $2"
	   shift ;;

	--list | --lis | --li | --l | -list | -lis | -li | -l )
	   ListFlag=1
	   ;;

	# **** The standard CLI options begin here ****
	-silent | -quiet | \
	--silence | --silenc | --silenc | --silen | --sile | --sil | \
	--quiet | --quie | --qui | --qu | --q | -q )
	silent=yes
	verbose=
	VerboseOpt="+x"
	;;
 
	-verbose | --verbose | --verbos | --verbo | --verb | \
	--ver | --ve | --v | -v ) 
	verbose=yes
	VerboseOpt="-x"
	;;

	--debug | --debu | --deb | -debug | -debu | -deb ) 
	debug=yes
        ;;

	--dryrun | --dryru | --dryr | --dry | --dr | -dr | \
	-dryrun | -dryru | -dryr | -dry | -dr | -dr )
	PrefixCmd="echo =>"
	DryRunFlag=1
	;;

	--help | --hel | --he | --h | -help | -hel | -he | -h | \
	--usage | --usag | --usa | --us | --u | \
	-usage | -usag | -usa | -us |  -u )
	PrintUsage
	exit 0
	;;

	--* | -*)
	SysError "unknown cli option: '$1'. Try '--help' for more info"
	break;;

	*) break;;

    esac
    shift
done

#
# Trap any signals
#
trap 'CleanUp "Cleaning"' 0
trap 'SignalCatcher "(SIGHUP)"'  1
trap 'SignalCatcher "(SIGINT)"'  2
trap 'SignalCatcher "(SIGQUIT)"' 3
trap 'SignalCatcher "(SIGTERM)"' 15

#
# Interpret the remaining command lines arguments
#
if [ $# -lt 3 ]; then
    SysError "requires a JAR filename, an a active directory
and at least one source directory. Try \`--help' to see details."
fi

#
# Sanity checking
#
JarFile=$1; shift
ActiveDirectory=$1; shift
if [ ! -d $ActiveDirectory ]; then
    SysError "active directory:\`$ActiveDirectory' no such directory."
fi

#
# Handle verbosity
#
if test -n "$verbose"; then
   JarVerboseFlag="v"
   VerboseOpt="-x"
else
   JarVerboseFlag=""
   VerboseOpt="+x"
fi

if test -n "$debug"; then
   JarVerboseFlag="v"
   DebugVerboseOpt="-x"
else
   DebugVerboseOpt="+x"
fi


#
# Check for absolute or relative in the final tar file
#
# Save the current working directory now
SaveDir=`pwd`
case $JarFile in
     /* )
	ThisJarFile=$JarFile
	;;
     -)
        ThisJarFile=$JarFile
	PipeCmd=1
	;;
     *)
	ThisJarFile=$SaveDir/$JarFile
	;;
esac

# Set up the java archive build directory.
JarBuildDir=`pwd`/jarbuild

# Remove the java archive build directory 
if [ -d ${JarBuildDir} ]; then
    test -n "$verbose" && \
     echo "Removing *OLD* jar build directory:\`${JarBuildDir}'"
    ( set ${DebugVerboseOpt}; ${PrefixCmd} /bin/rm -rf ${JarBuildDir} )
fi

# Create the Java Archive build directory 
test -n "$verbose" && \
 echo "Creating *NEW* Jar build directory:\`${JarBuildDir}'"
( set ${DebugVerboseOpt}; ${PrefixCmd} mkdirhier ${JarBuildDir}; );
status=$?
if [ $status -ne 0 ]; then
    SysError "cannot create build directory:\`${JarBuildDir}'"
fi

# Define the name of excluded files from the JAR archive
# Remove the exclusion file
JarExcludeFile=${JarFile}.EXCLUDE
/bin/rm -rf ${JarExcludeFile}
cat /dev/null > ${JarExcludeFile}




if [ $ExcJavaFlag -ne 0 ] ; then
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.java$"
fi
if [ $ExcJarFlag -ne 0 ] ; then
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.jar$|\\.zip$|\/#"
fi
if [ $ExcCppFlag -ne 0 ] ; then
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.[ch]$|\\.[CH]$|\\.cc$|\\|.cpp$"
fi
if [ $ExcObjectsFlag -ne 0 ] ; then
    ## ExcObjects="-e \\.o$ -e \\.obj$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.o$|\\.obj$"
fi
if [ $ExcLibsFlag -ne 0 ] ; then
    ## ExcLibs="-e \\.a$ -e \\.so$ -e \\.sa$ -e \\.sl$ "
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.a$|\\.so$|\\.sa$|\\.sl$"
fi
if [ $ExcPatchFlag -ne 0 ] ; then
    ## ExcPatch="-e \\.save$ -e \\.orig$ -e \\.patch$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.save$|\\.orig$|\\.patch$"
fi
if [ $ExcDotFlag -ne 0 ] ; then
    ## ExcDot="-e /\\."
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}/\\."
fi
if [ $ExcTempFlag -ne 0 ] ; then
    ## ExcTemp1="-e .~$ -e \\.bak$ -e \\.tmp$ "
    ExcTemp2="-e /# -e .BAK$ -e .mail$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}.~$|\\.bak$|\\.tmp$|\/#|\\.BAK$|\\.mail$"
fi
if [ $ExcCoreFlag -ne 0 ] ; then
    ## ExcCore="-e /core$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}/core$"
fi
if [ $ExcSccsFlag -ne 0 ] ; then
    ## ExcSccs="-e /SCCS -e /s\\. -e /p\\."
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}/SCCS|/s\\.|/p\\."
fi
if [ $ExcRcsFlag -ne 0 ] ; then
    ## ExcRcs="-e /RCS  -e \\,v$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}/RCS|/CVS|\\,v$"
fi
if [ $ExcEmacsFlag -ne 0 ] ; then
    ## ExcEmacs="-e .flc$  -e /# -e /\!"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.flc$|/#|/\!"
fi
if [ $ExcTarFlag -ne 0 ] ; then
    ## ExcTar="-e \\.tar$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.tar$"
fi
if [ $ExcCpioFlag -ne 0 ] ; then
    ## ExcCpio="-e \\.cpio$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.cpio$"
fi
if [ $ExcZipFlag -ne 0 ] ; then
    ## ExcZip="-e \\.gz$ -e \\.tgz$ -e \\.z$ -e \\.Z -e \\.tz$"
    if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
    AxcFlags="${AxcFlags}\\.gz$|\\.zip$|\\.tgz$|\\.z$|\\.Z|\\.tz$"
fi

# Make sure the exclusion file is also excluded!!
if [ "x$AxcFlags" != "x" ]; then AxcFlags="${AxcFlags}|"; fi
AxcFlags="${AxcFlags}`basename ${JarExcludeFile}`|TAR-EXCLUDE$|\\.EXCLUDE$"

test -n "$debug" && echo "(*DEBUG*) AxcFlags='$AxcFlags'"

### Uncomment to debug & stop the exclude regex *PP*
### echo "*** DEATH 69 ***"; exit 69

# Change to the active directory
cd $ActiveDirectory

# Iterate through each source directory
for SourceDir in "$@"
do
    SourceDir=$1 ; shift
    if [ ! -d ${SourceDir} ]; then
	SysError "source directory:\`$ActiveDirectory/$SourceDir' not found."
    fi

    # Set up the temporary file for Jar File
    TempFile1=${TMPDIR}/$myname.classes.${JarFile}
    /bin/rm -rf ${TempFile1}

    # find . -type f -mount -xdev -prune -print > ${TempFile1}
    find ${SourceDir} -type f -prune -print > ${TempFile1}

    #
    # Copy the files from the source directory to the destination
    # directory making the directories as and when. We exclude
    # any files that match the exclusion list.
    #
    exec 4<&0		;# Save standard input channel
    exec < ${TempFile1}

    while read ClassFile
    do
	total=`expr $total + 1`
	ClassFile=`echo "$ClassFile" | sed 's!^\./!!g'`
	File=`basename $ClassFile`
	Temp=`echo "$ClassFile" | egrep "${AxcFlags}"`
	## test -n "$debug" && echo "Temp='$Temp'"
	if [ "x${Temp}" != "x" ]; then
	    exclusions=`expr $exclusions + 1`
	    echo "[$total] Excluding	\`$ClassFile'"
	    echo "$ClassFile" >> ${JarExcludeFile}
	elif [ -x $ClassFile ]; then 
	    exclusions=`expr $exclusions + 1`
	    echo "[$total] Excluding	\`$ClassFile' (*Executable*)"
	    echo "$ClassFile" >> ${JarExcludeFile}
	else
	    ### set -x
	    InputDir=`dirname $ClassFile`
	    DestDir=${JarBuildDir}/${InputDir}
	    if [ $DryRunFlag -eq 0 ]; then
		echo "[$total] copying	\`$ClassFile'"
	    fi
	    if [ ! -d ${DestDir} ]; then
		${PrefixCmd} mkdirhier ${DestDir} ; status=$?
		if [ $status -ne 0 ]; then
		    errors=`expr $errors + 1`
		    SysError "cannot make directory:\`$DestDir'"
		fi
	    fi
	    ( set ${DebugVerboseOpt}; ${PrefixCmd} cp ${ClassFile} ${DestDir}/${File} )
	    status=$?
	    if [ $status -ne 0 ]; then
		errors=`expr $errors + 1`
		SysWarn "cannot copy file:\`$ClassFile'"
	    else
		cmpltd=`expr $cmpltd + 1`
	    fi
	    ## echo "*** DEATH 69 ***"; exit 69
	fi
    done 
done

exec 0<&4		;# Restore standard input channel

### set -x
if [ $PipeCmd -eq 0 -a -z "$silent" ]; then
    echo "Copied $cmpltd files to dir:\`$JarBuildDir'"
fi

if [ $PipeCmd -eq 0 -a -z "$silent" ]; then
    echo
    echo $Bar80
    echo "-*- Building Java Archive -*- : '${JarFile}'"
    echo $Bar80
fi

if [ "$ThisJarFile" != "-" ]; then
    # Also long as the target jar is not a pipe, then remove the old jar.
    if [ -f ${ThisJarFile} ]; then
        /bin/rm -f ${ThisJarFile};
    fi
fi

# Change the build directory and then build the archive
cd $JarBuildDir


(set ${DebugVerboseOpt}; ${PrefixCmd} \
 ${JAR_CMD} ${JarStoreOnlyFlag}c${JarVerboseFlag}f ${ThisJarFile} . ); status=$?
if [ $status -ne 0 ]; then
    if [ $ForceFlag -eq 0 ]; then
	SysError "couldn't create jar file: \`${JarFile}'
	(final status: $status)" 1>&2
    else
	echo "Command '${JarCmd}' returned error (status:$status)"
	echo "However force flag was set -- ignoring status"
    fi
fi

if [ -n "$debug" -o $ListFlag -ne 0 ]; then
    echo "-*- Long List of Jar File -*-"
    ${PrefixCmd} ls -l ${ThisJarFile}
fi

if [ $PipeCmd -eq 0 -a -z "$silent" ]; then
    echo "completed file: '$ThisJarFile'."
fi

# Finally remove the build directory.
cd $SaveDir
if [ -d ${JarBuildDir} ]; then
    /bin/rm -rf ${JarBuildDir}
fi

exit
# fini
