|
Producing Debian packages the easy wayIntroductionThe Debian Linux distribution includes a staggaringly wide range of packages. However, eventually you're likely to find yourself requiring a program that hasn't been packaged. The standard thing to do here is simply to install it in /usr/local directly - however, there's a somewhat more elegant alternative. Creating your own package is a good deal easier than you might think in most cases, and brings you the benefits of being able to replace the old version far more easily (especially if an official Debian package of it appears at some point).
The simplest caseThis example assumes that your program can be installed with nothing more than
Firstly, extract your program. Once extracted, the program should be in a directory called programname-version - if not, rename the directory to this and create a new tarball of the resulting directory (tar zcvf programname-version.tar.gz programname-version/). Now enter the directory and extract this tarball. This will create a directory called debian inside the program directory. Enter the debian directory and edit the changelog file to suit. Then edit the control file - the majority of the fields in here should be fairly self-explanatory. Note that a . is required between each paragraph of the long description. Then return to the original program directory and type fakeroot dpkg-buildpackage. This should give you a set of files in the parent directory - the most important of these is the one ending .deb. The others are the source files which you should keep in case you want to modify the package in any way - typing dpkg-source -x packagename.dsc will extract the source providing the other files are present.
Slightly harder onesFor packages that require a slightly more convoluted installation sequence, the easiest thing to do is probably to follow the above instructions but edit the debian/rules file as well. The section headed build-stamp simply contains a list of the commands that must be executed in order to build the package. The other section that is likely to be relevant is headed install - again, this is primarily a list of commands to be executed to install the package. Note that at this point, the package is installed into debian/tmp/usr - this is to allow the package to be built once the binaries are in place. You should make sure that your program is installed here as well. From this point on, simply follow the same instructions as above.
Trickier stillIt's quite possible that your package will require some form of system-specific configuration, or for certain conditions to be set up before it is fully installed. This can be achieved by adding extra files in the debian subdirectory. These should be standard shell or perl scripts called preinst, postinst, prerm and postrm. The preinst script will be run before the files within the package are installed, while the postinst script will be run afterwards. The same is true of the prerm and postrm packages, except that they are used during package removal. Examples may be found in /usr/share/debhelper/autoscripts.These pages are maintained by JCN. This file was last modified on 25/04/01. Copyright © JCN, 1998-2002. |