Building Deb packages from source….

Openvpn has been one of the tools of choice this week, so as I was tinkering on my ubuntu boxen…. I thought why don’t I install openvpn there as well for a little broader testing. So, I did, but was a bit disappointed to see that the version was not the most current. (Yes, they may have merged changes from the current version and left the version number at 2.0.6, but 2.0.9 is out and easy to build an rpm from source….. so….) I’ve compiled from source before, I’ve built RPM’s on Mandrake/Mandriva, but never a deb package.

First, I should recommend that most users stick to the official packages from your vendor. There are times however, when you have a system that a) is no longer officially supported (and for some other reason you don’t wish to upgrade) or b) find an app that isn’t provided by your distro vendor…. or c) find that updates for certain things don’t have priority… (Bug fix updates only for instance.) For those reasons you may want to build your own package.

Why build a deb instead of just installing from source? For starters it let’s the package manager deal with installing (and THAT makes uninstalling much nicer…) The next reason is if you want to distribute to other machines. Let’s say you have 10 ubuntu workstations and wan’t to compile and install the same program on each…. that would be a bit of a waste if the hardware is similar. IF the hardware is similar it makes more sense to compile once and redistribute.

Among the packages you probably will need….

checkinstall build-essential fakeroot dh-make apt-build

so… sudo apt-get install checkinstall build-essential fakeroot dh-make apt-build

When you start working with an actual piece of software to install you may well need other devel libraries. apt-cache search can help you deal with error messages from a compile/build. For this example I’ve downloaded the tarball for openvpn 2.0.9 into an edgy eft vm to my home directory and gone ahead and unpacked it to my home directory (I used the gui, but you could use the terminal and tar -xzvf the download.gz…) SO, I’m left with openvpn-2.0.9 in my home directory. I open up a terminal and cd to that folder/directory.

Now, we need to generate a Debian package control file… that’s what dh_make does. The simplest way to run dh_make is this…. dh_make -s -n -e to tell your (e) mail address, the package is (n)ative to debian and it’s a (s)ingle package. dh_make requires that the folder name be the name of the package and most software tarballs follow this custom/practice.

You should see something like this….

$ dh_make -n -s -e
Maintainer name : Avery J. Parker
Email-Address :
Date : Thu, 25 Jan 2007 08:59:15 -0500
Package Name : openvpn
Version : 2.0.9
License : blank
Type of Package : Single
Hit to confirm:

Then press enter…. and hopefully you’ll see….

Done. Please edit the files in the debian/ subdirectory now. openvpn
uses a configure script, so you probably don’t have to edit the Makefiles.

You don’t HAVE to do anything else, but since my first try left me without the /etc/openvpn directory created… I’m going to edit debian/dirs to include etc/openvpn (leading / is left out of the list of directories you want the package to create.)

Now I’m set to build….

dpkg-buildpackage -rfakeroot

and I get my first error….

dpkg-checkbuilddeps: Unmet build dependencies: autotools-dev

so… it’s we need to install autotools-dev (sudo apt-get autotools-dev) and start the process again…

dpkg-buildpackage -rfakeroot

Another error….
LZO headers were not found
LZO library available from
configure: error: Or try ./configure –disable-lzo
make: *** [config.status] Error 1

This shouldn’t be a big problem….
apt-cache search lzo shows us a few options… let’s try to sudo apt-get install liblzo2-dev and try again…..

dpkg-buildpackage -rfakeroot

another error….
configure: checking for OpenSSL Crypto Library and Header files…
checking openssl/evp.h usability… no
checking openssl/evp.h presence… no
checking for openssl/evp.h… no
configure: error: OpenSSL Crypto headers not found.
make: *** [config.status] Error 1

No openssl header files – we’ll NEED those….
apt-cache search openssl
Lot’s of possible matches, but… libssl-dev looks like our best choice (we’re looking for library *(lib) and header files (dev))….

Now that we’ve apt-get install’ed those… try again…

dpkg-buildpackage -rfakeroot

We’ve apparently met all the dependencies and the build process get’s underway, this could take some time depending on the size of the program…. but towards the end I see this….

