Howto build a trivial Debian package with dh_make
Building a Debian package can be complicated. If you’re in a hurry to build a really simple package, you might find the available documentation (such as the Debian New Maintainers’ Guide) overwhelming. Maybe you just want to install some files with dpkg. Maybe you don’t want to deal with Makefiles. Maybe you discovered the source package for hello-debhelper (the “Hello World” of Debian packaging) uncompresses to 3.1MB. Maybe these instructions will be more helpful. Then again, maybe not.
This example will create an architecture-independent package called foo which will install an empty file at /usr/share/example/file. To install other files, just place them wherever you want them to go under the example-src directory.
mkdir foo-0.1 cd foo-0.1 dh_make --createorig --indep # this will prompt you to hit enter mkdir essentials mv debian/{changelog,compat,rules,control} essentials rm -r debian mv essentials debian echo './example-src/* ./' > debian/foo.install mkdir -p example-src/usr/share/example touch example-src/usr/share/example/file # create the empty file to be installed dpkg-buildpackage -uc -tc -rfakeroot dpkg --contents ../foo_0.1-1_all.deb # inspect the resulting Debian package
Notes:
- In addition to these steps, you probably want to edit the debian/control and debian/changelog files.
- The version of the package is defined by the changelog entry, which must conform to the Debian changelog format. (dh_make wrote the first entry for you, with the version taken from the name of the directory you ran it in.)
- For reasons I haven’t investigated, if you try to put files under /usr/local/ this recipe won’t work. (There are probably other directories this will also not work for; /usr/share and /var are all that I’ve tried successfully.)
- These instructions were tested using debhelper 8.0.0ubuntu1 and dh-make 0.55; if you find that they do not work in some newer version please leave a note in the comments.
10 comments