[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ next ]


APT HOWTO (Obsolete Documentation)
Chapter 6 - Working with source packages


6.1 Downloading source packages

It's common in the world of free software to study source code or even make corrections to buggy code. To do this, you would need to download the source of the program. The APT system provides an easy way to obtain source code to the many programs contained in the distribution, including all the files needed to create a .deb for the program.

Another common use of Debian sources is to adapt a more recent version of a program, from the unstable distribution, for example, for use with the stable distribution. Compiling a package against stable will generate .debs with dependencies adjusted to match the packages available in this distribution.

To accomplish this, the deb-src entry in your /etc/apt/sources.list should be pointed at unstable. It should also be enabled (uncommented). See section The /etc/apt/sources.list file, Section 2.1.

To download a source package, you would use the following command:

     $ apt-get source packagename

This will download three files: a .orig.tar.gz, a .dsc and a .diff.gz. In the case of packages made specifically for Debian, the last of these is not downloaded and the first usually won't have "orig" in the name.

The .dsc file is used by dpkg-source for unpacking the source package into the directory packagename-version. Within each downloaded source package there is a debian/ directory that contains the files needed for creating the .deb package.

To auto-build the package when it's been downloaded, just add -b to the command line, like this:

     $ apt-get -b source packagename

If you decide not to create the .deb at the time of the download, you can create it later by running:

     $ dpkg-buildpackage -rfakeroot -uc -b

from within the directory that was created for the package after downloading. To install the package built by the commands above one must use the package manager directly, like this:

     # dpkg -i file.deb

There's a difference between apt-get's source method and its other methods. The source method can be used by normal users, without needing special root powers. The files are downloaded to the directory from which the apt-get source package command was called.


6.2 Packages needed for compiling a source package

Normally, specific headers and shared libraries need to be present in order for a source package to be compiled. All source packages have a field in their control files called 'Build-Depends:' that indicates which additional packages are needed for the package to be built from source.

APT has a simple way of downloading these packages. Just run apt-get build-dep package, where `package' is the name of the package you're going to build. For example:

     # apt-get build-dep gmc
     Reading Package Lists... Done
     Building Dependency Tree... Done
     The following NEW packages will be installed:
       comerr-dev e2fslibs-dev gdk-imlib-dev imlib-progs libgnome-dev libgnorba-dev
       libgpmg1-dev 
     0 packages upgraded, 7 newly installed, 0 to remove and 1  not upgraded.
     Need to get 1069kB of archives. After unpacking 3514kB will be used.
     Do you want to continue? [Y/n]

The packages that will be installed are the packages needed in order for gmc to be built correctly. It's important to note that this command doesn't look for the source package of the program to be compiled. You will therefore need to run apt-get source separately to get it.

If all you want is checking what packages are needed to build a given package, there's a variant of the apt-cache show command (see Getting information about packages., Chapter 5, which will show, among other informations, the Build-Depends line that lists those information, the Build-Depends line that lists those

     # apt-cache showsrc package

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ next ]


APT HOWTO (Obsolete Documentation)

1.8.11 - August 2005

Gustavo Noronha Silva [email protected]