I'm always running debain stable in my machines. It has few updates (great for a slow Internet connection) and it runs smoothly. It's the perfect system for someone like me, who likes a working system rather than looking at what direction developers are taking their software. I run it even in my desktop computer, it's great.
However, from time to time I find myself in a position where I need to run a newer version of a software, yet it's not available for my system. Many times I can use the version from [debian backports][(http://backports.debian.org). Sometimes even they fail me, though. It was the case of octave.
I needed to run octave version 3.4 or greater, otherwise I was unable to work on a project I was interested in. didn't hold a new version of octave. Searching through debian packages I found out that wheezy (the current testing release) had octave. Sometimes one can download the .deb from wheezy release and get it to work in the current release. It wasn't the case, octave depended on libraries my squeeze release didn't have. Also, it needed a liboctave1 package, which I knew was bad because one of the new features of debian wheezy is multiarch libraries. It's a nice feature, but it makes binary library packages backwards incompatible.
I knew I needed to download the source package and work from there. So I updated my /etc/apt/sources.list file and changed squeeze to wheezy, then the following commands downloaded the source package for me:
# aptitude update
$ apt-get source octave
After that I changed my sources.list back to what it was and ran aptitude update once again (just to get my system back to what it was).
Current wheezy version is 3.6.2-5. I don't want to use the same version or higher, otherwise, when I update my system to wheezy, my package won't get overriden (assuming wheezy has version 3.6.2-5 of octave when released). However, I'd like to keep a version that reflects what version my package is based of: tilde to the rescue. By appending ~bpo60+1 to 3.6.2-5 I get a version which is lower than 3.6.2-5 but higher than 3.6.2-4. I'm using debian backports version formating for this package: ~bpo${debian_release}+${build_int}. In order to use that version I have to write to debian/changelog file. The following command will help me with that:
$ dch -v 3.6.2-5~bpo0+1 -b Backported to squeeze
Now comes the generating the package part. I'll use pbuilder for generating the package. People sometimes advise lower level tools. Maybe becuase they're more likely to work in older versions of debian or because there are more options and changes as you get to higher levels. However, pbuilder is the tool I know and love.
First I'll create a chroot environment with pbuilder:
# pbuilder --create --distribution squeeze
It takes a while. After running it, I'm ready to generate my pacakge. First I tried to run pdebuild right away
$ pdebuild --use-pdebuild-internal
It didn't work. The package build depended on something called dh-exec, and a new version of dpkg-dev. Also, there were libraries with versions greater than the ones on stable. Sometimes that means you're out of luck: you need such new libraries in your system. Sometimes they're just what the package maintainer know to work, but the package could work with older libraries as well. Fortunately, octave case was the latter.
So I changed libhdf5-dev (>= 1.8.8) to libhdf5-serial-dev (>= 1.8.4) -- that was the name of the package in stable release. I also changed liblapack-dev (>= 3.4.1-4) to liblapack-dev (>= 3.2.1-8), I'm not sure why the maintainer required such version. The package compiled fine with 3.2.1-8 (and it worked just fine as well -- I did matrix inversion, multiplication, etc.).
I also changed things that impacted on how the packaging works: I set dpkg-dev back to 1.15.8 and removed dh-exec.
As it turns out dh-exec was needed so that .install and .links files had access to the variable DEB_VERSION_UPSTREAM and DEB_HOST_MULTIARCH. I don't need DEB_HOST_MULTIARCH, because I'm packaging to squeeze, so I just removed the variable from proper files. We also don't really need DEB_VERSION_UPSTREAM, I just substituted it to the known value of 3.6.2 on octave-common.links.
I ran the command
$ pdebuild --use-pdebuild-internal
once again and it worked like a charm. I have uploaded my packages to the repository
deb http://kontesti.me squeeze main
deb-src http://kontesti.me squeeze main
feel free to add that to your sources.list. I have also notified people at backports.debian.org. However, recently octave maintainers said they already had a backported package almost ready to go. They said my diff is not much different than theirs, that's good. Their backport is not up yet though.
If you just want to take a quick look at the changes I've made to the debian/ directory, see my patch.