#!/bin/bash
#set -x ; mkdir -p /root/LOGs; NAME=$(basename "$0"); exec 1>> /root/LOGs/"$NAME".log 2>&1
export TEXTDOMAIN=petget___pkg_chooser.sh
export OUTPUT_CHARSET=UTF-8
[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
# Check input
if [ "$TREE2" != "" ]; then
if [ "$(grep $TREE2 /tmp/pkgs_to_remove)" = "" ]; then
echo "$TREE2" >> /tmp/pkgs_to_remove
fi
else
exit 0
fi
report_window () {
#[ ! -f /tmp/remove_pets_quietly ] && exit 0
/usr/local/petget/finduserinstalledpkgs.sh
sync
rm -f /tmp/pgks_really_removed 2>/dev/null
rm -f /tmp/pgks_failed_to_remove 2>/dev/null
for LINE in $(cat /tmp/pkgs_to_remove_done)
do
REALLY=$(grep $LINE /tmp/petget/installedpkgs.results)
if [ "$REALLY" = "" ]; then
echo $LINE >> /tmp/pgks_really_removed
else
echo $LINE >> /tmp/pgks_failed_to_remove
fi
done
REMOVED_PGKS="$(${MAYBEREM}"
fi
cat << EOF > /tmp/overall_remove_deport
Packages succesfully uninstalled:
$REMOVED_PGKS
Packages that did not uninstall properly or the user abortded their removal:
$FAILED_TO_REMOVE
Installed packages that may not be needed after the removal of the above:
$MAYBEREM
EOF
# Info window/dialogue (display and option to save "missing" info)
export REPORT_DIALOG='
'"`/usr/lib/gtkdialog/xml_info fixed package_remove.svg 60 " " "$(gettext "Remove packages report")"`"'
'"`/usr/lib/gtkdialog/xml_pixmap dialog-complete.svg 32`"'
'"`/usr/lib/gtkdialog/xml_pixmap dialog-error.svg 32`"'
'"`/usr/lib/gtkdialog/xml_pixmap building_block.svg 32`"'
'"`/usr/lib/gtkdialog/xml_scalegrip`"'
'
RETPARAMS="`gtkdialog --center -p REPORT_DIALOG`"
rm -f /tmp/pgks_really_removed
rm -f /tmp/pgks_failed_to_remove
rm -f /tmp/pkgs_to_remove_done
rm -f /tmp/overall_remove_deport
rm -f /tmp/overall_petget-deps-maybe-rem
echo 100 > /tmp/petget/install_status_percent
}
export -f report_window
remove_package () {
[ ! "$( /tmp/petget/install_status_percent
echo "$(gettext 'Removing'): $LINE" > /tmp/petget/install_status
#---
if [ -f /tmp/remove_pets_quietly ]; then
if [ "$(cat /var/local/petget/nt_category 2>/dev/null)" = "true" ]; then
/usr/local/petget/removepreview.sh
else
rxvt -title "$(gettext 'Removing... Do NOT Close')" \
-fn -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-* -bg black \
-fg grey -geometry 80x5+50+50 -e /usr/local/petget/removepreview.sh
fi
else
/usr/local/petget/removepreview.sh
fi
sed -i "/$TREE2/d" /tmp/pkgs_left_to_remove
sync
done
/usr/local/petget/findmissingpkgs.sh
/usr/local/petget/finduserinstalledpkgs.sh
rm -f /tmp/{pkgs_to_remove,pkgs_left_to_remove}
report_window
rm -f /tmp/remove_pets_quietly 2>/dev/null
}
export -f remove_package
classic_remove () {
rm -f /tmp/remove{,_pets}_quietly 2>/dev/null
cp -a /tmp/pkgs_to_remove /tmp/pkgs_to_remove_done
remove_package
echo 100 > /tmp/petget/install_status_percent
}
export -f classic_remove
auto_remove () {
rm -f /tmp/remove_pets_quietly 2>/dev/null
touch /tmp/remove_pets_quietly
cp -a /tmp/pkgs_to_remove /tmp/pkgs_to_remove_done
remove_package
}
export -f auto_remove
delete_out_entry () {
sed -i "/$TREE2/d" /tmp/pkgs_to_remove
}
export -f delete_out_entry
case "$1" in
"$(gettext 'Auto remove')") auto_remove;;
"$(gettext 'Step by step remove (classic mode)')") classic_remove;;
esac