Packaging with Debhelper
[Important]
Requirements: The requirements from the section called "Packaging From Scratch" plus debhelper and dh-make
As a packager, you will rarely create packages from scratch as we have done in the previous section. As you can imagine, many of the tasks and information in the rules file, for instance, are common to packages. To make packaging easier and more efficient, you can use debhelper to help with these tasks. Debhelper is a set of Perl scripts (prefixed with dh_) that automate the process of package-building. With these scripts, building a Debian package becomes quite simple.
In this example, we will again build the GNU Hello package, but this time we will be comparing our work to the Ubuntu hello-debhelper package. Again, create a directory where you will be working:
mkdir ~/hello-debhelper cd ~/hello-debhelper wget http://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz mkdir ubuntu cd ubuntu
Then, get the Ubuntu source package:
apt-get source hello-debhelper cd ..
Like the previous example, the first thing we need to do is unpack the original (upstream) tarball.
tar -xzvf hello-2.1.1.tar.gz
Instead of copying the upstream tarball to hello_2.1.1.orig.tar.gz as we did in the previous example, we will let dh_make do the work for us. The only thing you have to do is rename the source folder so it is in the form of <packagename>-<version> where packagename is lowercase. In this case, just untarring the tarball produces a correctly named source directory so we can move into it:
cd hello-2.1.1
To create the initial "debianization" of the source we will use dh_make.
dh_make -e your.maintainer@address -f ../hello-2.1.1.tar.gz
dh_make will then ask you a series of questions:
Type of package: single binary, multiple binary, library, kernel module or cdbs? [s/m/l/k/b] s
Maintainer name : Captain Packager Email-Address : packager@coolness.com Date : Thu, 6 Apr 2006 10:07:19 -0700 Package Name : hello Version : 2.1.1 License : blank Type of Package : Single Hit <enter> to confirm: Enter
[Caution]
Only run dh_make -e once. If you run it again after you do it the first time, it will not work properly. If you want to change it or made a mistake, remove the source directory and untar the upstream tarball afresh. Then you can migrate into the source directory and try again.
Running dh_make -e does two things:
-
Creates the hello_2.1.1.orig.tar.gz file in the parent directory,
-
Creates the basic files needed in debian/ and many template files (.ex) that may be needed.
The Hello program is not very complicated, and as we have seen in the section called "Packaging From Scratch", packaging it does not require much more than the basic files. Therefore, let us remove the .ex files:
cd debian rm *.ex *.EX
For hello, you will also not
* License

