apt-get build-dep is unable to find a source package
As others have already noted, make sure that for every deb …
entry in /etc/apt/sources.list
and /etc/apt/sources.list.d/*
, you have a matching deb-src …
entry. The rest of the line must be identical.
The deb
entry is for binary packages (i.e. ready to install), the deb-src
is for source packages (i.e. ready to compile). The reason why the two kinds of packages are separated is that they are managed very differently: binary packages have a dependency tracking mechanism and a currently-installed list, whereas source packages are only tracked so that they can be downloaded conveniently.
Note that when discussing package repositories, the word source means two unrelated things: a source as in a location to download packages from, and a source package as opposed to a binary package.
libgtk2.0-0
is the name of a binary package. It is built from a source package called gtk+2.0
. The reason source and binary package names don't always match is that building a source package can produce multiple binary packages; for example, gtk+2.0
is the source for 14 packages as it is split into two libraries (libgtk2.0
, libgail
), corresponding packages to build programs using these libraries (…-dev
), documentation for developers (…-doc
), companion programs (libgtk2.0-bin
), etc.
You can see the name of the source package corresponding to a binary package by checking the Source: …
line in the output of dpkg -s BINARY_PACKAGE_NAME
(if the package is installed) or apt-cache show BINARY_PACKAGE_NAME
.
You can list the binary packages produced by a source package with aptitude search '?source-package(^SOURCE_PACKAGE_NAME$)
.
The command apt-get source
downloads a source package. If you give it an argument which isn't a known source package, it looks it up in the database of installable binary packages and tries to download the corresponding source package.
The command apt-get build-dep
follows the same approach to deduce the name of a source package, then queries the source package database to obtain a list of binary packages (the list in the Build-Dep:
field), and installs those binary packages.
The Software Sources GUI has a checkbox “enable repositories with source code” for official repositories, make sure that it's ticked. If you add third-party repositories manually, make sure that you add both deb-src
and deb
lines.
CLI method
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
Tested on the Ubuntu 18.04 Docker image. After this change, I can successful do for example:
sudo apt-get build-dep hello
and before the change it failed with the error:
E: You must put some 'source' URIs in your sources.list
See also: https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list/857433#857433
software-properties-gtk
option "Source code"
From the GUI, you can run:
software-properties-gtk
then under the "Ubuntu Software" tab click "Source code":
This has added some deb-src
lines under /etc/apt/sources.list
, and now I can do sudo apt-get build-dep <package>
.
Tested on Ubuntu 16.04 to 18.04.
Thanks to @steeldriver, I figured out what to do.
Just had to add the following ling to my /etc/apt/sources.list
:
deb-src ftp://ftp.de.debian.org/debian/ stable main contrib
deb-src repositories contain sources packages (as opposed to binary, ready-to-install packages) needed for compiling.
Edit: After Adding this, you must execute sudo apt-get update