dpkg-deb: building package `openvpn’ in `../openvpn_2.0.9_i386.deb’.
tar: -: file name read contains nul character
dpkg-genchanges: including full source code in upload
dpkg-buildpackage: full upload; Debian-native package (full source is included)

which is the bit we’re looking for….

so… sudo dpkg -i ../openvpn_2.0.9_i386.deb and test it out.

That wasn’t REALLY a tough process. It may seem tedious when you’re going through and filling dependencies, but 90% of the time if you read the error message (and the lines preceeding it) you can get a very good clue as to what’s missing and start searching. Odds are it will already be packaged, but there are a few times where you might have to stop building one package to build and package something it requires. That’s the way things go and I appreciate very much the fact that we’ve got the required tools to do so under linux. When the NEXT openvpn release is out I WON’T have to hunt down those same dependencies (of course, they MIGHT require something else in the 2.1 series…)

I should also note that checkinstall run as root should be able to successfully package and install the software on one system. I don’t think checkinstall leaves it’s deb file for portability to other systems. (The advantage of checkinstall over a traditional ./configure make and make install process is that it registers with the package manager for removal/upgrade/etc.)

Yes, I’ve glossed over the details of the build process, but as a simple step by step “here’s how to build this package”, I’ve told everything you need to do as you work towards the finished deb file.

Here are some references for more info…
Rolling your own Debian packages (link is to part 2 of a series).
Debian new maintainers guide
how to make deb packages

You also might be interested in …
how to make your own apt repository with upload support.

Note… after testing with the openvpn package on a system that had NOT had that software previously installed I noticed that /etc/openvpn was created – the init file at /etc/init.d/openvpn was NOT, the binary WAS installed, but sample configs were not. *(Possibly missing manpage too.) So, I need to go back and look at the process a bit. Upgrading from an older version seemed to have all of the above “extras”.

I had a chance to go back and fix my mistake. I needed to add the easy-rsa directory to the ./debian/docs file…. also, TWO packages were built with my last settings the binary and docs in seperate packages. (Last time I did the dh_make I chose multiple binaries.)

Related Posts

Blog Traffic Exchange Related Posts
  • Linux: Using Mandrake (Mandriva's) URPMI tool As background for this, I've used Mandrake Linux (now Mandriva) for my main desktop since around 8.2 I can't remember quite how long ago that's been, but around 3 to 4 years I think. The why is something best saved for another writeup. Early on I was frustrated by installing......
  • Big Ubuntu Linux news This is something that really looks interesting. Recently Linspire announced their intent to open source the CNR (Click N Run) concept for installing software, launching a wiki based web site that would allow supported linux distributions to install software (open source or commercial) with as easy a process as possible......
  • How to Remove SystemVeteran | Removal Guide SystemVeteran is (yet another) variation from the wini family of rogue antivirus applications. Their last one prior to this was BlockProtector (BlockProtector Removal Guide) but it is a VERY long lived family and they are churning out one variation every two to three days. Most of these have the same......
Blog Traffic Exchange Related Websites
  • Enabling DVD playback in Ubuntu 9.04 I have just finished installing Ubuntu 9.04 on a Gateway laptop, everything worked well from video to wireless until I popped in a DVD to watch. Did the updates and still nothing, until I ran across this command on the Internet, tried it and everything is golden now. sudo apt-get......
  • Sensible and Cost Effective Green Building Green construction has to be neither cost prohibitive or complicated, according to experts at the Pacific Coast Builders Conference. According to these experts, building homes that are green and energy efficient does not have to be rocket science at all, but rather you can build a very efficient home at......
  • Pc Is Slow? How To Solve Such Problems? I’m a new PC user and I do not know why my computer is slower and slower, sometimes even freezing. Firstly, I just go to the repair shop for a help, however things are not that simple. After some days, the same thing happened. Have you met with such kind......
PDF24    Send article as PDF   

Similar Posts

See what happened this day in history from either BBC Wikipedia
Amazon Logo

One Response to “Building Deb packages from source….”

  1. Cable Internet Bundles Says:

    Cable Internet Bundles…

    Subscribe Categories Brand Architecture Brand Name Research Brand Naming Branding Company Naming Industry Apparel Automotive Beverages Consumer Electronics Durable Goods Fashion Financial Services Food Health and Beauty Household Goods Media and Entert…

Switch to our mobile site