#!/bin/sh
#---------------------------------------------------------------------
#
#	MUG is Maemo by/for Uber-Geeks - a collection of tools and
#	utilities for the Nokia770 by Uber-Geeks.com
#
#	mug-pkgextract.sh v0.1 [2005feb15]
#
#	Unless otherwise documented in the code, this software
#	has been released under the GNU General Public License
#	and is copyright mug@uber-geeks.com.
#
#	More information about the GPL can be found on the GNU website.
#
#	All of this software is considered to be "stable". However,
#	it is always a good idea to test and/or review code before
#	relying on it. There is no warranty for this code beyond what
#	is required by the GPL. 
#
#	usage mug-pkgextract.sh packagename extractdir
#
#	author mug@uber-geeks.com	
#
#---------------------------------------------------------------------
#
#	test for both input parameters
#
if [ -z $1 -o  -z $2 ] ; then
	echo 
	echo "mug-pkgextract.sh v0.1a[2005feb14] GPL2"
	echo
	echo "usage: mug-pkgextract.sh packagename extractdir"
	echo
	exit 1 ;
fi
#
#	test for existance of input package
#
if [ ! -f $1 ] ; then
	echo $1 " not found - aborting"
	exit 1 ;
fi
#
#	test for existance of output directory
#
if [ -d $2 ] ; then
	echo $2 " exists. please select new target dir - aborting"
	exit 1 ;
fi
#
#	test for existance of output directory
#
if [ ! -x /usr/bin/dpkg-deb ] ; then
	echo "/usr/bin/dpkg-deb not foundi - aborting"
	exit 1 ;
fi
#
#	finally extract the package contents
#
/usr/bin/dpkg-deb --extract $1 $2
/usr/bin/dpkg-deb --control $1 $2/DEBIAN


	

