Debian - Working with source packages
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4043
Location: East Coast, West Coast? I know it's one of them.
Reply Quote

This is a pretty complete tutorial re working with Debian's source packages, so I didn't want to forget it.

:: Quote ::
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
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.

Back to top
Display posts from previous:   

All times are GMT - 8 Hours