11

Is there a command that installs all the unmet build dependencies that dpkg-checkbuilddeps would list?

I tried to sed the output and give it to apt-get install, but it seems very hacky and for some reason didn't work in some environments.

sudo apt-get install --yes $(dpkg-checkbuilddeps | sed 's/([^)]*)//g' | sed 's/dpkg-checkbuilddeps:\serror:\sUnmet build dependencies://g')

Is there a better way?

1
19

I use mk-build-deps from the devscripts package for this (you’ll also need equivs).

mk-build-deps

will build a package depending on all the build-dependencies in the debian/control control file; that package can then be installed using apt, which will also install all the missing dependencies.

The advantage of this approach is that uninstalling the dependency package, once you’ve finished with it, will also identify any build-dependencies which could also be uninstalled.

To reduce manual steps, the following command can be used:

mk-build-deps --install --root sudo --remove
0
2

Try the following:

dpkg-checkbuilddeps 2>&1 | sed 's/dpkg-checkbuilddeps:\serror:\sUnmet build dependencies: //g' | sed 's/[\(][^)]*[\)] //g'

First of all, dpkg-checkbuilddeps prints out the error to stderr not stdout. So it needs to be redirected to stdout to use pipeline.

Here is how to Redirect stderr and stdout in Bash

You used the regex ([^)]*) on:

sed 's/([^)]*)//g'

But it should be:

sed 's/[\(][^)]*[\)]//g'

Reference: Using sed to delete a string between parentheses

0
0

Combining the 2 methods previously mentioned worked for me:

sudo apt-get install \
    --yes $(dpkg-checkbuilddeps 2>&1 | sed -e 's/dpkg-checkbuilddeps:\serror:\sUnmet build dependencies: //g' -e  's/[\(][^)]*[\)] //g')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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