I have done many actions with aptitude 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 aptitude 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 safe-upgrade
apt-undo full-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
Like this:
Like Loading...
Nice one Joel!
Thanks!
Didn’t work on Lucid 10.4.3 LTS:
W: Failed to fetch http://ppa.launchpad.net/lkjoel/apt-undo/ubuntu/dists/lucid/main/binary-i386/Packages.gz 404 Not Found
E: Some index files failed to download, they have been ignored, or old ones used instead.
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package apt-undo
I fixed it. Try installing it again.
Your life might be easier if you would parse /var/log/apt/history.log* as this already tells you at great details what APT did and then. You could avoid causing harm e.g. if you install package A which depends on B > 2, but the user only had B = 1 installed. B shows up in dpkg.log as installed and you would remove it, but it was only an upgrade and properly other installed packages depend on it. APT’s log on the other hand tells you the difference between Install and Upgrade… And catches not only what you have done with apt-undo but also apt-get, aptitude, synaptics, software-center, … (= whole APT family).
Bonuspoints if you can implement something like an apt-history command which parses this file (and its logrotates) in the process of implementing ‘apt-get undo’ (Even through its not a real undo in case of upgrades of B so a different yet-to-imagine name is maybe better).
Either way, the APT team would happy to hear from you if you want to make that happen (and properly also if you “just” want to chat
).
Thanks! I’ll see what I can do.
Hello,
apt-undo doesn’t work for me. Unfortunately I couldn’t figure out what’s wrong. Here are the errors I get: http://pastebin.com/T9ERYqCt
I get these errors both on my computer running Ubuntu 11.04 and on a fresh Ubuntu 10.10 install in VirtualBox.
I found out the possible cause for the error (I’m not sure if this causes it though): the “lastundo” file is never created but then the script tries to copy it and it obviously can’t.
I think I have fixed it now.
Last fix didn’t work. I think this fix does now. (0.1.5)
Pingback: Apt-Undo - A simple way of undoing Apt actions | Ubuntu Geek
Pingback: APT undo « Lablo´s Ubuntu Blog
Pingback: apt-undo, o como deshacer lo que haces con apt-get | El atareao
Pingback: APT-UNDO « El Programador Hereje
I am going to just say what a relief to discover a person who actually knows what theyre speaking about on the net. You certainly know how to bring a matter to light and make it important. More folks should look at this and fully grasp this side of the story. I cant believe youre not more popular since you definitely possess the gift.
I like Your Article about Apt-Undo, a simple way of undoing Apt actions lkubuntu Perfect just what I was looking for! .
Pingback: apt undo o como deshacer lo que haces con apt g