Compdigitec Labs

« | Home | »

Creating Debian packages (properly) using debhelper

By admin | April 28, 2012

# change these to fit your name/e-mail address
export DEBEMAIL="john.smith@fanboys.example.com"
export DEBFULLNAME="John Smith"

wget http://www.example.com/pub/example-2.0.1.tar.gz
tar zxvf example-2.0.1.tar.gz
cd example-2.0.1
dh_make -f ../example-2.0.1.tar.gz

Now, open up debian/control and modify the section field to fit one of the valid Debian sections. Then, the Build-Depends field should have whatever packages you need – minimally it should have debhelper (>= 7.0.50~), dh-buildinfo, dh-autoreconf (if you need it), along with any libraries your application will need. Set the Homepage field to be the URL of your software’s homepage on the Internet.

Once you are happy with that you can modify your package’s fields, right below the source section. Set the Architechture (i386, amd64, or etc), add Depends (Depends: ${shlibs:Depends}, ${misc:Depends} should work in most cases, because dh_shlibdeps is called). Finally, modify the package description.

A sample debian/control file:

Source: example
Section: misc
Priority: optional
Maintainer: John Smith
Build-Depends: debhelper (>= 7.0.50~),
               dh-buildinfo,
               dh-autoreconf,
               libogg-dev
Standards-Version: 3.8.4
Homepage: http://www.example.org/
Vcs-Git: git://git.example.org/example.git
Vcs-Browser: http://git.example.org/?p=example.git;a=summary

Package: example
Architecture: i386
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Awesome example application
 Example is an awesome example application. It provides examples to do many things.
 .
 Example can also be used as an excuse to not learn how to make examples.

A sample debian/rules file:

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

build:
	./configure --prefix=/usr --sysconfdir=/etc --enable-ogg --enable-the-force --disable-stuff --blah-blah=blah
	make

binary:
	dh_testroot
	dh_auto_install
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

%:
	dh $@

To build the package (assuming everything compiles correctly):

dpkg-buildpackage -nc -us -uc -ivolatile_build_folder/

Explanation:
-nc means don’t clean (saves you time in case an error occurs)
-us and -uc mean unsigned source and unsigned changes recently, not useful if you are not official maintainer
-i means don’t consider this folder when making diff archive (to avoid dpkg-source: error: unrepresentable changes to source)

After this process is complete, the built .deb file can be found in the folder above the source folder.

Useful links:

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Linux | 10 Comments »

10 Responses to “Creating Debian packages (properly) using debhelper”

  1. Thai Lottery Says:
    January 14th, 2025 at 18:29

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  2. som777 Says:
    January 25th, 2025 at 06:11

    … [Trackback]

    […] Information to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  3. kc9 Says:
    January 26th, 2025 at 21:54

    … [Trackback]

    […] Here you can find 5089 more Information to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  4. kc9 Says:
    January 26th, 2025 at 22:53

    … [Trackback]

    […] Read More on to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  5. KC9 สล็อต เว็บตรงไม่ผ่านเอเย่นต์ Says:
    January 29th, 2025 at 22:04

    … [Trackback]

    […] There you will find 53600 additional Info to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  6. ดูบอลสด66 Says:
    February 6th, 2025 at 06:34

    … [Trackback]

    […] Find More here to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  7. สีพ่นรถยนต์ Says:
    February 6th, 2025 at 21:44

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  8. โคมไฟ Says:
    February 11th, 2025 at 10:02

    … [Trackback]

    […] Find More Information here on that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  9. pgslot Says:
    February 14th, 2025 at 03:27

    … [Trackback]

    […] Read More Info here to that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

  10. เอเจนซี่ศัลยกรรมจีน Says:
    February 14th, 2025 at 21:42

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2012/04/28/creating-debian-packages-properly-using-debhelper/ […]

Comments