GNU/Linux Desktop Survival Guide by Graham Williams |
|||||
Building Packages from Source |
You can download the source code for any Debian package from the Debian archive. You can then modify it, if you wish, and then generate your own deb file for installation. Or perhaps, like Gentoo, you are interested in building the package with your local compilation optimisations to suit your system specifically. This is all quite easy with Debian.
The steps involved include:
To obtain the source of a Debian package you will need one or more
deb-src lines in your /etc/apt/sources.list file.
The following is a good start:
deb-src http://ftp.debian.org/debian unstable main contrib non-free |
To obtain and unpack the source Debian package, and have the Debian
patches applied, use:
$ wajig source <package names> (apt-get source) |
The source command downloads a tar.gz file, a dsc file, and possibly a diff file for the package. The tar.gz file contains the source code and associated files. The dsc file contains test information that is used by the packaging system. The diff file contains changes, as a patch file, made by the Debian maintainer of the package. The source command will also extract the contents of the .tar.gz archive into a subdirectory consisting of the package name and version, and applies the patches contained in the diff file.
You could reverse the patching using, for example, if the package we
obtained was most_4.9.5-1.deb:
$ zcat most_4.9.5-1.diff.gz | patch -R -p0 |
To go one step further and also configure and compile the package, and
then generate a default Debian deb package from the
source code then use:
$ wajig build <package names> (apt-get source -b) |
If you need to modify the source to the package (e.g., the package
most) in some way and thus need to rebuild the
deb package, the steps would be:
$ wajig update $ wajig source most $ cd most_4.9.5 |
$ fakeroot dpkg-buildpackage -b -uc -us |
$ cd .. $ wajig install most_4.9.5-1_i386.deb |
Copyright © 1995-2006 [email protected]