Can I undo apt-get build-dep?

Asked by Eddy Mulyono on 2007-06-18

I invoked `apt-get source python2.5` and `apt-get build-dep python2.5`.

APT installed and removed a bunch of stuff.

Fast forward 2 days later, I want to uninstall the packages installed by `apt-get build-dep python2.5`. Is there an automated way to do this?

Thanx in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
APT Edit question
Assignee:
No assignee Edit question
Solved by:
Hanusz leszek
Solved:
2007-06-20
Last query:
2007-06-20
Last reply:
2007-06-20
Hanusz leszek (leszek-skynet) said : #1

Hello,

I don't know any automated way to do this but you can do it manually.

find the dependencies of python2.5:
apt-cache depends python2.5

for each of the dependencies, find the packages that needs them, ie:
apt-cache rdepends python2.5-minimal

If there is a package you want to keep which need the dependency, do nothing.

If there isn't a package you want to keep which need the dependency, then you need to check the dependencies of this package before removing it (recursively), ie:
apt-cache depends python2.5-minimal
apt-get remove python2.5-minimal
apt-cache rdepends zlib1g

...
...

Eddy Mulyono (eddymul) said : #2

`apt-cache depends` (and rdepends) only shows me the runtime dependencies, which are often just a subset of the build time dependencies (which often includes build-essential, debhelper, dpkg-dev, *-dev).

Best Hanusz leszek (leszek-skynet) said : #3

You're right.

You can view the build dependencies with apt-cache showsrc <package>.

Eddy Mulyono (eddymul) said : #4

There appears to be no automated way to do this. :(

Thanx, though, Hanusz.

Thiago Teixeira (tvst) said : #5

In special cases you could run something like:

apt-cache showsrc tracker-search-tool | grep Build-Depends: | sed -e 's/Build-Depends:\|,\|([^)]*)//g' | xargs sudo apt-get remove

But it doesn't really work most of the times because of cross-dependencies. If you do run it, make sure you read what apt-get tells you it's doing!!

Thiago Teixeira (tvst) said : #6

lol, in my example, replace tracker-search-tool with the app whose dependencies you want to remove! i forgot it there from my testing... :)

Thiago Teixeira (tvst) said : #7

Ok, I think I got it:

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

ppine (ppine) said : #8

Yep that works great tvst, i made a little bash script so its more easy to use.

#!/bin/bash
echo App name?
read -s PARAM

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

Wesley Schwengle (wesleys) said : #9

The tvst way didn't work for me for mplayer-nogui on zsh, I've modified it a bit:

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

Keith Kyzivat (kamaji) said : #10

Some Build-Depends lines include information in brackets in addition to the versioning information in parentheses. This information appears to be architecture information augmented with something else. Here's an example of the Build-Depends for memtest86+ on an AMD64 Ubuntu 10.04 install:

Build-Depends: debhelper (>> 5.0.0), dh-buildinfo, gcc-multilib [amd64 kfreebsd-amd64]

The prior examples of ways to remove this do not work for this particular Build-Depends line.
Here's an updated command line that will handle it. It also condenses the functionality provided by grep into the sed line:

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

ottadini (ben-harrison) said : #11

Seems to work very well. Just doesn't catch the final braces?

harb@joan:~$ sudo aptitude markauto $(apt-cache showsrc banshee | sed -e '/Build-Depends/!d;s/Build-Depends: \|,\|([^)]*),\|\[[^]]*\]//g')
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Couldn't find any package matching "(>". However, the following
packages contain "(>" in their description:
  libtao-dev openswan tightvncserver gmusicbrowser timeout libtao-orbsvcs-dev sl-modem-daemon backintime-kde4 ctorrent
  build-essential mediawiki-extensions prctl desktop-profiles xtightvncviewer autoconf2.64 autoconf2.59
Couldn't find any package whose name or description matched "0.10.25.2)"
Couldn't find any package matching "(>". However, the following
packages contain "(>" in their description:
  libtao-dev openswan tightvncserver gmusicbrowser timeout libtao-orbsvcs-dev sl-modem-daemon backintime-kde4 ctorrent
  build-essential mediawiki-extensions prctl desktop-profiles xtightvncviewer autoconf2.64 autoconf2.59
Couldn't find any package whose name or description matched "0.10.25.2)"
The following packages will be REMOVED:
  cli-common-dev{u} intltool{u} libboo-cil-dev{u} libgconf2.0-cil-dev{u} libgdata-cil-dev{u} libglib2.0-cil-dev{u}
  libgstreamer-plugins-base0.10-dev{u} libgstreamer0.10-dev{u} libgtk2.0-cil-dev{u} libipod-cil-dev{u} libipodui-cil-dev{u}
  libkarma-cil-dev{u} libmono-addins-cil-dev{u} libmono-addins-gui-cil-dev{u} libmono-zeroconf-cil-dev{u} libmtp-dev{u}
  libndesk-dbus-glib1.0-cil-dev{u} libndesk-dbus1.0-cil-dev{u} libnotify-cil-dev{u} libsqlite3-dev{u} libtaglib-cil-dev{u}
  libwebkit-cil-dev{u} libwebkit1.1-cil{u} libxxf86vm-dev{u} mono-devel{u} monodoc-base{u} quilt{u}
0 packages upgraded, 0 newly installed, 27 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 16.7MB will be freed.
Do you want to continue? [Y/n/?]

Cas (calumlind) said : #12

The bug in kamaji's example is that is does not account for a final package with a version in brackets which does not have a trailing comma. Here is a fixed version:

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

ottadini (ben-harrison) said : #13

Good work! The only thing I can see that's a bit weird now is that there's a single pipe symbol between two versions of libwebkit. Don't think it's an issue, as the search will just not find anything called "|".

$ apt-cache showsrc banshee | sed -e '/Build-Depends/!d;s/Build-Depends: \|,\|([^)]*),*\|\[[^]]*\]//g'
debhelper dh-autoreconf autotools-dev cli-common-dev intltool lsb-release mono-devel libboo-cil-dev libdbus1.0-cil-dev libdbus-glib1.0-cil-dev libmono-addins-cil-dev libtaglib-cil-dev libmono-zeroconf-cil-dev libnotify-cil-dev libglib2.0-cil-dev libgtk2.0-cil-dev libgconf2.0-cil-dev libgudev1.0-cil-dev libgkeyfile-cil-dev libgio2.0-cil-dev libgtk-sharp-beans2.0-cil-dev libgpod-cil-dev libkarma-cil-dev libwebkitgtk-dev | libwebkit-dev libsoup2.4-dev libsoup-gnome2.4-dev libgdata-cil-dev monodoc-base libsqlite3-dev libmtp-dev gconf2 libgconf2-dev libglib2.0-dev libwnck-dev libgtk2.0-dev libx11-dev libxrandr-dev libxxf86vm-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gnome-doc-utils libgnome-desktop-dev libmono-upnp-cil-dev

Borim (borim) said : #14

For all who do not want to install aptitude just to mark some packages auto-installed: apt-mak can do the job, too.

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