I wanted to use an old program on my computer(s). The program was available as source and binary, but the binary had unsatisfiable dependencies, and were not the latest version. So I thought this might be a good case of learning to create a source .deb and then offering it for download (the program in question, qjoypad, was licensed with GPL 2).
Here is a step-by-step instruction of how to do that.
0. Install the necessary software for creating deb-packages and compiling. Strictly speaking, these are two different things, you don't need to be able to compile the software in order to create a source .deb
For creating the source .deb, you need:1
apt-get install autotools-dev fakeroot dh-make
1. get the source, extract it and go to that directory:
wget -nd http://surfnet.dl.sourceforge.net/sourceforge/qjoypad/qjoypad-3.4.1.tgz tar -zxvf qjoypad-3.4.1.tgz cd qjoypad-3.4.1
2. Create the files needed for the .deb: (gpl is used here, because this particular program was licensed with gpl, you have to check what license applies to your program, of course.)
dh_make -c gpl -e hans@sociologi.cjb.net -s --createorig
3. Optionally edit debian/README.Debian and debian/control
4. Build the source package
dpkg-buildpackage -rfakeroot -S -us -uc
While this didn't really fail, it didn't produce any .deb either, only these three files:
qjoypad_3.4.1-1.dsc qjoypad_3.4.1-1.diff.gz qjoypad_3.4.1-1_source.changes
So I installed the rest of the packages needed for actually compiling the source and creating a binary .deb. The last two are build dependencies of this particular package.
apt-get install build-essential libqt3-mt-dev libxtst-dev
Now, you have to add the commands that actually build the software to
the file debian/rules. But before doing so, edit the config file so
the package will not install into /usr/local, it must only install
into a sub-directory of the debian
directory in the sources.
I had to change
prefix="/usr/local"
into
prefix="usr"
The upstream documented make process was the standard:
./config make make install
These commands must be executed from within the src
directory, so in
debian/rules
I modified the following lines:
# Add here commands to configure the package. cd src; ./config [...] # Add here commands to compile the package. cd src; $(MAKE) [...] # Add here commands to clean up after the build process. cd src; $(MAKE) clean dh_installdirs qjoypad # Add here commands to install the package into debian/qjoypad. cd src; $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/qjoypad install
1. Source: http://www.quietearth.us/articles/2006/08/16/Building-deb-package-from-source