#!/bin/sh
program="`basename $0`"
usage="Usage: $program tarfile
Extracts directories from a gzipped tar file created by \`cvs-wrap'.
"
for option
do
case "$option" in
-h | --help)
echo "$usage"
exit 1
;;
-*)
echo "$program: Unknown option: $option"
echo "$usage"
exit 1
;;
*)
;;
esac
done
if [ $ echo "$program: Invalid parameters."
echo "$usage"
exit 1
fi
if [ ! -f "$1" ]; then
echo "$program: \`$1' doesn't exist."
echo "$usage"
exit 1
fi
tmpfile="$1.cvswrapped-file-$$"
rm -rf "$tmpfile"; mv "$1" "$tmpfile"
if `gzip -t "$tmpfile" > /dev/null 2>&1`; then
wrapper=`gzip -d -c "$tmpfile" | gnutar -t -f - | head -1`
rm -rf "$wrapper"
gzip -d -c "$tmpfile" | gnutar -m --preserve --sparse -x -f -
else
wrapper=`gnutar -t -f "$tmpfile" | head -1`
rm -rf "$wrapper"
gnutar -m --preserve --sparse -x -f "$tmpfile"
fi
rm -rf "$tmpfile"
exit 0