Simple .deb Creation For Ubuntu

I recently wanted to create a .deb package in Ubuntu for the new netatalk version. Finding a decent tutorial for what should be a simple thing was a PITA.  So here’s one that will hopefully help some people out:

  1. Create a folder to work in, eg. ~/builds
  2. Download/copy the source code to the ~/builds folder (make sure the file name is in the format thepackage-versionnumber.tar.gz, eg. mycode-2.4.tar.gz)
  3. Decompress the contents of the .tar.gz to a folder with the same name (eg. mycode-2.4).  ie.
    tar zxvf mycode-2.4.tar.gz
  4. Install the necessary packages for package building:
    sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder 
  5. cd to mycode-2.4 directory.  Note that from here on in all commands are issued from this directory.
  6. Run dh_make
    dh_make email@address.com -f ../mycode-2.4.tar.gz

    In most cases you’ll want to select s(single) when prompted

  7.  Edit ./debian/control.  In particular you’ll want to add any build dependancies to the Build-Depends: line.  You can find the dependancies by running:
    dkpg-depcheck -d ./configure --add --any --build --options --here
  8. Run ./configure with any build options you need (You can usually find what’s available by running ./configure –help):
    ./configure --add --any --build --options --here
  9. Build the package:
    dpkg-buildpackage -rfakeroot
The package will then be located at ~/builds/mycode_2.4-1_thearchitecture.deb