lkubuntu

A listing of random software, tips, tweaks, hacks, and tutorials I made for Ubuntu

Apt-Undo, a simple way of undoing Aptitude actions

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

About these ads

21 responses to “Apt-Undo, a simple way of undoing Aptitude actions

  1. Ubudog (Michael) July 27, 2011 at 2:42 am

    Nice one Joel!

    • lkjoel July 27, 2011 at 3:30 am

      Thanks!

  2. Angela Kahealani July 27, 2011 at 3:44 am

    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

    • lkjoel July 27, 2011 at 3:03 pm

      I fixed it. Try installing it again.

  3. DonKult July 27, 2011 at 8:02 am

    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 ;) ).

    • lkjoel July 27, 2011 at 2:57 pm

      Thanks! I’ll see what I can do.

  4. Andrew July 27, 2011 at 8:22 am

    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.

    • Andrew July 27, 2011 at 8:37 am

      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.

      • lkjoel July 27, 2011 at 2:54 pm

        I think I have fixed it now.

      • lkjoel July 27, 2011 at 9:57 pm

        Last fix didn’t work. I think this fix does now. (0.1.5)

  5. Pingback: Apt-Undo - A simple way of undoing Apt actions | Ubuntu Geek

  6. Pingback: APT undo « Lablo´s Ubuntu Blog

  7. Pingback: apt-undo, o como deshacer lo que haces con apt-get | El atareao

  8. Pingback: APT-UNDO « El Programador Hereje

  9. Lose Fast Weight August 2, 2011 at 12:57 pm

    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.

  10. Cut The Rope August 6, 2011 at 5:51 pm

    I like Your Article about Apt-Undo, a simple way of undoing Apt actions lkubuntu Perfect just what I was looking for! .

  11. Pingback: apt undo o como deshacer lo que haces con apt g

  12. sepero111 August 10, 2013 at 3:04 pm

    The ppa appears to be giving 404 right now. I can’t wait to try it out. Is the source on github?

    • MiJyn August 10, 2013 at 9:59 pm

      Hmm, that’s a good idea… I’ll do that soon :D

  13. sepero111 August 11, 2013 at 1:46 am

    I kind of beat you to it my friend. I added it minutes after I wrote the comment.
    https://github.com/Sepero/Apt-Undo

    But don’t let that stop you if you’re gonna do it too. Maybe you can get some ideas from how I uploaded it and do it better than me. (If so, please let me know.) I obviously stripped all the packaging stuff away. I was gonna make a few modifications to it, via the GPL3, of course. Also, I was thinking to give it some test runs with Ubuntu 12.04, because I wasn’t sure if you were still on Arch. Cheers to You and GNU software. :)

    • MiJyn August 11, 2013 at 8:00 am

      Oh awesome!! I won’t repeat work, and what you did there looks perfectly fine :D

      Yeah, I’m not sure if it’ll work on Ubuntu 12.04 or not… since it’s pretty much just one big hack :P Let’s hope it does though ^^

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 166 other followers

%d bloggers like this: