I Might Be Wrong

Howto build a trivial Debian package with dh_make

Posted in Debian, Ubuntu by Leif Ryge on May 18, 2011

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.
Tagged with: , , , , , ,

6 Responses

Subscribe to comments with RSS.

  1. abb said, on May 31, 2011 at 3:02 pm

    Useful tutorial, thanks.

  2. Jupeter said, on October 6, 2011 at 6:00 am

    Yes … It’s so simple, than brilliant :)
    Thanks a lot :)!!

  3. fritter said, on January 20, 2013 at 5:01 pm

    Your uninvestigated reason –
    The package manager is not supposed to control files under /usr/local.
    http://www.debian.org/releases/stable/i386/ch08s03.html.en#id595726

  4. Rory X. Twedt said, on September 28, 2014 at 5:32 pm

    Hello, i believe that i saw you visited my weblog thus
    i got here to return the want?.I am attempting to find issues to enhance my site!I suppose
    its good enough to make use of some of your ideas!!

  5. Maybelle Y. Spilis said, on October 4, 2014 at 3:01 pm

    I visit every day a few web sites and blogs to read articles or reviews, but this blog offers quality based writing.

  6. Rory U. Underdue said, on October 5, 2014 at 12:22 am

    Hi there mates, nice piece of writing and fastidious urging commented at this place, I am truly enjoying by these.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: