55

I have a debian (well technically ubuntu) source package, i.e. the .dsc, the .tar.gz, etc., I want to build this. The dpkg-buildpackage fails, since I don't have all the build dependencies.

Normally I'd use apt-get build-dep, but this package isn't in apt.

Is there a 'clean', 'proper' way to install all the build dependencies, given a source package. I know I could just open the debian/control file, but I'm curious if there's a 'proper' way.

I have installed build-essential, and have all the normal compilers etc., this package requires extra software.

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246

6 Answers6

43

Use mk-build-deps which is part of devscripts.

ptman
  • 27,124
  • 2
  • 26
  • 45
  • 2
    For those looking to create a source package for normal depends, use `equivs-build`. This would be the "other half" of `mk-build-deps`. – ayao1337 Mar 28 '21 at 05:55
19

Here is an example workflow using ptman's suggestion.

Assuming you have downloaded the .dsc file, the .orig.*z file, and maybe also a .debian.*z file, then unpack the source package with:

dpkg-source -x [package_name]_[package_version].dsc

Move into the extracted source folder and run:

sudo mk-build-deps -i

This will create the file [package_name]-build-deps_[version].deb and install it, and also install all the dependencies it suggests.

Now you should be able to build your package from source:

debuild

When you are finished, you can easily remove the dependencies that were pulled in, by removing the build-deps package which you generated:

sudo apt-get purge --auto-remove [package_name]-build-deps
joeytwiddle
  • 484
  • 4
  • 7
  • 5
    You can also pass `-r` to `sudo mk-build-deps -i` to remove the package after installing it. Also, instead of building as root, you can install as root using `--root-cmd sudo`. In the end, use `mk-build-deps --install --root-cmd sudo --remove` – Lucas Nov 08 '17 at 19:17
  • Also, you may need to `sudo apt install devscripts equivs` first. – Alba Mendez May 31 '19 at 10:03
11

Actually I can use dpkg-checkbuilddeps which shows the build dependencies. That gets me 99% of what I need

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246
  • 4
    oddly enough, the *packagename-version.dsc* file contains the build dependencies in the line that begins with the string **Build-Depends** – quack quixote Mar 30 '10 at 13:46
6

I usually use debuild from devscripts to build packages, and if relevent it prints a line of the missing build-deps.

The "proper" way is to use pbuilder or similar which will build the package in a minimal chroot, and just install any additional build-deps as specified by the package, this also removes a bunch of other potential issues (local installations of non-packaged libraries for example).

LapTop006
  • 6,466
  • 19
  • 26
0

The file debian/control lists all the packages that should be installed as build-dependencies. If (for whatever reason) you have installed some of the required software without the apt system, then just remove respective lines from the debian/control file, so dpkg-buildpackage will not know about these packages and not check on them.

Another trick is to execute the build instructions directly, which also circumvents any extra checks by dpkg-buildpackage and that also does not perform the cleaning of the build files (helps with incremental local fixes) by executing fakeroot ./debian/rules binary instead of dpkg-buildpackage.

user872021
  • 101
  • 3
-7

Try:

apt-get install build-essential
Lanselot
  • 1,208
  • 9
  • 5