I recently had to create modified versions of some debian packages, to apply some custom patches and use some special compilation options for a scratchbox environment. It was time that I learnt something about actually making debian packages. These were packages that Daniel Holbach couldn’t do for me, but he did explain some stuff, which I’ll note here for my reference. He’s not to blame for my errors.
To get existing debian package stuff, make a directory and do this:
- “apt-get source gtkmm2.4”, replacing gtkmm2.4 with your package name.
- or download from the debian page. For instance, http://packages.debian.org/stable/source/gtkmm2.4
This gives you 3 files, of these types:
- .orig.tar.gz: The original source tarball, exactly as you would get it if you downloaded the source code directly.
- .dsc: The Debian Source Control file.
- .diff.gz: A patch to add the debian sub-directory.
You don’t need to uncompress and apply all that manually. There are tools to help:
- dpkg-source -x something.dsc, to expand the source tarball and apply the .diff.gz patch. You then have the source directory, with the debian sub-directory inside. If you did apt-get source then this has been done for you already.
- cd into the source directory.
- Do debuild (or debuild -us -uc to avoid the GPG signing). This builds the package, by reading information from the debian sub-directory, building the source, and putting it all in .debs in the parent directory.
(On scratchbox, where debuild does not work due to fakeroot problems, do dpkg-buildpackage -rfakeroot -sa)
That should confirm that you can actually build the packages. If you are missing some dependencies, try “apt-get build-dep yourpackagname”.
Now you might want to change some things before building the packages again. For instance:
- Using a newer source tarball release:
- Get the source tarball of the latest release.
- Rename it to match the debian convention. For instance:
mv gconfmm-2.14.1.tar.gz gconfmm2.6_2.14.1.orig.tar.gz - Unpack the new tarball.
- Copy the debian directory from the old source directory to the new one.
- cd to the new source directory.
- Do dch -i to edit debian/changelog with the editor. Export EDITOR=editoryoulike if you don’t like vi.
- Change the version number in the new changelog entry. debuild/dpkg-buildpackge actually uses the version number in the changelog for the version number of the debian packages.
- Changing dependencies:
- Edit debian/control and change the Depends line.
- Using special compiler options, or configure options:
- Edit debian/rules and edit the appropriate makefile rule. Try to use a makefile variable, to keep things simple. Some debian/rules files already use CFLAGS or CXXFLAGS variables.
- Apply patches:
- Some debian/rules files have makefile rules to automatically apply any .patch files. If yours does then just add the .patch file in appropriate place. Otherwise, just apply the patch manually and store it in a debian/patches_applied/ directory.
After you have changed the sources and the debian files appropriately, debuild (or dpkg-buildpackage – see above), should build the packages again, putting them in the parent directory. It will even create the .dsc and .diff.gz files, completing the circle.