How to create a Debian .deb package for a C program?

The following lists the steps required to create a Debian .deb package for a C program.

Install essential programs:

apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder

I worked on my custom modification of fping source code.

Have your C source code ready in a folder. I put mine in a folder fpingj-1, containing:

l fpingj-1
total 536
-rw-r--r-- 1  510 staff    250 Nov  3  2001 acconfig.h
-rw-r--r-- 1  510 staff   4396 Nov  3  2001 aclocal.m4
-rw-r--r-- 1  510 staff  10816 Mar 15  2001 ChangeLog
-rw-r--r-- 1 root root     978 Aug 26 12:27 config.h
-rw-r--r-- 1  510 staff    865 Nov  3  2001 config.h.in
-rw-r--r-- 1 root root    6474 Aug 26 12:27 config.log
-rwxr-xr-x 1 root root   19879 Aug 26 12:27 config.status
-rwxr-xr-x 1  510 staff 101827 Nov  3  2001 configure
-rw-r--r-- 1  510 staff    669 Nov  3  2001 configure.in
-rw-r--r-- 1  510 staff    716 Mar 15  2001 COPYING
drwxr-xr-x 4 root root    4096 Aug 26 12:27 debian
-rwxr-xr-x 1 root root   74182 Aug 26 12:27 fping
-rw-r--r-- 1  510 staff   7089 Mar 15  2001 fping.8
-rw-r--r-- 1  510 staff  59539 Aug 26 11:36 fping.c
-rw-r--r-- 1 root root  145904 Aug 26 12:27 fping.o
-rw-r--r-- 1  510 staff   7802 Apr 26  2001 INSTALL
-rw-r--r-- 1  510 staff   4773 Mar 15  2001 install-sh
-rw-r--r-- 1  510 staff   4018 Mar 15  2001 linux.h
-rw-r--r-- 1 root root   11078 Aug 26 12:27 Makefile
-rw-r--r-- 1  510 staff    133 Nov  3  2001 Makefile.am
-rw-r--r-- 1  510 staff  11134 Nov  3  2001 Makefile.in
-rwxr-xr-x 1  510 staff   6283 Nov  3  2001 missing
-rw-r--r-- 1  510 staff    730 Mar 15  2001 mkinstalldirs
-rw-r--r-- 1  510 staff   1658 Mar 15  2001 options.h
-rw-r--r-- 1  510 staff   2509 Apr 25  2001 README
-rw-r--r-- 1 root root      10 Aug 26 12:27 stamp-h
-rw-r--r-- 1  510 staff     10 Nov  3  2001 stamp-h.in

Typically the folder should contain your ‘Makefile’.

Create an archive of your folder:

tar zcf jping-1.tar.gz jping-1
cd jping-1/
dh_make -e [email protected] -f ../jping-1.tar.gz

Now edit debian/control, and edit the Maintainer:

Add your name and email address:
Maintainer: G Kappa

Now, run:

dpkg-depcheck -d ./configure

Note the following:
Packages needed:
perl
automake
mime-support
perl-modules
autoconf

And add it to debian/control:

emacs debian/control

Look for the line:
Build-Depends: debhelper (>= 8.0.0)

And change it to:
Build-Depends: debhelper (>= 8.0.0), autotools-dev, perl, automake, mime-support, perl-modules, autoconf

Now edit debian/copyright

Now create a gpg key:

gpg --gen-key --no-use-agent

Edit debian/changelog and modify the line “– ” with your name and email address, from the following block

fpingj (1-1) unstable; urgency=low

  * Initial release (Closes: #nnnn)  <nnnn is the bug number of your ITP>

 -- Someone <[email protected]> Mon, 26 Aug 2013 11:51:38 +0530

I had also done:
gpg –import ~/.gnupg/JoelGMathew.gpg

The name and email should be exactly what you see from the command:

#gpg --list-keys

Now do:

dpkg-buildpackage -rfakeroot

Helpful links:
http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html