#!/bin/bash
# Show jar content difference

if [ $# != 2 ] ; then
	echo  "usage: `basename $0` jar1 jar2"
	exit 1
fi

if [ -r "$1" ] ; then
	JAR1=$1
	LIST1=`basename $1`.list
else
	echo "Jar $1 not readable"
	exit 1
fi

if [ -r "$2" ] ; then
	JAR2=$2
	LIST2=`basename $2`.list
else
	echo "Jar $2 not readable"
	exit 1
fi

JAR=$JAVA_HOME/bin/jar

# get sorted jar content
$JAR tvf "$JAR1" | awk -F" " '{ print $8}' | sort > "$LIST1"
$JAR tvf "$JAR2" | awk -F" " '{ print $8}' | sort > "$LIST2"
# compute difference
diff -Naur "$LIST1" "$LIST2"
# remove files
rm -f "$LIST1"
rm -f "$LIST2"
