Debian – How to install / parse build dependencies from debian/control

command linedebianpackage-managementpackaging

Let's suppose you downloaded a source code folder, that contains an existing /debian/ folder as well as /debian/control file.

Let's suppose the package in question is not in Debian official repository, so apt-get build-dep cannot be used.

How to parse the Build-Depends: line?

For example, if the line would read Build-Depends: debhelper (>= 8), faketime, is there some tool control-parse debian/control build-depends that would echo debhelper faketime?

Especially when it's multi line?

Are there existing Debian tools or has one to write its own code to parse this?

Best Answer

You could use dpkg-checkbuilddeps. The man page says

This program checks the installed packages in the system against the build dependencies and build conflicts listed in the control file. If any are not met, it displays them and exits with a nonzero return code.

For example:

faheem@orwell:/usr/local/src/julia/julia-0.3.2$ dpkg-checkbuilddeps
dpkg-checkbuilddeps: Unmet build dependencies: libopenblas-dev (>= 0.2.10-1~) libopenlibm-dev libopenspecfun-dev (>= 0.4~) patchelf python-sphinx-rtd-theme

However, you could also just try building the package, using (for example) debuild, e.g.

faheem@orwell:/usr/local/src/julia/julia-0.3.2$ debuild -uc -us
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: source package julia
dpkg-buildpackage: source version 0.3.2-1
dpkg-buildpackage: source changed by Sébastien Villemot <sebastien@debian.org>
 dpkg-source --before-build julia-0.3.2
dpkg-buildpackage: host architecture amd64
dpkg-checkbuilddeps: Unmet build dependencies: libopenblas-dev (>= 0.2.10-1~) libopenlibm-dev libopenspecfun-dev (>= 0.4~) patchelf python-sphinx-rtd-theme
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1357:
dpkg-buildpackage -rfakeroot -D -us -uc failed

Which gives the same information (since it uses dpkg-checkbuilddeps), but is a little noisier.

Related Question