#! /bin/sh
. /lib/libtaz.sh
. /etc/slitaz/slitaz.conf
DIALOG=dialog
LOG='/var/log/slitaz/tazpkg.log'
[ ! -f $LOG ] && LOG='/var/log/tazpkg.log'
exec 3>&1
aa=$($DIALOG \
    --title "-tazpkg-remove-sort-by-log" \
    --item-help \
    --checklist "" 30 61 111 \
    $(for p in $(cat $LOG | cut -d' ' -f6 | uniq); \
    do
	if [ -f $INSTALLED/$p/receipt ]; then
	echo "$p"; \
	. $INSTALLED/$p/receipt ; \
	echo -e "$UNPACKED_SIZE---$PACKED_SIZE"; \
	echo -e "off" ; \
	echo -e "$VERSION" ; \
	fi
    done) \
2>&1 1>&3)

#	cat $PKGS_DB/installed.info |  ; \
#cat $PKGS_DB/installed.info | grep "^${p}	" | cut -d'	' -f4 | sed 's/ /`/g'  ; \
#	echo -e "$VERSION" ; \
#	echo -e "${DEPENDS}" | sed 's/ /_/g' ; \
#	echo -e "$VERSION" ; \
#		unset $DEPENDS ; \
#	[ -z $DEPENDS ] && DEPENDS="AAA" ; \
# 		echo -e "$VERSION" | sed 's/ //g' | sed 's/[^a-z|-]//g' | sed 's/ /_/g' ; 

retval=$?
echo $aa
[ retval = 0 ] || \
for r in $(echo $aa | sed 's/"//g');do echo y | tazpkg -r $r;done
##| grep VERSION )  | sed 's/[^0-9]//g') \
