#!/bin/sh
#
# http://www.pdaXrom.org 2004
# package uninstaller
# ipkg-uninstall package1[ package2[.. packageN]]
#


PREFIXES="/mnt/card /mnt/cf /mnt/net /mnt/user /mnt/ide /"

findpackage () {
	echo "*** Locating package"
	# Does the list file exist?

	for PREFIX in $PREFIXES ; do
	    if [ -e "$PREFIX/usr/lib/ipkg/info/$PACKAGE.list" ]; then
		echo "*** Found $PACKAGE on $PREFIX"
		return 0
	    fi
	done

	echo "Package \"$PACKAGE\" not found on external storages."
	return 1
}

for PACKAGE in $* ; do
    findpackage && (
    ipkg -d $PREFIX remove $PACKAGE
    )
done
