Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
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 Answers 3

up vote 1 down vote accepted

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.