8

Is it possible to undo all changes made by "aptitude build-dep xxxxxx" i.e to un-install all dependencies installed by this command?

binW
  • 13,034
  • Remove the program (for which you installed dependencies) and the type sudo apt-get autoremove . this might work. – Ashu May 22 '12 at 18:33
  • @Ashu: No, it doesnt. Already tried it. – binW May 22 '12 at 18:50
  • try this apt-cache depends PACKAGE_NAME this will print all the packages needed by a program and the uninstall whatever you think is not needed – Ashu May 22 '12 at 19:27

3 Answers3

9

For the future, I highly recommend using mk-build-deps -i instead of aptitude build-dep. That leaves a package installed in your system, depending on the build-deps, that you can easily uninstall later.

tumbleweed
  • 8,026
4

I found these commands on a Launchpad question:

sudo aptitude markauto $(apt-cache showsrc PACKAGE_NAME | grep Build-Depends | perl -p -e 's/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g')

There is also an alternative based around sed that copes with brackets in package names:

sudo aptitude markauto $(apt-cache showsrc PACKAGE_NAME | sed -e '/Build-Depends/!d;s/Build-Depends: \|,\|([^)]*),*\|\[[^]]*\]//g')

Note: Replace PACKAGE_NAME with your own package.

Braiam
  • 67,791
  • 32
  • 179
  • 269
Cas
  • 8,557
2

I don't think there's an automatic way. Packages installed through build-dep are recorded in the same way as if they'd been directly requested by name.

If you know approximately when you ran aptitude build-dep, you can find which packages got installed when you ran the command by looking through the logs in /var/log/aptitude* or /var/log/apt/*.

You can run apt-cache showsrc PACKAGENAME | grep '^Build-depends:' to list the build dependencies of the package. Review each of them to see if you want them; mark the ones you don't care about as not manually installed (apt-get markauto PACKAGENAME) and flush the non-required packages (apt-get autoremove).