Okay, the headline is not really the full truth, but with the help of vi you can do some cool things.
I had installed „graphviz“ on one of my servers, because I thought I could create a dot file. For some reason […] that did not work and so I decided to remove this package again. I wanted it really clean.
Normally someone would just do something like
apt-get autoremove –purge graphviz
but sometimes that does not remove all previously installed dependencies.
All package stuff gets logged to /var/log/apt/history.log. At least here on Ubuntu Lucid 😉
So you may find a block like the following one:
Start-Date: 2011-10-23 14:41:00
Install: libts-0.0-0 (1.0-7build1), xfonts-encodings (1.0.3-1), ttf-dejavu-core (2.30-2), ttf-liberation (1.05.2.20091019-4), libcairo2 (1.8.10-2ubuntu1), xfonts-utils (7.5+2), libthai-data (0.1.13-1build1), libdirectfb-1.2-0 (1.2.8-5ubuntu2), libdatrie1 (0.2.2-3), fontconfig (2.8.0-2ubuntu1), libxfont1 (1.4.1-1ubuntu0.1), libpango1.0-common (1.28.0-0ubuntu2.2), libpixman-1-0 (0.16.4-1ubuntu2), libxaw7 (1.0.7-1), libgraphviz4 (2.20.2-8ubuntu3), libxft2 (2.1.14-1ubuntu1), fontconfig-config (2.8.0-2ubuntu1), libice6 (1.0.6-1), libthai0 (0.1.13-1build1), libxmu6 (1.0.5-1), libxpm4 (3.5.8-1), libxrender1 (0.9.5-1), x-ttcidfont-conf (32), libfontenc1 (1.0.5-1), libjpeg62 (6b-15ubuntu1), tsconf (1.0-7build1), x11-common (7.5+5ubuntu1), libsysfs2 (2.1.0-6), libfontconfig1 (2.8.0-2ubuntu1), libpango1.0-0 (1.28.0-0ubuntu2.2), libsm6 (1.1.1-1), libxcb-render0 (1.5-2), libxt6 (1.0.7-1), defoma (0.11.10-4ubuntu1), graphviz (2.20.2-8ubuntu3), libxcb-render-util0 (0.3.6-1build1), libgd2-noxpm (2.0.36~rc1~dfsg-3.1ubuntu1)
End-Date: 2011-10-23 14:41:10
Simply copy this code into a file and open it with vi. Now type the following command:
:%s/\( ([\.0-9a-z\-+~]\+),\?\)//g
Remove the Install: and the Start and End line. Save it.
Now:
cat filename | xargs apt-get autoremove --purge -y
No guarantees, have fun…
I want to test it with Debian Squeeze but the code line only removes the version details with and into the round brackets. The Install: and Start and End lines are still exists.
Here are the result:
Start-Date: 2011-10-23 14:41:00
Install: libts-0.0-0 xfonts-encodings ttf-dejavu-core ttf-liberation libcairo2 xfonts-utils libthai-data libdirectfb-1.2-0 libdatrie1 fontconfig libxfont1 libpango1.0-common libpixman-1-0 libxaw7 libgraphviz4 libxft2 fontconfig-config libice6 libthai0 libxmu6 libxpm4 libxrender1 x-ttcidfont-conf libfontenc1 libjpeg62 tsconf x11-common libsysfs2 libfontconfig1 libpango1.0-0 libsm6 libxcb-render0 libxt6 defoma graphviz libxcb-render-util0 libgd2-noxpm
End-Date: 2011-10-23 14:41:10
Could it be a problem with the vi version (VIM – Vi IMproved 7.2 (2008 Aug 9, compiled Jul 12 2010 12:49:33)) which comes with Debian Squeeze?!
Sorry for delayed answer. I haven’t tried this for a long time. So unfortunately I can not tell you, if this tip still works. But I guess it does not need very complex modification to work with Squeeze
Ah, just one thing: did you follow this:
„Remove the Install: and the Start and End line. Save it.“
as is said above?