How to build a Debian package

05Jun10

Update: Check out the new how-to here.

This howto only gives you brief steps to build a Debian package for your program. It is not a great tutorial, but it will help me to remember the steps I have to do when I want to build DeTraS and I hope it will help you in the process of building a package.

In first place, you should read Debian New Maintainers’ Guide, at least the basics of needed files to compile a Debian package and what tools you will need in the process.

Before you start building packages, you may prefer doing this process under a chroot (as I do). This way, you can build and test your package under several environments and right on your machine, even without restarting! There are hundreds of tutorials explaining you how to install and configure a chroot over the Internet, but I will link three of them here [1], [2] and [3].

Now you are ready to building packages, so it’s time to see what kind of package do you want to build:

Build a source package

This option is interesting in the case you want someone else compiles your program or if you want to maintain your own PPA repository.

To do this, you have to follow this steps:

  1. If your code does not have a Makefile (like DeTraS), you should execute ./autogen.sh --prefix=/usr under the chroot you are going to use to generate Makefile.
  2. Run dh_make -f <tarball-path> and follow screen instructions. This will generate a orig.tar.gz file and skeletons for all files you should need to build your Debian package.
  3. Edit files under debian directory as indicates Debian New Maintainers’ Guide.
  4. Generate source package executing dpkg-buildpackage -S.

If you want to upload your package to a Launchpad PPA read this document once you have successfully completed previous steps.

Build a compiled package (aka deb package)

This option allows you to generate deb packages for a specified distro and architecture, ready to install with a single click.

You can build your own deb package following these steps:

  1. If your code does not have a Makefile (like DeTraS), you should execute ./autogen.sh --prefix=/usr under the chroot you are going to use to generate Makefile.
  2. Run dh_make -f <tarball-path> and follow screen instructions. This will generate a orig.tar.gz file and skeletons for all files you should need to build your Debian package.
  3. Edit files under debian directory as indicates Debian New Maintainers’ Guide.
  4. Generate compiled package executing dpkg-buildpackage -B -a<arch>.

Take into account that you will need to compile the package for any distro and architecture you want to support, but remember: chroot is your friend ;-)

About these ads


4 Responses to “How to build a Debian package”


  1. 1 How to build a Debian package | Debian-News.net - Your one stop for news about Debian
  2. 2 Debian Linux: Пособие для гопников » Blog Archive » How to build a Debian package
  3. 3 How to build a Debian package v2.0 « DeTraS Project's Blog
  4. 4 How to build a Debian package | 石木说

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


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: