From From http://lkubuntu.wordpress.com
Apt-Undo, a simple way of undoing Apt actions
I have done many actions with apt-get that I later regretted, so I decided to make a script to undo those actions. This script can only work if you use this script instead of apt-get to install/upgrade/remove/purge/downgrade your packages.
To install, open up a Terminal window, and type in it:
sudo add-apt-repository ppa:lkjoel/apt-undo && sudo apt-get update; sudo apt-get install apt-undo
Usage examples:
apt-undo install yourpackages
apt-undo remove yourpackages
apt-undo purge yourpackages
apt-undo upgrade
apt-undo dist-upgrade
apt-undo install yourpackages=old.version
apt-undo install yourpackages=new.version
To undo:
apt-undo undo
# Or
apt-undo undo $HOME/.aptundo/year/month/date/yearmonthdatehourminutesseconds
# Or
bash $HOME/.aptundo/year/month/date/yearmonthdatehourminutesseconds