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 firstname.lastname@example.org 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 email@example.com
Maintainer name : Avery J. Parker
Email-Address : firstname.lastname@example.org
Date : Thu, 25 Jan 2007 08:59:15 -0500
Package Name : openvpn
Version : 2.0.9
License : blank
Type of Package : Single
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….
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…
LZO headers were not found
LZO library available from http://www.oberhumer.com/opensource/lzo/
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…..
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…
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.
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 PostsRelated Posts
- apt-get introduction For those of you new to linux and using a debian based distribution... here is a good introduction to the world of apt-get. Apt-get is a tool for installing software, updating software, uninstalling software and even for doing complete distribution upgrades. It was the first easy "package installer" frontend to......
- Building RPM's from Source RPMs Let me start by saying I am FAR from being an expert on the subject of building rpm's... RPM's are binary packages for use in red-hat based distributions. They are used (*in my case on Mandriva) with urpmi to install. Urpmi is a "wrapper" around the rpm utility that figures......
- Ubuntu Gutsy Gibbon coming The release date for the 7.10 Ubuntu release is coming soon. I've installed a beta into a virtual machine to see what's what and so far haven't had much time to play around. I seem to recall the localization question being new in the installer, but then it's been a......
- How to Choose and Install Automatic Lawn Sprinklers Though it might look like an intimidating project, you can install automatic lawn sprinklers and avoid the pricey professional installation fees. Sprinkler systems come with step by step installation instructions to help you. First, you need to decide what kind of automatic sprinklers will work best for you. If you......
- 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......
- 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......
- Metapackages in Ubuntu for new system provisioning
- Building RPM’s from Source RPMs
- apt-get introduction
- Useful Linux Utilities
- Building RPM’s – building from tarballs