Ubuntu – How to remove all build dependencies for a particular package


When I want to compile something from source in Ubuntu/Debian, I usually get build-dependencies by running "sudo apt-get build-dep PACKAGE_NAME" in the terminal.

They are (usually) useless once the compilation job is done.

So, how do I remove all build-dependencies for a particular package?

Best Answer

To find out the build-dependencies of a program you can run apt-cache showsrc pkgname and that will list, amongst other information the Build-Depends, which are often files ending in -dev; although it is worth checking if any of the files (particularly those not marked -dev) are required by other programs. You could find this out by using apt-cache depends file and apt-cache rdepends file. The following example is for Shotwell:

apt-cache showsrc shotwell

Build-Depends: debhelper (>= 7.0.50~), m4, valac-0.16 (>= 0.15), libgee-dev (>= 0.5.0), libgtk-3-dev (>= 3.0.11), libexif-dev (>= 0.6.16), libsqlite3-dev (>= 3.5.9), libgexiv2-dev (>= 0.4.1-1build1), libgnomevfs2-dev (>= 2.24.2), libgphoto2-2-dev (>= 2.4.2), libsoup2.4-dev (>= 2.26.0), libxml2 (>= 2.6.32), libunique-3.0-dev (>= 1.0.0), libwebkitgtk-3.0-dev (>= 1.1.5), libgudev-1.0-dev (>= 145), libdbus-glib-1-dev (>= 0.80), libraw-dev (>= 0.13.1-2), libusb-dev, libjson-glib-dev (>= 0.7.6), libgstreamer0.10-dev (>= 0.10.28), libgstreamer-plugins-base0.10-dev (>= 0.10.32), python-scour, libunity-dev, liblaunchpad-integration-3.0-dev (>= 0.1.36), librest-dev

There is a command to do it all in one go at the webupd8 site, but I have found that it doesn't seem to work reliably with the current version of Ubuntu in that it seems to remove too much. I tried it with Pinta and it suggested removing the entire mono library. There is discussion of such problems with using commands like the webupd8 one at Launchpad. Be very careful when experimenting with any 'solutions' you might find.

It is a shame that there is no autoremove command for build-dep installed packages.

Related Question