#!/bin/dash
# (C) James Budiono 2014
# License: GPL Version 3 or later.
#
### view contents of a tarball
# $1 - tarball package

[ -z "$1" ] && echo "Usage: ${0##*/} tarball" && exit
out=$(mktemp -p /tmp viewtarball.XXXXXXXX)

(
### 1. List
tar -tvf "$1" 2>/dev/null | awk -v fn="$1" '
BEGIN {
	print "Contents of " fn "\n==="
}
{
	for (i=6; i<=NF; i++) printf ("%s",$i)
	print ""
}
END {
	print "===\nListing completed."
}' 
) > $out &

Xdialog --title "View Tarball $1" --no-cancel --tailbox $out 25 80
rm $out
